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.
# on their status and the user's request parameters
def closed_condition(notes)
closed_since = if params[:closed]
# on their status and the user's request parameters
def closed_condition(notes)
closed_since = if params[:closed]
+ params[:closed].to_i.days
+ Note::DEFAULT_FRESHLY_CLOSED_LIMIT
end
if closed_since.negative?
end
if closed_since.negative?
elsif closed_since.positive?
notes.where(:status => "open")
.or(notes.where(:status => "closed")
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
else
notes.where(:status => "open")
end
after_initialize :set_defaults
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?
# 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?
def freshly_closed_until
return nil unless closed?
def freshly_closed_until
return nil unless closed?
+ closed_at + DEFAULT_FRESHLY_CLOSED_LIMIT
end
# Return the author object, derived from the first comment
end
# Return the author object, derived from the first comment