Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove dead code from Rewind

Régis Hanol8363d2f33316
diff --git a/plugins/discourse-rewind/app/services/discourse_rewind/action/base_report.rb b/plugins/discourse-rewind/app/services/discourse_rewind/action/base_report.rb
index e62d35fbfc7..0debaa676f3 100644
--- a/plugins/discourse-rewind/app/services/discourse_rewind/action/base_report.rb
+++ b/plugins/discourse-rewind/app/services/discourse_rewind/action/base_report.rb
@@ -6,10 +6,6 @@ module DiscourseRewind
option :user
option :date
- def call
- raise NotImplementedError
- end
-
def self.publicly_visible_topics
Topic.listable_topics.visible.secured
end
diff --git a/plugins/discourse-rewind/app/services/discourse_rewind/action/reading_time.rb b/plugins/discourse-rewind/app/services/discourse_rewind/action/reading_time.rb
index 7f897b24da4..3ee4fcaeecf 100644
--- a/plugins/discourse-rewind/app/services/discourse_rewind/action/reading_time.rb
+++ b/plugins/discourse-rewind/app/services/discourse_rewind/action/reading_time.rb
@@ -172,6 +172,8 @@ module DiscourseRewind
}
end
+ private
+
def best_book_fit(reading_time)
best_fit =
POPULAR_BOOKS
diff --git a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/best-posts.gjs b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/best-posts.gjs
index b4fdffeddeb..9cdb518ee1d 100644
--- a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/best-posts.gjs
+++ b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/best-posts.gjs
@@ -24,38 +24,36 @@ export default class BestPosts extends Component {
}
<template>
- {{#if @report.data.length}}
- <div class="rewind-report-page --best-posts">
- <h2 class="rewind-report-title">
- {{this.titleText}}
- </h2>
- <div class="rewind-report-container">
- {{#each @report.data as |post idx|}}
- <div class={{dConcatClass "rewind-card" (this.rankClass idx)}}>
- <span class="best-posts --rank"></span>
- <span class="best-posts --rank"></span>
- <div class="best-posts__post">
- <p>{{trustHTML post.excerpt}}</p>
- </div>
- <div class="best-posts__metadata">
- <span class="best-posts__likes">
- {{dIcon "heart"}}{{post.like_count}}
- </span>
- <span class="best-posts__replies">
- {{dIcon "comment"}}{{post.reply_count}}
- </span>
- <a
- href={{getURL
- (concat "/t/" post.topic_id "/" post.post_number)
- }}
- >
- {{i18n "discourse_rewind.reports.best_posts.view_post"}}
- </a>
- </div>
+ <div class="rewind-report-page --best-posts">
+ <h2 class="rewind-report-title">
+ {{this.titleText}}
+ </h2>
+ <div class="rewind-report-container">
+ {{#each @report.data as |post idx|}}
+ <div class={{dConcatClass "rewind-card" (this.rankClass idx)}}>
+ <span class="best-posts --rank"></span>
+ <span class="best-posts --rank"></span>
+ <div class="best-posts__post">
+ <p>{{trustHTML post.excerpt}}</p>
</div>
- {{/each}}
- </div>
+ <div class="best-posts__metadata">
+ <span class="best-posts__likes">
+ {{dIcon "heart"}}{{post.like_count}}
+ </span>
+ <span class="best-posts__replies">
+ {{dIcon "comment"}}{{post.reply_count}}
+ </span>
+ <a
+ href={{getURL
+ (concat "/t/" post.topic_id "/" post.post_number)
+ }}
+ >
+ {{i18n "discourse_rewind.reports.best_posts.view_post"}}
+ </a>
+ </div>
+ </div>
+ {{/each}}
</div>
- {{/if}}
+ </div>
</template>
}
diff --git a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/best-topics.gjs b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/best-topics.gjs
index 65456eb7b4f..b6119bd3586 100644
--- a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/best-topics.gjs
+++ b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/best-topics.gjs
@@ -24,36 +24,32 @@ export default class BestTopics extends Component {
}
<template>
- {{#if @report.data.length}}
- <div class="rewind-report-page --best-topics">
- <h2 class="rewind-report-title">
- {{this.titleText}}
- </h2>
- <div class="rewind-report-container">
- <div class="rewind-card">
- {{#each @report.data as |topic idx|}}
- <div
- class={{dConcatClass "best-topics__topic" (this.rankClass idx)}}
- >
- <span class="best-topics --rank"></span>
- <span class="best-topics --rank"></span>
- <h2 class="best-topics__header">{{dReplaceEmoji
- topic.title
- }}</h2>
- <span class="best-topics__excerpt">
- {{dReplaceEmoji (trustHTML topic.excerpt)}}
- </span>
+ <div class="rewind-report-page --best-topics">
+ <h2 class="rewind-report-title">
+ {{this.titleText}}
+ </h2>
+ <div class="rewind-report-container">
+ <div class="rewind-card">
+ {{#each @report.data as |topic idx|}}
+ <div
+ class={{dConcatClass "best-topics__topic" (this.rankClass idx)}}
+ >
+ <span class="best-topics --rank"></span>
+ <span class="best-topics --rank"></span>
+ <h2 class="best-topics__header">{{dReplaceEmoji topic.title}}</h2>
+ <span class="best-topics__excerpt">
+ {{dReplaceEmoji (trustHTML topic.excerpt)}}
+ </span>
- <div class="best-topics__metadata">
- <a href={{getURL (concat "/t/-/" topic.topic_id)}}>
- {{i18n "discourse_rewind.reports.best_topics.view_topic"}}
- </a>
- </div>
+ <div class="best-topics__metadata">
+ <a href={{getURL (concat "/t/-/" topic.topic_id)}}>
+ {{i18n "discourse_rewind.reports.best_topics.view_topic"}}
+ </a>
</div>
- {{/each}}
- </div>
+ </div>
+ {{/each}}
</div>
</div>
- {{/if}}
+ </div>
</template>
}
diff --git a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/most-viewed-categories.gjs b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/most-viewed-categories.gjs
index c2234313e1c..3606b62e728 100644
--- a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/most-viewed-categories.gjs
+++ b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/most-viewed-categories.gjs
@@ -43,30 +43,28 @@ export default class MostViewedCategories extends Component {
}
<template>
- {{#if @report.data.length}}
- <div class="rewind-report-page --most-viewed-categories">
- <h2 class="rewind-report-title">
- {{this.titleText}}
- </h2>
- <div class="rewind-report-container">
- {{#each @report.data as |data|}}
- <a
- class={{dConcatClass
- "folder-wrapper"
- (if (eq this.openedCategoryId data.category_id) "--opened" "")
- }}
- href={{getURL (concat "/c/-/" data.category_id)}}
- {{on "click" (fn this.handleFolderClick data.category_id)}}
- >
- <span class="folder-tab"></span>
- <div class="rewind-card">
- <p class="most-viewed-categories__category">#{{data.name}}</p>
- </div>
- <span class="folder-bg"></span>
- </a>
- {{/each}}
- </div>
+ <div class="rewind-report-page --most-viewed-categories">
+ <h2 class="rewind-report-title">
+ {{this.titleText}}
+ </h2>
+ <div class="rewind-report-container">
+ {{#each @report.data as |data|}}
+ <a
+ class={{dConcatClass
+ "folder-wrapper"
+ (if (eq this.openedCategoryId data.category_id) "--opened" "")
+ }}
+ href={{getURL (concat "/c/-/" data.category_id)}}
+ {{on "click" (fn this.handleFolderClick data.category_id)}}
+ >
+ <span class="folder-tab"></span>
+ <div class="rewind-card">
+ <p class="most-viewed-categories__category">#{{data.name}}</p>
+ </div>
+ <span class="folder-bg"></span>
+ </a>
+ {{/each}}
</div>
- {{/if}}
+ </div>
</template>
}
diff --git a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/most-viewed-tags.gjs b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/most-viewed-tags.gjs
index 165588b63d9..0615cf31751 100644
--- a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/most-viewed-tags.gjs
+++ b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/most-viewed-tags.gjs
@@ -38,30 +38,28 @@ export default class MostViewedTags extends Component {
}
<template>
- {{#if @report.data.length}}
- <div class="rewind-report-page --most-viewed-tags">
- <h2 class="rewind-report-title">{{this.titleText}}</h2>
- <div class="rewind-report-container">
- {{#each @report.data as |data|}}
- <a
- class={{dConcatClass
- "folder-wrapper"
- (if (eq this.openedTag data.name) "--opened" "")
- }}
- href={{getURL (concat "/tag/" data.slug "/" data.tag_id)}}
- {{on "click" (fn this.handleFolderClick data.name)}}
- >
- <span class="folder-tab"></span>
- <div class="rewind-card">
- <p class="most-viewed-tags__tag">
- #{{data.name}}
- </p>
- </div>
- <span class="folder-bg"></span>
- </a>
- {{/each}}
- </div>
+ <div class="rewind-report-page --most-viewed-tags">
+ <h2 class="rewind-report-title">{{this.titleText}}</h2>
+ <div class="rewind-report-container">
+ {{#each @report.data as |data|}}
+ <a
+ class={{dConcatClass
+ "folder-wrapper"
+ (if (eq this.openedTag data.name) "--opened" "")
+ }}
+ href={{getURL (concat "/tag/" data.slug "/" data.tag_id)}}
+ {{on "click" (fn this.handleFolderClick data.name)}}
+ >
+ <span class="folder-tab"></span>
+ <div class="rewind-card">
+ <p class="most-viewed-tags__tag">
+ #{{data.name}}
+ </p>
+ </div>
+ <span class="folder-bg"></span>
+ </a>
+ {{/each}}
</div>
- {{/if}}
+ </div>
</template>
}
diff --git a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/reading-time.gjs b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/reading-time.gjs
index bb1390f94db..660a0bea323 100644
--- a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/reading-time.gjs
+++ b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/reading-time.gjs
@@ -32,36 +32,34 @@ export default class ReadingTime extends Component {
}
<template>
- {{#if @report.data}}
- <div class="rewind-report-page --reading-time">
- <h2 class="rewind-report-title">
- {{i18n "discourse_rewind.reports.reading_time.title"}}
- </h2>
- <div class="rewind-card">
- <p class="reading-time__text">
- {{trustHTML this.bookComparisonText}}
- </p>
- <div class="reading-time__book">
- <div class="book">
- <img
- alt=""
- src={{getURL
- (concat
- "/plugins/discourse-rewind/images/books/"
- @report.data.isbn
- ".jpg"
- )
- }}
- />
- </div>
- {{#if @report.data.series}}
- <div class="book-series one"></div>
- <div class="book-series two"></div>
- <div class="book-series three"></div>
- {{/if}}
+ <div class="rewind-report-page --reading-time">
+ <h2 class="rewind-report-title">
+ {{i18n "discourse_rewind.reports.reading_time.title"}}
+ </h2>
+ <div class="rewind-card">
+ <p class="reading-time__text">
+ {{trustHTML this.bookComparisonText}}
+ </p>
+ <div class="reading-time__book">
+ <div class="book">
+ <img
+ alt=""
+ src={{getURL
+ (concat
+ "/plugins/discourse-rewind/images/books/"
+ @report.data.isbn
+ ".jpg"
+ )
+ }}
+ />
</div>
+ {{#if @report.data.series}}
+ <div class="book-series one"></div>
+ <div class="book-series two"></div>
+ <div class="book-series three"></div>
+ {{/if}}
</div>
</div>
- {{/if}}
+ </div>
</template>
}
diff --git a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/time-of-day-activity.gjs b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/time-of-day-activity.gjs
index b8e56223796..461d3dc0e7b 100644
--- a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/time-of-day-activity.gjs
+++ b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/time-of-day-activity.gjs
@@ -6,6 +6,33 @@ import DButton from "discourse/ui-kit/d-button";
import { i18n } from "discourse-i18n";
import { i18nForOwner } from "discourse/plugins/discourse-rewind/discourse/lib/rewind-i18n";
+const PEAK_WINDOW = 0.2;
+const BIT_CRUSH_STEPS = 5;
+const LAST_HOUR = 23;
+const SVG_WIDTH = 1200;
+const SVG_HEIGHT = 200;
+const SVG_PADDING = 40;
+const PLOT = {
+ left: SVG_PADDING,
+ right: SVG_WIDTH - SVG_PADDING,
+ top: SVG_PADDING,
+ bottom: SVG_HEIGHT - SVG_PADDING,
+ labelY: SVG_HEIGHT - SVG_PADDING / 2,
+ width: SVG_WIDTH - SVG_PADDING * 2,
+ height: SVG_HEIGHT - SVG_PADDING * 2,
+};
+
+function triangleWave(frequency, time) {
+ return (2 / Math.PI) * Math.asin(Math.sin(2 * Math.PI * frequency * time));
+}
+
+function activityAt(activityByHour, fractionalHour) {
+ const hour = Math.floor(fractionalHour);
+ const current = activityByHour[hour];
+ const next = activityByHour[Math.min(hour + 1, LAST_HOUR)];
+ return current + (next - current) * (fractionalHour - hour);
+}
+
export default class TimeOfDayActivity extends Component {
@tracked isPlaying = false;
@tracked playbackProgress = 0;
@@ -18,32 +45,16 @@ export default class TimeOfDayActivity extends Component {
animationFrame = null;
hasGlitched = false;
- SVG_WIDTH = 1200;
- SVG_HEIGHT = 200;
- SVG_PADDING = 40;
- BIT_CRUSH_STEPS = 5;
-
get activityByHour() {
- return this.args.report?.data?.activity_by_hour ?? {};
+ return this.args.report.data.activity_by_hour;
}
get mostActiveHour() {
- return this.args.report?.data?.most_active_hour ?? 0;
+ return this.args.report.data.most_active_hour;
}
get maxActivity() {
- const counts = Object.values(this.activityByHour);
- return Math.max(...counts, 1);
- }
-
- get plotDimensions() {
- return {
- width: this.SVG_WIDTH,
- height: this.SVG_HEIGHT,
- padding: this.SVG_PADDING,
- plotWidth: this.SVG_WIDTH - this.SVG_PADDING * 2,
- plotHeight: this.SVG_HEIGHT - this.SVG_PADDING * 2,
- };
+ return Math.max(...this.activityByHour, 1);
}
get personalizedAudioParams() {
@@ -88,9 +99,7 @@ export default class TimeOfDayActivity extends Component {
}
get waveformPath() {
- const points = Array.from({ length: 24 }, (_, hour) =>
- this.calculatePoint(hour)
- );
+ const points = Array.from({ length: 24 }, (_, hour) => this.pointAt(hour));
const tension = 0.3;
let path = `M ${points[0].x} ${points[0].y}`;
@@ -114,7 +123,7 @@ export default class TimeOfDayActivity extends Component {
get waveformPoints() {
return Array.from({ length: 24 }, (_, hour) => {
- const { x, y } = this.calculatePoint(hour);
+ const { x, y } = this.pointAt(hour);
const isActive = hour === this.mostActiveHour;
return {
x,
@@ -129,31 +138,15 @@ export default class TimeOfDayActivity extends Component {
get gridLines() {
return Array.from({ length: 5 }, (_, i) => ({
- y: this.SVG_PADDING + (i * (this.SVG_HEIGHT - 2 * this.SVG_PADDING)) / 4,
+ y: PLOT.top + (i * PLOT.height) / 4,
style: trustHTML(`opacity: ${i === 0 || i === 4 ? 0.3 : 0.15}`),
}));
}
get playbackPosition() {
- if (!this.isPlaying) {
- return null;
- }
-
- const { height, padding, plotWidth, plotHeight } = this.plotDimensions;
-
- const currentHour = this.playbackProgress * 23;
- const hourIndex = Math.floor(currentHour);
- const nextHourIndex = Math.min(hourIndex + 1, 23);
- const t = currentHour - hourIndex;
-
- const currentActivity = this.activityByHour[hourIndex] || 0;
- const nextActivity = this.activityByHour[nextHourIndex] || 0;
- const activity = currentActivity + (nextActivity - currentActivity) * t;
-
- const x = padding + (currentHour / 23) * plotWidth;
- const y = height - padding - (activity / this.maxActivity) * plotHeight;
-
- return { x, y };
+ return this.isPlaying
+ ? this.pointAt(this.playbackProgress * LAST_HOUR)
+ : null;
}
get playButtonText() {
@@ -164,19 +157,17 @@ export default class TimeOfDayActivity extends Component {
);
}
- calculatePoint(hour) {
- const { height, padding, plotWidth, plotHeight } = this.plotDimensions;
- const count = this.activityByHour[hour] || 0;
- const x = padding + (hour / 23) * plotWidth;
- const y = height - padding - (count / this.maxActivity) * plotHeight;
- return { x, y };
+ pointAt(fractionalHour) {
+ const activity = activityAt(this.activityByHour, fractionalHour);
+ return {
+ x: PLOT.left + (fractionalHour / LAST_HOUR) * PLOT.width,
+ y: PLOT.bottom - (activity / this.maxActivity) * PLOT.height,
+ };
}
formatHour(hour) {
- const hourNum = parseInt(hour, 10);
- const period = hourNum >= 12 ? "PM" : "AM";
- const displayHour =
- hourNum === 0 ? 12 : hourNum > 12 ? hourNum - 12 : hourNum;
+ const period = hour >= 12 ? "PM" : "AM";
+ const displayHour = hour === 0 ? 12 : hour > 12 ? hour - 12 : hour;
return `${displayHour}${period}`;
}
@@ -229,25 +220,18 @@ export default class TimeOfDayActivity extends Component {
const channelData = buffer.getChannelData(0);
const params = this.personalizedAudioParams;
+ const scale = params.scale;
+ const activityByHour = this.activityByHour;
+ const maxActivity = this.maxActivity;
+ const peakHourTime = (this.mostActiveHour / LAST_HOUR) * duration;
- const hours = Array.from({ length: 24 }, (_, i) => i);
const samplesPerHour = numSamples / 24;
for (let i = 0; i < numSamples; i++) {
- const hourIndex = Math.floor(i / samplesPerHour);
- const nextHourIndex = Math.min(hourIndex + 1, 23);
- const t = (i % samplesPerHour) / samplesPerHour;
-
- // Get activity for current and next hour
- const currentActivity = this.activityByHour[hours[hourIndex]] || 0;
- const nextActivity = this.activityByHour[hours[nextHourIndex]] || 0;
-
- // Interpolate between hours
- const activity = currentActivity + (nextActivity - currentActivity) * t;
+ const activity = activityAt(activityByHour, i / samplesPerHour);
// Map activity to personalized musical scale
- const scale = params.scale;
- const normalizedActivity = activity / this.maxActivity;
+ const normalizedActivity = activity / maxActivity;
// Map to scale index with smooth interpolation
const scalePosition = normalizedActivity * (scale.length - 1);
@@ -260,28 +244,20 @@ export default class TimeOfDayActivity extends Component {
const time = i / sampleRate;
- // Generate triangle waveform for retro feel
- const generateWave = (freq) => {
- const sine = Math.sin(2 * Math.PI * freq * time);
- return (2 / Math.PI) * Math.asin(sine);
- };
-
// Generate main voice and harmony
- const mainWave = generateWave(frequency);
- const harmonyWave = generateWave(frequency * params.harmonyRatio);
+ const mainWave = triangleWave(frequency, time);
+ const harmonyWave = triangleWave(frequency * params.harmonyRatio, time);
// Mix voices (70/30 split)
const mixedWave = mainWave * 0.7 + harmonyWave * 0.3;
// Add bit crushing effect for retro feel
const crushed =
- Math.round(mixedWave * this.BIT_CRUSH_STEPS) / this.BIT_CRUSH_STEPS;
+ Math.round(mixedWave * BIT_CRUSH_STEPS) / BIT_CRUSH_STEPS;
// Add minimal noise (sparkle at peak hour)
- const peakHourTime = (this.mostActiveHour / 23) * duration;
- const peakWindow = 0.2;
const isPeakMoment =
- Math.abs(time - peakHourTime) < peakWindow && time >= peakHourTime;
+ Math.abs(time - peakHourTime) < PEAK_WINDOW && time >= peakHourTime;
const noise = (Math.random() - 0.5) * (isPeakMoment ? 0.08 : 0.02);
@@ -337,7 +313,7 @@ export default class TimeOfDayActivity extends Component {
}
// Trigger visual glitch when hitting peak hour
- const peakHourProgress = this.mostActiveHour / 23;
+ const peakHourProgress = this.mostActiveHour / LAST_HOUR;
if (
!this.hasGlitched &&
this.playbackProgress >= peakHourProgress &&
@@ -389,7 +365,10 @@ export default class TimeOfDayActivity extends Component {
@action={{this.playWaveform}}
@icon={{if this.isPlaying "volume-xmark" "volume-high"}}
/>
- <svg class="oscilloscope__svg" viewBox="0 0 1200 200">
+ <svg
+ class="oscilloscope__svg"
+ viewBox="0 0 {{SVG_WIDTH}} {{SVG_HEIGHT}}"
+ >
<defs>
<filter id="glow">
<feGaussianBlur result="coloredBlur" stdDeviation="2" />
@@ -412,8 +391,8 @@ export default class TimeOfDayActivity extends Component {
<line
class="oscilloscope__grid-line"
style={{gridLine.style}}
- x1="40"
- x2="1160"
+ x1={{PLOT.left}}
+ x2={{PLOT.right}}
y1={{gridLine.y}}
y2={{gridLine.y}}
/>
@@ -425,13 +404,13 @@ export default class TimeOfDayActivity extends Component {
class="oscilloscope__grid-line --vertical"
x1={{point.x}}
x2={{point.x}}
- y1="40"
- y2="160"
+ y1={{PLOT.top}}
+ y2={{PLOT.bottom}}
/>
<text
class="oscilloscope__time-label"
x={{point.x}}
- y="180"
+ y={{PLOT.labelY}}
>{{this.formatHour point.hour}}</text>
{{/if}}
{{/each}}
diff --git a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/top-words.gjs b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/top-words.gjs
index 4c5ab7178e4..c2ce9d90e43 100644
--- a/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/top-words.gjs
+++ b/plugins/discourse-rewind/assets/javascripts/discourse/components/reports/top-words.gjs
@@ -1,28 +1,21 @@
-import Component from "@glimmer/component";
import { i18n } from "discourse-i18n";
import WordCard from "discourse/plugins/discourse-rewind/discourse/components/reports/top-words/word-card";
-export default class WordCards extends Component {
- get topWords() {
- return this.args.report.data.sort((a, b) => b.score - a.score).slice(0, 5);
- }
-
- <template>
- <div class="rewind-report-page --top-words">
- <div class="rewind-report-container">
- <h2 class="rewind-report-title">{{i18n
- "discourse_rewind.reports.top_words.title"
- }}</h2>
- <div class="cards-container">
- {{#each this.topWords as |entry index|}}
- <WordCard
- @count={{entry.score}}
- @index={{index}}
- @word={{entry.word}}
- />
- {{/each}}
- </div>
+export default <template>
+ <div class="rewind-report-page --top-words">
+ <div class="rewind-report-container">
+ <h2 class="rewind-report-title">{{i18n
+ "discourse_rewind.reports.top_words.title"
+ }}</h2>
+ <div class="cards-container">
+ {{#each @report.data as |entry index|}}
+ <WordCard
+ @count={{entry.score}}
+ @index={{index}}
+ @word={{entry.word}}
+ />
+ {{/each}}
</div>
</div>
- </template>
-}
+ </div>
+</template>
diff --git a/plugins/discourse-rewind/assets/javascripts/discourse/services/rewind.js b/plugins/discourse-rewind/assets/javascripts/discourse/services/rewind.js
index ac145a1140b..9a7ba66f5f0 100644
--- a/plugins/discourse-rewind/assets/javascripts/discourse/services/rewind.js
+++ b/plugins/discourse-rewind/assets/javascripts/discourse/services/rewind.js
@@ -32,27 +32,8 @@ export default class Rewind extends Service {
* reality, only December).
*/
get fetchRewindYear() {
- const currentDate = new Date();
- const currentMonth = currentDate.getMonth();
- const currentYear = currentDate.getFullYear();
-
- if (currentMonth === 0) {
- return currentYear - 1;
- } else {
- return currentYear;
- }
- }
-
- get fetchRewindNextYear() {
- const currentDate = new Date();
- const currentMonth = currentDate.getMonth();
- const currentYear = currentDate.getFullYear();
-
- if (currentMonth === 0) {
- return currentYear;
- } else {
- return currentYear + 1;
- }
+ const now = new Date();
+ return now.getMonth() === 0 ? now.getFullYear() - 1 : now.getFullYear();
}
dismiss() {
diff --git a/plugins/discourse-rewind/assets/stylesheets/common/best-posts.scss b/plugins/discourse-rewind/assets/stylesheets/common/best-posts.scss
index 9577326b025..07c240ce3e3 100644
--- a/plugins/discourse-rewind/assets/stylesheets/common/best-posts.scss
+++ b/plugins/discourse-rewind/assets/stylesheets/common/best-posts.scss
@@ -103,10 +103,6 @@
line-height: 22px;
}
- .best-post__post h5 {
- font-family: var(--jersey-heading);
- }
-
.best-posts__post table {
font-family: var(--pixel-text) !important;
font-weight: normal;
diff --git a/plugins/discourse-rewind/assets/stylesheets/common/best-topics.scss b/plugins/discourse-rewind/assets/stylesheets/common/best-topics.scss
index c7c3a323800..b63a8aca479 100644
--- a/plugins/discourse-rewind/assets/stylesheets/common/best-topics.scss
+++ b/plugins/discourse-rewind/assets/stylesheets/common/best-topics.scss
@@ -7,10 +7,6 @@
gap: 1em;
}
- .best-topics__title {
- color: var(--primary);
- }
-
.rewind-report-title {
margin-left: 0;
width: 100%;
diff --git a/plugins/discourse-rewind/assets/stylesheets/common/rewind-header.scss b/plugins/discourse-rewind/assets/stylesheets/common/rewind-header.scss
index 0a73af7a3ef..c32e4e0a674 100644
--- a/plugins/discourse-rewind/assets/stylesheets/common/rewind-header.scss
+++ b/plugins/discourse-rewind/assets/stylesheets/common/rewind-header.scss
@@ -1,35 +1,3 @@
-.rewind-logo {
- height: 40px;
-
- &.--light {
- display: none;
- }
-
- &.--dark {
- display: block;
- }
-
- @media (prefers-color-scheme: dark) {
- &.--light {
- display: block;
- }
-
- &.--dark {
- display: none;
- }
- }
-
- @if is-dark-color-scheme() {
- &.--dark {
- display: none;
- }
-
- &.--light {
- display: block;
- }
- }
-}
-
.rewind__header {
padding: 1em 0 1em 1em;
background-color: #fbf8e4;
@@ -42,10 +10,6 @@
color: var(--rewind-black);
display: flex;
- .rewind-logo {
- margin-bottom: 5px;
- }
-
p {
margin: 0 0.5em 0 0;
text-transform: uppercase;
diff --git a/plugins/discourse-rewind/assets/stylesheets/common/rewind.scss b/plugins/discourse-rewind/assets/stylesheets/common/rewind.scss
index adf9a38c0ba..bb75e3764a3 100644
--- a/plugins/discourse-rewind/assets/stylesheets/common/rewind.scss
+++ b/plugins/discourse-rewind/assets/stylesheets/common/rewind.scss
@@ -225,10 +225,6 @@
transform: skew(3deg);
font-size: var(--font-down-1);
- &.rewind__share-btn {
- right: 78px;
- }
-
&.rewind__exit-fullscreen-btn {
right: 24px;
}
@@ -251,20 +247,6 @@
}
}
-.rewind__prev-btn {
- position: absolute;
- bottom: 5px;
- left: 5px;
- z-index: 1;
-}
-
-.rewind__next-btn {
- position: absolute;
- bottom: 5px;
- right: 5px;
- z-index: 1;
-}
-
.rewind-loader {
display: flex;
flex-direction: column;
diff --git a/plugins/discourse-rewind/assets/stylesheets/common/writing-analysis.scss b/plugins/discourse-rewind/assets/stylesheets/common/writing-analysis.scss
index e00df7c3b46..7f3ca828e7d 100644
--- a/plugins/discourse-rewind/assets/stylesheets/common/writing-analysis.scss
+++ b/plugins/discourse-rewind/assets/stylesheets/common/writing-analysis.scss
@@ -13,15 +13,6 @@
margin-bottom: 0;
}
- .writing-analysis__titlebar {
- background: var(--rewind-green);
- color: #000;
- padding: 6px 10px;
- font-weight: bold;
- display: flex;
- justify-content: space-between;
- }
-
.writing-analysis__menubar {
background: var(--rewind-green);
color: #000;
diff --git a/plugins/discourse-rewind/config/locales/client.en.yml b/plugins/discourse-rewind/config/locales/client.en.yml
index 5af5199f90a..8caae1c198b 100644
--- a/plugins/discourse-rewind/config/locales/client.en.yml
+++ b/plugins/discourse-rewind/config/locales/client.en.yml
@@ -6,7 +6,6 @@ en:
discourse_rewind: "Discourse Rewind"
js:
discourse_rewind:
- placeholder: Discourse Rewind
title: Rewind
loading: "Reticulating splines..."
viewing_other_user: "You are viewing <strong>%{username}'s</strong> Discourse Rewind report."
@@ -88,18 +87,14 @@ en:
one: "%{username}'s best post"
other: "%{username}'s %{count} best posts"
ai_usage:
- title: AI Usage
total_requests: Total Requests
total_tokens: Total Tokens
success_rate: Success Rate
- favorite_features: Most Used Features
- favorite_models: Most Used AI Models
wake_up: "Wake up, %{username}..."
system_title: "AI USAGE DETECTED"
section_features: "TOP FEATURES"
section_models: "TOP MODELS"
assignments:
- title: Assignments
total_assigned: Assigned to me
total_assigned_others: "Assigned to %{username}"
completed: Assignments completed
@@ -108,13 +103,6 @@ en:
completion_rate: Completion rate
chat_usage:
title: Chat Activity
- total_messages: Total Messages
- dm_messages: Direct Messages
- unique_dm_channels: Direct Message Conversations
- reactions_received: Reactions Received
- avg_message_length: Avg Message Length
- favorite_channels: Favorite Channels
- messages: messages
bot_name: XxRewindBotxX
author: You
author_others: "%{username}"
@@ -142,17 +130,6 @@ en:
message_5: "Your favorite channels:"
dancing_baby_alt: "Dancing baby"
invites:
- title: Invites
- total_invites: Total Invites Sent
- redeemed: Accepted Invites
- redemption_rate: Acceptance Rate
- avg_trust_level: Avg Trust Level
- invitee_impact: Impact of Your Invitees
- invitee_impact_others: "Impact of %{username}'s Invitees"
- invitee_posts: Posts Created
- invitee_topics: Topics Started
- invitee_likes: Likes Given
- most_active_invitee: Most Active Invitee
guest_book_title: Guest Book
guest_book_subtitle: Your Community Invitations
guest_book_subtitle_others: "%{username}'s Community Invitations"
@@ -165,22 +142,9 @@ en:
label_likes_given: "Likes given:"
section_most_active: Most Active Guest
new_user_interactions:
- title: Mentoring New Users
- subtitle:
- one: You helped %{count} new user this year
- other: You helped %{count} new users this year
- subtitle_others:
- one: "%{username} helped %{count} new user this year"
- other: "%{username} helped %{count} new users this year"
new_member:
one: "%{count} new member"
other: "%{count} new members"
- total_interactions: Total Interactions
- unique_new_users: Unique New Users
- likes_given: Likes Given
- replies: Replies to Posts
- mentions: Mentions
- topics_with_new_users: Topics with New Users
contributions_helped: your contributions helped
contributions_helped_others: "%{username}'s contributions helped"
time_of_day_activity:
diff --git a/plugins/discourse-rewind/lib/discourse_rewind/engine.rb b/plugins/discourse-rewind/lib/discourse_rewind/engine.rb
index 548db2e6489..f246456a7d6 100644
--- a/plugins/discourse-rewind/lib/discourse_rewind/engine.rb
+++ b/plugins/discourse-rewind/lib/discourse_rewind/engine.rb
@@ -5,15 +5,5 @@ module ::DiscourseRewind
engine_name PLUGIN_NAME
isolate_namespace DiscourseRewind
config.autoload_paths << File.join(config.root, "lib")
- scheduled_job_dir = "#{config.root}/app/jobs/scheduled"
- config.to_prepare do
- Rails.autoloaders.main.eager_load_dir(scheduled_job_dir) if Dir.exist?(scheduled_job_dir)
- end
-
- Rails.application.reloader.to_prepare do
- Dir[
- "#{Rails.root.join("plugins/discourse-rewind/app/services/discourse_rewind/rewind/action/*.rb")}"
- ].each { |file| require_dependency file }
- end
end
end
diff --git a/plugins/discourse-rewind/plugin.rb b/plugins/discourse-rewind/plugin.rb
index b3455f46640..68f7d525b47 100644
--- a/plugins/discourse-rewind/plugin.rb
+++ b/plugins/discourse-rewind/plugin.rb
@@ -20,10 +20,6 @@ register_asset "stylesheets/mobile/_index.scss", :mobile
module ::DiscourseRewind
PLUGIN_NAME = "discourse-rewind"
- def self.public_asset_path(name)
- File.expand_path(File.join(__dir__, "public", name))
- end
-
def self.rewind_year(date = nil)
date ||= Time.zone.now
date.month == 1 ? date.year - 1 : date.year
@@ -46,7 +42,6 @@ after_initialize do
user_option.discourse_rewind_share_publicly && !user_option.hide_profile
end
- # add_to_serializer(:current_user) / add_to_serializer(:current_user_option)
%i[user_option current_user_option].each do |serializer|
add_to_serializer(serializer, :discourse_rewind_enabled) { object.discourse_rewind_enabled }