Updates to groups sorting

• Updates to groups sorting
This commit is contained in:
mgabdev
2020-08-08 13:08:48 -05:00
parent d3aa5ddf4b
commit 4a8cd0b585
8 changed files with 47 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
# frozen_string_literal: true
class FetchGroupsService < BaseService
def call(type)
if type == "featured"
body = Redis.current.get("groups:featuredgroups")
if body.nil? || !body || body.empty?
@groupIds = Group.where(is_featured: true, is_archived: false).limit(150).all.pluck(:id)
Redis.current.set("groups:featuredgroups", @groupIds.join(","))
Redis.current.expire("groups:featuredgroups", 6.hours.seconds)
@groupIds
else
body.split(",")
end
end
end
end