api: support the expires_in param on all GET requests.
`expires_in` is an alternative to `expiry` that supports durations other than days: * https://danbooru.donmai.us/posts.json?expires_in=30s * https://danbooru.donmai.us/posts.json?expires_in=5min * https://danbooru.donmai.us/posts.json?expires_in=1hour * https://danbooru.donmai.us/posts.json?expires_in=1week * https://danbooru.donmai.us/posts.json?expires_in=1month
This commit is contained in:
@@ -313,29 +313,7 @@ class Tag < ApplicationRecord
|
||||
end
|
||||
|
||||
when :age
|
||||
object =~ /(\d+)(s(econds?)?|mi(nutes?)?|h(ours?)?|d(ays?)?|w(eeks?)?|mo(nths?)?|y(ears?)?)?/i
|
||||
|
||||
size = $1.to_i
|
||||
unit = $2
|
||||
|
||||
case unit
|
||||
when /^s/i
|
||||
size.seconds.ago
|
||||
when /^mi/i
|
||||
size.minutes.ago
|
||||
when /^h/i
|
||||
size.hours.ago
|
||||
when /^d/i
|
||||
size.days.ago
|
||||
when /^w/i
|
||||
size.weeks.ago
|
||||
when /^mo/i
|
||||
size.months.ago
|
||||
when /^y/i
|
||||
size.years.ago
|
||||
else
|
||||
size.seconds.ago
|
||||
end
|
||||
DurationParser.parse(object).ago
|
||||
|
||||
when :ratio
|
||||
object =~ /\A(\d+(?:\.\d+)?):(\d+(?:\.\d+)?)\Z/i
|
||||
|
||||
Reference in New Issue
Block a user