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(created_at: date)
.group(:reaction_value)
.limit(5)
.count,
)
end
@ -85,7 +84,7 @@ module DiscourseRewind
end
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

View File

@ -51,19 +51,19 @@ module DiscourseRewind
end
def fetch_reports(date:, user:, guardian:, year:)
key = "rewind:#{guardian.user.username}:#{year}"
reports = Discourse.redis.get(key)
# key = "rewind:#{guardian.user.username}:#{year}"
# reports = Discourse.redis.get(key)
if Rails.env.development? || !reports
reports =
::DiscourseRewind::Rewind::Action::BaseReport
.descendants
.filter { _1.enabled? }
.map { |report| report.call(date:, user:, guardian:) }
Discourse.redis.setex(key, CACHE_DURATION, MultiJson.dump(reports))
else
reports = MultiJson.load(reports.compact, symbolize_keys: true)
end
# if Rails.env.development? || !reports
reports =
::DiscourseRewind::Rewind::Action::BaseReport
.descendants
.filter { _1.enabled? }
.map { |report| report.call(date:, user:, guardian:) }
# Discourse.redis.setex(key, CACHE_DURATION, MultiJson.dump(reports))
# else
# reports = MultiJson.load(reports.compact, symbolize_keys: true)
# end
reports
end

View File

@ -53,7 +53,9 @@
left: -4px;
top: -4px;
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;
background-size: cover;
}

View File

@ -49,7 +49,9 @@
}
.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() {
opacity: 0.15;
}
@ -68,6 +70,7 @@
position: relative;
display: flex;
flex-direction: column;
padding-bottom: var(--safe-area-inset-bottom);
}
.rewind__exit-fullscreen-btn {