This commit is contained in:
Jordan Vidrine 2025-01-03 10:40:24 -06:00
commit d0f813207b
11 changed files with 64 additions and 20 deletions

View File

@ -10,7 +10,7 @@ module DiscourseRewind
.where(deleted_at: nil) .where(deleted_at: nil)
.where("post_number > 1") .where("post_number > 1")
.order("like_count DESC NULLS LAST") .order("like_count DESC NULLS LAST")
.limit(5) .limit(3)
.pluck(:id, :topic_id, :like_count, :reply_count, :raw, :cooked) .pluck(:id, :topic_id, :like_count, :reply_count, :raw, :cooked)
{ data: best_posts, identifier: "best-posts" } { data: best_posts, identifier: "best-posts" }

View File

@ -9,7 +9,7 @@ module DiscourseRewind
.references(:topic) .references(:topic)
.where(topic: { deleted_at: nil, created_at: date, user_id: user.id }) .where(topic: { deleted_at: nil, created_at: date, user_id: user.id })
.order("yearly_score DESC NULLS LAST") .order("yearly_score DESC NULLS LAST")
.limit(5) .limit(3)
.pluck(:topic_id, :title, :excerpt, :yearly_score) .pluck(:topic_id, :title, :excerpt, :yearly_score)
.map do |topic_id, title, excerpt, yearly_score| .map do |topic_id, title, excerpt, yearly_score|
{ topic_id: topic_id, title: title, excerpt: excerpt, yearly_score: yearly_score } { topic_id: topic_id, title: title, excerpt: excerpt, yearly_score: yearly_score }

View File

@ -27,7 +27,7 @@ module DiscourseRewind
ndoc DESC, ndoc DESC,
word word
LIMIT LIMIT
100 5
), lex AS ( ), lex AS (
SELECT SELECT
DISTINCT ON (lexeme) to_tsvector('english', word) as lexeme, DISTINCT ON (lexeme) to_tsvector('english', word) as lexeme,

View File

@ -1,6 +1,5 @@
import Component from "@glimmer/component"; import Component from "@glimmer/component";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { and, eq } from "truth-helpers";
import concatClass from "discourse/helpers/concat-class"; import concatClass from "discourse/helpers/concat-class";
const ROWS = 7; const ROWS = 7;
@ -8,8 +7,6 @@ const COLS = 53;
export default class ActivityCalendar extends Component { export default class ActivityCalendar extends Component {
get rowsArray() { get rowsArray() {
console.log(this.args.report.data);
const data = this.args.report.data; const data = this.args.report.data;
let rowsArray = []; let rowsArray = [];

View File

@ -1,9 +1,22 @@
import Component from "@glimmer/component"; import Component from "@glimmer/component";
import { get } from "@ember/object";
import { htmlSafe } from "@ember/template";
export default class BestPosts extends Component { export default class BestPosts extends Component {
<template> <template>
<div class="rewind-report-page"> <div class="rewind-report-page -best-posts">
Best posts <h3 class="rewind-report-title">Your 3 best posts</h3>
<div class="rewind-report-container">
{{#each @report.data as |post|}}
<div class="rewind-card">
<div class="best-posts__post">{{htmlSafe (get post "5")}}</div>
<span class="best-posts__likes">Likes:
{{htmlSafe (get post "2")}}</span>
<span class="best-posts__replies">Replies:
{{htmlSafe (get post "3")}}</span>
</div>
{{/each}}
</div>
</div> </div>
</template> </template>
} }

View File

@ -1,9 +1,23 @@
import Component from "@glimmer/component"; import Component from "@glimmer/component";
import { concat } from "@ember/helper";
export default class BestTopics extends Component { export default class BestTopics extends Component {
<template> <template>
<div class="rewind-report-page"> <div class="rewind-report-page -best-topics">
BestTopics <h3 class="rewind-report-title">Your 3 best topics</h3>
<div class="rewind-report-container">
{{log @report.data}}
{{#each @report.data as |topic|}}
<div class="rewind-card">
<a
href={{concat "/t/-/" topic.topic_id}}
class="best-topics__title"
>
{{topic.title}}
</a>
</div>
{{/each}}
</div>
</div> </div>
</template> </template>
} }

View File

@ -2,8 +2,16 @@ import Component from "@glimmer/component";
export default class WordCloud extends Component { export default class WordCloud extends Component {
<template> <template>
<div class="rewind-report-page"> <div class="rewind-report-page -word-cloud">
Word cloud <h3 class="rewind-report-title">Most used words</h3>
<div class="rewind-report-container">
{{#each-in @report.data as |word count|}}
<div class="rewind-card">
<span>{{word}}</span>
<span>{{count}} times</span>
</div>
{{/each-in}}
</div>
</div> </div>
</template> </template>
} }

View File

@ -113,16 +113,14 @@ export default class Rewind extends Component {
<div class={{concatClass "rewind-report" report.identifier}}> <div class={{concatClass "rewind-report" report.identifier}}>
{{#if (eq report.identifier "reactions")}} {{#if (eq report.identifier "reactions")}}
<Reactions @report={{report}} /> <Reactions @report={{report}} />
<Reactions @report={{report}} /> {{else if (eq report.identifier "word-cloud")}}
<Reactions @report={{report}} /> <WordCloud @report={{report}} />
<Reactions @report={{report}} /> {{else if (eq report.identifier "best-posts")}}
<BestPosts @report={{report}} />
{{else if (eq report.identifier "best-topics")}}
<BestTopics @report={{report}} />
{{else if (eq report.identifier "activity-calendar")}} {{else if (eq report.identifier "activity-calendar")}}
<ActivityCalendar @report={{report}} /> <ActivityCalendar @report={{report}} />
<ActivityCalendar @report={{report}} />
<ActivityCalendar @report={{report}} />
<ActivityCalendar @report={{report}} />
{{/if}} {{/if}}
{{!-- {{else if (eq report.identifier "fbff")}} {{!-- {{else if (eq report.identifier "fbff")}}
<FBFF @report={{report}} /> <FBFF @report={{report}} />

View File

@ -0,0 +1,6 @@
.-best-posts {
.rewind-report-container {
flex-direction: column;
gap: 1em;
}
}

View File

@ -0,0 +1,6 @@
.-best-topics {
.rewind-report-container {
flex-direction: column;
gap: 1em;
}
}

View File

@ -4,4 +4,6 @@
@import "post-received-reactions"; @import "post-received-reactions";
@import "post-used-reactions"; @import "post-used-reactions";
@import "activity-calendar"; @import "activity-calendar";
@import "best-posts";
@import "best-topics";
@import "blobs"; @import "blobs";