Define a DEFAULT_FRESHLY_CLOSED_LIMIT constant
Define DEFAULT_FRESHLY_CLOSED_LIMIT in the Note model to allow the 7 day limit to be referenced in the API controller and in the new `freshy_closed_until` logic. The default value is `7.days`. API users can still override this, but the website uses that default for the duration of the green "freshly closed" notes markers.
This commit is contained in:
parent
d8e51614cb
commit
e057e1c479
2 changed files with 6 additions and 4 deletions
|
@ -351,9 +351,9 @@ module Api
|
|||
# on their status and the user's request parameters
|
||||
def closed_condition(notes)
|
||||
closed_since = if params[:closed]
|
||||
params[:closed].to_i
|
||||
params[:closed].to_i.days
|
||||
else
|
||||
7
|
||||
Note::DEFAULT_FRESHLY_CLOSED_LIMIT
|
||||
end
|
||||
|
||||
if closed_since.negative?
|
||||
|
@ -361,7 +361,7 @@ module Api
|
|||
elsif closed_since.positive?
|
||||
notes.where(:status => "open")
|
||||
.or(notes.where(:status => "closed")
|
||||
.where(notes.arel_table[:closed_at].gt(Time.now.utc - closed_since.days)))
|
||||
.where(notes.arel_table[:closed_at].gt(Time.now.utc - closed_since)))
|
||||
else
|
||||
notes.where(:status => "open")
|
||||
end
|
||||
|
|
|
@ -37,6 +37,8 @@ class Note < ApplicationRecord
|
|||
|
||||
after_initialize :set_defaults
|
||||
|
||||
DEFAULT_FRESHLY_CLOSED_LIMIT = 7.days
|
||||
|
||||
# Sanity check the latitude and longitude and add an error if it's broken
|
||||
def validate_position
|
||||
errors.add(:base, "Note is not in the world") unless in_world?
|
||||
|
@ -75,7 +77,7 @@ class Note < ApplicationRecord
|
|||
def freshly_closed_until
|
||||
return nil unless closed?
|
||||
|
||||
closed_at + 7.days
|
||||
closed_at + DEFAULT_FRESHLY_CLOSED_LIMIT
|
||||
end
|
||||
|
||||
# Return the author object, derived from the first comment
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue