diff --git a/app/services/discourse_rewind/action/favorite_categories.rb b/app/services/discourse_rewind/action/most_viewed_categories.rb similarity index 83% rename from app/services/discourse_rewind/action/favorite_categories.rb rename to app/services/discourse_rewind/action/most_viewed_categories.rb index 641ae18..6aa6ebe 100644 --- a/app/services/discourse_rewind/action/favorite_categories.rb +++ b/app/services/discourse_rewind/action/most_viewed_categories.rb @@ -3,7 +3,7 @@ # Topics visited grouped by category module DiscourseRewind module Action - class FavoriteCategories < BaseReport + class MostViewedCategories < BaseReport FakeData = { data: [ { category_id: 1, name: "cats" }, @@ -12,12 +12,12 @@ class FavoriteCategories < BaseReport { category_id: 4, name: "management" }, { category_id: 5, name: "things" }, ], - identifier: "favorite-categories", + identifier: "most-viewed-categories", } def call return FakeData if Rails.env.development? - favorite_categories = + most_viewed_categories = TopicViewItem .joins(:topic) .joins("INNER JOIN categories ON categories.id = topics.category_id") @@ -30,7 +30,7 @@ def call .pluck("categories.id, categories.name") .map { |category_id, name| { category_id: category_id, name: name } } - { data: favorite_categories, identifier: "favorite-categories" } + { data: most_viewed_categories, identifier: "most-viewed-categories" } end end end diff --git a/app/services/discourse_rewind/action/favorite_tags.rb b/app/services/discourse_rewind/action/most_viewed_tags.rb similarity index 85% rename from app/services/discourse_rewind/action/favorite_tags.rb rename to app/services/discourse_rewind/action/most_viewed_tags.rb index 112268d..a11661e 100644 --- a/app/services/discourse_rewind/action/favorite_tags.rb +++ b/app/services/discourse_rewind/action/most_viewed_tags.rb @@ -3,7 +3,7 @@ # Topics visited grouped by tag module DiscourseRewind module Action - class FavoriteTags < BaseReport + class MostViewedTags < BaseReport FakeData = { data: [ { tag_id: 1, name: "cats" }, @@ -12,13 +12,13 @@ class FavoriteTags < BaseReport { tag_id: 4, name: "management" }, { tag_id: 5, name: "things" }, ], - identifier: "favorite-tags", + identifier: "most-viewed-tags", } def call return FakeData if Rails.env.development? - favorite_tags = + most_viewed_tags = TopicViewItem .joins(:topic) .joins("INNER JOIN topic_tags ON topic_tags.topic_id = topics.id") @@ -32,7 +32,7 @@ def call .pluck("tags.id, tags.name") .map { |tag_id, name| { tag_id: tag_id, name: name } } - { data: favorite_tags, identifier: "favorite-tags" } + { data: most_viewed_tags, identifier: "most-viewed-tags" } end end end diff --git a/app/services/discourse_rewind/fetch_reports.rb b/app/services/discourse_rewind/fetch_reports.rb index a685231..c959a24 100644 --- a/app/services/discourse_rewind/fetch_reports.rb +++ b/app/services/discourse_rewind/fetch_reports.rb @@ -26,8 +26,8 @@ class FetchReports Action::ReadingTime, Action::Reactions, Action::Fbff, - Action::FavoriteTags, - Action::FavoriteCategories, + Action::MostViewedTags, + Action::MostViewedCategories, Action::BestTopics, Action::BestPosts, Action::ActivityCalendar, @@ -62,7 +62,13 @@ def fetch_year when 12 current_year else - false + # Otherwise it's impossible to test in browser unless you're + # in December or January + if Rails.env.development? + current_year + else + false + end end end diff --git a/assets/javascripts/discourse/components/reports/favorite-categories.gjs b/assets/javascripts/discourse/components/reports/most-viewed-categories.gjs similarity index 67% rename from assets/javascripts/discourse/components/reports/favorite-categories.gjs rename to assets/javascripts/discourse/components/reports/most-viewed-categories.gjs index 47bb41f..5d72a85 100644 --- a/assets/javascripts/discourse/components/reports/favorite-categories.gjs +++ b/assets/javascripts/discourse/components/reports/most-viewed-categories.gjs @@ -1,18 +1,18 @@ import { concat } from "@ember/helper"; import { i18n } from "discourse-i18n"; -const FavoriteCategories =