bans: change expires_at field to duration.
Changes: * Change the `expires_at` field to `duration`. * Make moderators choose from a fixed set of standard ban lengths, instead of allowing arbitrary ban lengths. * List `duration` in seconds in the /bans.json API. * Dump bans to BigQuery. Note that some old bans have a negative duration. This is because their expiration date was before their creation date, which is because in 2013 bans were migrated to Danbooru 2 and the original ban creation dates were lost.
This commit is contained in:
@@ -21,7 +21,7 @@ class BigqueryExportService
|
||||
Rails.application.eager_load!
|
||||
|
||||
models = ApplicationRecord.descendants.sort_by(&:name)
|
||||
models -= [Ban, Favorite, IpAddress, TagRelationship, ArtistVersion, ArtistCommentaryVersion, NoteVersion, PoolVersion, PostVersion, WikiPageVersion]
|
||||
models -= [Favorite, IpAddress, TagRelationship, ArtistVersion, ArtistCommentaryVersion, NoteVersion, PoolVersion, PostVersion, WikiPageVersion]
|
||||
models
|
||||
end
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ module Searchable
|
||||
search_text_attribute(name, params)
|
||||
when :boolean
|
||||
search_boolean_attribute(name, params)
|
||||
when :integer, :float, :datetime
|
||||
when :integer, :float, :datetime, :interval
|
||||
search_numeric_attribute(name, params, type: type)
|
||||
when :inet
|
||||
search_inet_attribute(name, params)
|
||||
@@ -221,7 +221,7 @@ module Searchable
|
||||
when :array
|
||||
search_array_attribute(name, subtype, params)
|
||||
else
|
||||
raise NotImplementedError, "unhandled attribute type: #{name}"
|
||||
raise NotImplementedError, "unhandled attribute type: #{name} (#{type})"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -740,6 +740,9 @@ class PostQueryBuilder
|
||||
when :age
|
||||
DurationParser.parse(object).ago
|
||||
|
||||
when :interval
|
||||
DurationParser.parse(object)
|
||||
|
||||
when :ratio
|
||||
object =~ /\A(\d+(?:\.\d+)?):(\d+(?:\.\d+)?)\Z/i
|
||||
|
||||
@@ -765,6 +768,9 @@ class PostQueryBuilder
|
||||
end
|
||||
|
||||
(size * conversion_factor).to_i
|
||||
|
||||
else
|
||||
raise NotImplementedError, "unrecognized type #{type} for #{object}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user