Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b1af6f717 | ||
|
|
19af3cb107 | ||
|
|
7cc39605f5 | ||
|
|
fed8205a64 | ||
|
|
d669a39a00 | ||
|
|
6a55f56b91 | ||
|
|
2bb1072d29 | ||
|
|
ff72e3ed37 |
@@ -7,7 +7,7 @@ module DiscourseRewind
|
|||||||
FakeData = {
|
FakeData = {
|
||||||
data:
|
data:
|
||||||
(Date.new(2024, 1, 1)..Date.new(2024, 12, 31)).map do |date|
|
(Date.new(2024, 1, 1)..Date.new(2024, 12, 31)).map do |date|
|
||||||
{ date:, post_count: rand(0..20), visited: false }
|
{ date: date.strftime("%Y-%m-%d"), post_count: rand(0..20), visited: false }
|
||||||
end,
|
end,
|
||||||
identifier: "activity-calendar",
|
identifier: "activity-calendar",
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,13 @@ module DiscourseRewind
|
|||||||
)
|
)
|
||||||
.group("generate_series, user_visits.id")
|
.group("generate_series, user_visits.id")
|
||||||
.order("generate_series")
|
.order("generate_series")
|
||||||
.map { |row| { date: row.date, post_count: row.post_count, visited: row.visited } }
|
.map do |row|
|
||||||
|
{
|
||||||
|
date: row.date.strftime("%Y-%m-%d"),
|
||||||
|
post_count: row.post_count,
|
||||||
|
visited: row.visited,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
{ data: calendar, identifier: "activity-calendar" }
|
{ data: calendar, identifier: "activity-calendar" }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,19 @@
|
|||||||
# Topics visited grouped by category
|
# Topics visited grouped by category
|
||||||
module DiscourseRewind
|
module DiscourseRewind
|
||||||
class Rewind::Action::FavoriteCategories < Rewind::Action::BaseReport
|
class Rewind::Action::FavoriteCategories < Rewind::Action::BaseReport
|
||||||
|
FakeData = {
|
||||||
|
data: [
|
||||||
|
{ category_id: 1, name: "cats" },
|
||||||
|
{ category_id: 2, name: "dogs" },
|
||||||
|
{ category_id: 3, name: "countries" },
|
||||||
|
{ category_id: 4, name: "management" },
|
||||||
|
{ category_id: 5, name: "things" },
|
||||||
|
],
|
||||||
|
identifier: "favorite-categories",
|
||||||
|
}
|
||||||
def call
|
def call
|
||||||
|
return FakeData if Rails.env.development?
|
||||||
|
|
||||||
favorite_categories =
|
favorite_categories =
|
||||||
TopicViewItem
|
TopicViewItem
|
||||||
.joins(:topic)
|
.joins(:topic)
|
||||||
|
|||||||
@@ -6,32 +6,32 @@ module DiscourseRewind
|
|||||||
FakeData = {
|
FakeData = {
|
||||||
data: {
|
data: {
|
||||||
post_received_reactions: {
|
post_received_reactions: {
|
||||||
"open_mouth" => 2,
|
open_mouth: 2,
|
||||||
"cat" => 32,
|
cat: 32,
|
||||||
"dog" => 34,
|
dog: 34,
|
||||||
"heart" => 45,
|
heart: 45,
|
||||||
"grinning" => 82,
|
grinning: 82,
|
||||||
},
|
},
|
||||||
post_used_reactions: {
|
post_used_reactions: {
|
||||||
"open_mouth" => 2,
|
open_mouth: 2,
|
||||||
"cat" => 32,
|
cat: 32,
|
||||||
"dog" => 34,
|
dog: 34,
|
||||||
"heart" => 45,
|
heart: 45,
|
||||||
"grinning" => 82,
|
grinning: 82,
|
||||||
},
|
},
|
||||||
chat_used_reactions: {
|
chat_used_reactions: {
|
||||||
"open_mouth" => 2,
|
open_mouth: 2,
|
||||||
"cat" => 32,
|
cat: 32,
|
||||||
"dog" => 34,
|
dog: 34,
|
||||||
"heart" => 45,
|
heart: 45,
|
||||||
"grinning" => 82,
|
grinning: 82,
|
||||||
},
|
},
|
||||||
chat_received_reactions: {
|
chat_received_reactions: {
|
||||||
"open_mouth" => 2,
|
open_mouth: 2,
|
||||||
"cat" => 32,
|
cat: 32,
|
||||||
"dog" => 34,
|
dog: 34,
|
||||||
"heart" => 45,
|
heart: 45,
|
||||||
"grinning" => 82,
|
grinning: 82,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
identifier: "reactions",
|
identifier: "reactions",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ module DiscourseRewind
|
|||||||
{ word: "what", score: 100 },
|
{ word: "what", score: 100 },
|
||||||
{ word: "have", score: 90 },
|
{ word: "have", score: 90 },
|
||||||
{ word: "you", score: 80 },
|
{ word: "you", score: 80 },
|
||||||
{ word: "achieved", score: 70 },
|
{ word: "overachieved", score: 70 },
|
||||||
{ word: "this", score: 60 },
|
{ word: "this", score: 60 },
|
||||||
{ word: "week", score: 50 },
|
{ word: "week", score: 50 },
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -51,19 +51,19 @@ module DiscourseRewind
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch_reports(date:, user:, guardian:, year:)
|
def fetch_reports(date:, user:, guardian:, year:)
|
||||||
# key = "rewind:#{guardian.user.username}:#{year}"
|
key = "rewind:#{guardian.user.id}:#{year}"
|
||||||
# reports = Discourse.redis.get(key)
|
cached_reports = Discourse.redis.get(key)
|
||||||
|
|
||||||
# if Rails.env.development? || !reports
|
if !cached_reports
|
||||||
reports =
|
reports =
|
||||||
::DiscourseRewind::Rewind::Action::BaseReport
|
::DiscourseRewind::Rewind::Action::BaseReport
|
||||||
.descendants
|
.descendants
|
||||||
.filter { _1.enabled? }
|
.filter { _1.enabled? }
|
||||||
.map { |report| report.call(date:, user:, guardian:) }
|
.map { |report| report.call(date:, user:, guardian:) }
|
||||||
# Discourse.redis.setex(key, CACHE_DURATION, MultiJson.dump(reports))
|
Discourse.redis.setex(key, CACHE_DURATION, reports.to_json)
|
||||||
# else
|
else
|
||||||
# reports = MultiJson.load(reports.compact, symbolize_keys: true)
|
reports = JSON.parse(cached_reports, symbolize_names: true)
|
||||||
# end
|
end
|
||||||
|
|
||||||
reports
|
reports
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ const FavoriteCategories = <template>
|
|||||||
}}</h2>
|
}}</h2>
|
||||||
<div class="rewind-report-container">
|
<div class="rewind-report-container">
|
||||||
{{#each @report.data as |data|}}
|
{{#each @report.data as |data|}}
|
||||||
<div class="rewind-card">
|
<a href={{concat "/c/-/" data.category_id}} class="rewind-card">
|
||||||
<a
|
<p
|
||||||
class="favorite-categories__category"
|
class="favorite-categories__category"
|
||||||
href={{concat "/c/-/" data.category_id}}
|
href={{concat "/c/-/" data.category_id}}
|
||||||
>{{data.name}}</a>
|
>{{data.name}}</p>
|
||||||
</div>
|
</a>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { on } from "@ember/modifier";
|
|||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
||||||
import { htmlSafe } from "@ember/template";
|
import { htmlSafe } from "@ember/template";
|
||||||
|
import concatClass from "discourse/helpers/concat-class";
|
||||||
import emoji from "discourse/helpers/emoji";
|
import emoji from "discourse/helpers/emoji";
|
||||||
import discourseLater from "discourse-common/lib/later";
|
import discourseLater from "discourse-common/lib/later";
|
||||||
|
|
||||||
@@ -45,6 +46,10 @@ export default class WordCard extends Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get longWord() {
|
||||||
|
return this.args.word.length >= 7;
|
||||||
|
}
|
||||||
|
|
||||||
get cardStyle() {
|
get cardStyle() {
|
||||||
return htmlSafe(`${this.randomStyle}; ${this.mysteryData.color};`);
|
return htmlSafe(`${this.randomStyle}; ${this.mysteryData.color};`);
|
||||||
}
|
}
|
||||||
@@ -72,7 +77,10 @@ export default class WordCard extends Component {
|
|||||||
<div
|
<div
|
||||||
{{on "click" this.handleClick}}
|
{{on "click" this.handleClick}}
|
||||||
{{on "mouseleave" this.handleLeave}}
|
{{on "mouseleave" this.handleLeave}}
|
||||||
class="rewind-card__wrapper"
|
class={{concatClass
|
||||||
|
"rewind-card__wrapper"
|
||||||
|
(if this.longWord "-long-word")
|
||||||
|
}}
|
||||||
style={{this.cardStyle}}
|
style={{this.cardStyle}}
|
||||||
{{didInsert this.registerCardContainer}}
|
{{didInsert this.registerCardContainer}}
|
||||||
role="button"
|
role="button"
|
||||||
|
|||||||
@@ -137,6 +137,16 @@
|
|||||||
0 0 / 6px 6px,
|
0 0 / 6px 6px,
|
||||||
var(--secondary-low);
|
var(--secondary-low);
|
||||||
}
|
}
|
||||||
|
&.-long-word .rewind-card__title {
|
||||||
|
font-size: var(--font-0);
|
||||||
|
}
|
||||||
|
&.-long-word .rewind-card {
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
.rewind-card__title {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
hyphens: auto;
|
||||||
|
}
|
||||||
.rewind-card__image {
|
.rewind-card__image {
|
||||||
image-rendering: pixelated;
|
image-rendering: pixelated;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user