mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
WIP
This commit is contained in:
parent
031ea7ef16
commit
748386f0af
@ -1,4 +1,5 @@
|
|||||||
require "uuid"
|
require "uuid"
|
||||||
|
require "big"
|
||||||
|
|
||||||
enum FilterType
|
enum FilterType
|
||||||
String
|
String
|
||||||
@ -47,6 +48,23 @@ struct Filter
|
|||||||
_value.as_f32? || nil
|
_value.as_f32? || nil
|
||||||
self.new key, value, type
|
self.new key, value, type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def match_chapter(obj : JSON::Any) : Bool
|
||||||
|
raw_value = obj[key]
|
||||||
|
case type
|
||||||
|
when FilterType::String
|
||||||
|
raw_value.as_s.lower == value.as_s.lower
|
||||||
|
when FilterType::NumMin
|
||||||
|
when FilterType::DateMin
|
||||||
|
BigFloat.new(raw_value) >= BigFloat.new(value)
|
||||||
|
when FilterType::NumMax
|
||||||
|
when FilterType::DateMax
|
||||||
|
BigFloat.new(raw_value) <= BigFloat.new(value)
|
||||||
|
when FilterType::Array
|
||||||
|
raw_value.as_s.lower.split(",")
|
||||||
|
.map(&.strip).include? value.as_s.lower.strip
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
struct Subscription
|
struct Subscription
|
||||||
@ -65,6 +83,10 @@ struct Subscription
|
|||||||
@created_at = Time.utc.to_unix
|
@created_at = Time.utc.to_unix
|
||||||
@last_checked = Time.utc.to_unix
|
@last_checked = Time.utc.to_unix
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def match_chapter(obj : JSON::Any) : Bool
|
||||||
|
filters.all? &.match_chapter(obj)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
struct SubscriptionList
|
struct SubscriptionList
|
||||||
|
Loading…
x
Reference in New Issue
Block a user