This commit is contained in:
Jordan Vidrine 2025-01-13 17:30:57 -06:00
commit 0d25800241
4 changed files with 20 additions and 16 deletions

View File

@ -57,7 +57,6 @@ module DiscourseRewind
.where(posts: { user_id: user.id }) .where(posts: { user_id: user.id })
.where(created_at: date) .where(created_at: date)
.group(:reaction_value) .group(:reaction_value)
.limit(5)
.count, .count,
) )
end end
@ -85,7 +84,7 @@ module DiscourseRewind
end end
def sort_and_limit(reactions) def sort_and_limit(reactions)
reactions.sort_by { |_, v| v }.first(5).to_h reactions.sort_by { |_, v| -v }.first(5).reverse.to_h
end end
end end
end end

View File

@ -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.username}:#{year}"
reports = Discourse.redis.get(key) # reports = Discourse.redis.get(key)
if Rails.env.development? || !reports # if Rails.env.development? || !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, MultiJson.dump(reports))
else # else
reports = MultiJson.load(reports.compact, symbolize_keys: true) # reports = MultiJson.load(reports.compact, symbolize_keys: true)
end # end
reports reports
end end

View File

@ -53,7 +53,9 @@
left: -4px; left: -4px;
top: -4px; top: -4px;
content: ""; content: "";
background-image: url(/plugins/discourse-rewind/images/rewind-avatar-2-shimmer.gif); background-image: absolute-image-url(
"/plugins/discourse-rewind/images/rewind-avatar-2-shimmer.gif"
);
display: block; display: block;
background-size: cover; background-size: cover;
} }

View File

@ -49,7 +49,9 @@
} }
.background-1 { .background-1 {
background: url(/plugins/discourse-rewind/images/blur-bg.png); background: absolute-image-url(
"/plugins/discourse-rewind/images/blur-bg.png"
);
@if is-dark-color-scheme() { @if is-dark-color-scheme() {
opacity: 0.15; opacity: 0.15;
} }
@ -68,6 +70,7 @@
position: relative; position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-bottom: var(--safe-area-inset-bottom);
} }
.rewind__exit-fullscreen-btn { .rewind__exit-fullscreen-btn {