diff --git a/app/services/discourse_rewind/rewind/action/reading_time.rb b/app/services/discourse_rewind/rewind/action/reading_time.rb index b83f337..94e5732 100644 --- a/app/services/discourse_rewind/rewind/action/reading_time.rb +++ b/app/services/discourse_rewind/rewind/action/reading_time.rb @@ -11,7 +11,7 @@ module DiscourseRewind data: { reading_time: reading_time, book: best_book_fit(reading_time)[:title], - isbn: best_book_fit(reading_time)[:isbn] + isbn: best_book_fit(reading_time)[:isbn], }, identifier: "reading-time", } @@ -19,26 +19,86 @@ module DiscourseRewind def popular_books { - "The Hunger Games" => { reading_time: 19_740, isbn: "978-0439023481" }, - "The Metamorphosis" => { reading_time: 3120, isbn: "978-0553213690" }, - "To Kill a Mockingbird" => { reading_time: 22_800, isbn: "978-0061120084" }, - "Pride and Prejudice" => { reading_time: 25_200, isbn: "978-1503290563" }, - "1984" => { reading_time: 16_800, isbn: "978-0451524935" }, - "The Lord of the Rings" => { reading_time: 108_000, isbn: "978-0544003415" }, - "Harry Potter and the Sorcerer's Stone" => { reading_time: 24_600, isbn: "978-0590353427" }, - "The Great Gatsby" => { reading_time: 12_600, isbn: "978-0743273565" }, - "The Little Prince" => { reading_time: 5400, isbn: "978-0156012195" }, - "Animal Farm" => { reading_time: 7200, isbn: "978-0451526342" }, - "The Catcher in the Rye" => { reading_time: 18_000, isbn: "978-0316769488" }, - "Jane Eyre" => { reading_time: 34_200, isbn: "978-0141441146" }, - "Fahrenheit 451" => { reading_time: 15_000, isbn: "978-1451673319" }, - "The Hobbit" => { reading_time: 27_000, isbn: "978-0547928227" }, - "The Da Vinci Code" => { reading_time: 37_800, isbn: "978-0307474278" }, - "Little Women" => { reading_time: 30_000, isbn: "978-0147514011" }, - "One Hundred Years of Solitude" => { reading_time: 46_800, isbn: "978-0060883287" }, - "And Then There Were None" => { reading_time: 16_200, isbn: "978-0062073488" }, - "The Alchemist" => { reading_time: 10_800, isbn: "978-0061122415" }, - "The Hitchhiker's Guide to the Galaxy" => { reading_time: 12_600, isbn: "978-0345391803" }, + "The Hunger Games" => { + reading_time: 19_740, + isbn: "978-0439023481", + }, + "The Metamorphosis" => { + reading_time: 3120, + isbn: "978-0553213690", + }, + "To Kill a Mockingbird" => { + reading_time: 22_800, + isbn: "978-0061120084", + }, + "Pride and Prejudice" => { + reading_time: 25_200, + isbn: "978-1503290563", + }, + "1984" => { + reading_time: 16_800, + isbn: "978-0451524935", + }, + "The Lord of the Rings" => { + reading_time: 108_000, + isbn: "978-0544003415", + }, + "Harry Potter and the Sorcerer's Stone" => { + reading_time: 24_600, + isbn: "978-0590353427", + }, + "The Great Gatsby" => { + reading_time: 12_600, + isbn: "978-0743273565", + }, + "The Little Prince" => { + reading_time: 5400, + isbn: "978-0156012195", + }, + "Animal Farm" => { + reading_time: 7200, + isbn: "978-0451526342", + }, + "The Catcher in the Rye" => { + reading_time: 18_000, + isbn: "978-0316769488", + }, + "Jane Eyre" => { + reading_time: 34_200, + isbn: "978-0141441146", + }, + "Fahrenheit 451" => { + reading_time: 15_000, + isbn: "978-1451673319", + }, + "The Hobbit" => { + reading_time: 27_000, + isbn: "978-0547928227", + }, + "The Da Vinci Code" => { + reading_time: 37_800, + isbn: "978-0307474278", + }, + "Little Women" => { + reading_time: 30_000, + isbn: "978-0147514011", + }, + "One Hundred Years of Solitude" => { + reading_time: 46_800, + isbn: "978-0060883287", + }, + "And Then There Were None" => { + reading_time: 16_200, + isbn: "978-0062073488", + }, + "The Alchemist" => { + reading_time: 10_800, + isbn: "978-0061122415", + }, + "The Hitchhiker's Guide to the Galaxy" => { + reading_time: 12_600, + isbn: "978-0345391803", + }, }.symbolize_keys end @@ -54,16 +114,10 @@ module DiscourseRewind reading_time_rest -= best_fit.last[:reading_time] end - book_title = books.group_by { |book| book } - .transform_values(&:count) - .max_by { |_, count| count } - .first - # popular_books[book_title] + book_title = + books.group_by { |book| book }.transform_values(&:count).max_by { |_, count| count }.first - { - title: book_title, - isbn: popular_books[book_title][:isbn], - } + { title: book_title, isbn: popular_books[book_title][:isbn] } end end -end \ No newline at end of file +end diff --git a/app/services/discourse_rewind/rewind/action/word_cloud.rb b/app/services/discourse_rewind/rewind/action/top_words.rb similarity index 93% rename from app/services/discourse_rewind/rewind/action/word_cloud.rb rename to app/services/discourse_rewind/rewind/action/top_words.rb index 638c1dd..aa978e8 100644 --- a/app/services/discourse_rewind/rewind/action/word_cloud.rb +++ b/app/services/discourse_rewind/rewind/action/top_words.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -# User Word Cloud module DiscourseRewind - class Rewind::Action::WordCloud < Rewind::Action::BaseReport + class Rewind::Action::TopWords < Rewind::Action::BaseReport FakeData = { data: [ { word: "what", score: 100 }, @@ -12,7 +11,7 @@ module DiscourseRewind { word: "this", score: 60 }, { word: "week", score: 50 }, ], - identifier: "word-cloud", + identifier: "top-words", } def call @@ -81,7 +80,7 @@ module DiscourseRewind word_score = words.map { { word: _1.original_word, score: _1.ndoc + _1.nentry } } - { data: word_score, identifier: "word-cloud" } + { data: word_score, identifier: "top-words" } end end end diff --git a/assets/javascripts/discourse/components/reports/activity-calendar.gjs b/assets/javascripts/discourse/components/reports/activity-calendar.gjs index b317b81..6e0ba0d 100644 --- a/assets/javascripts/discourse/components/reports/activity-calendar.gjs +++ b/assets/javascripts/discourse/components/reports/activity-calendar.gjs @@ -1,6 +1,7 @@ import Component from "@glimmer/component"; import { action } from "@ember/object"; import concatClass from "discourse/helpers/concat-class"; +import { i18n } from "discourse-i18n"; const ROWS = 7; const COLS = 53; @@ -22,6 +23,11 @@ export default class ActivityCalendar extends Component { return rowsArray; } + @action + getAbbreviatedMonth(monthIndex) { + return moment().month(monthIndex).format("MMM"); + } + @action computeClass(count) { if (!count) { @@ -37,24 +43,62 @@ export default class ActivityCalendar extends Component {