cartodb-4.42/lib/carto/metrics/twitter_imports_retriever.rb

25 lines
637 B
Ruby
Raw Normal View History

2024-04-06 13:25:13 +08:00
module Carto::Metrics
class TwitterImportsRetriever
def metrics
[:retrieved_items]
end
def services
[:twitter_imports]
end
def get_range(user, org, _service, _metric, date_from, date_to)
tweets_query = if user
user.search_tweets
else
org.users.joins(:search_tweets).reorder(nil)
end
result = Carto::SearchTweet.twitter_imports_count_by_date(tweets_query, date_from, date_to)
date_from.upto(date_to) do |date|
result[date] = 0 unless result[date]
end
result
end
end
end