parent
d3aa5ddf4b
commit
4a8cd0b585
|
@ -12,7 +12,8 @@ class Api::V1::GroupsController < Api::BaseController
|
||||||
def index
|
def index
|
||||||
case current_tab
|
case current_tab
|
||||||
when 'featured'
|
when 'featured'
|
||||||
@groups = Group.where(is_featured: true, is_archived: false).limit(100).all
|
@groupIds = FetchGroupsService.new.call("featured")
|
||||||
|
@groups = Group.where(id: @groupIds).limit(150).all
|
||||||
when 'new'
|
when 'new'
|
||||||
if !current_user
|
if !current_user
|
||||||
render json: { error: 'This method requires an authenticated user' }, status: 422
|
render json: { error: 'This method requires an authenticated user' }, status: 422
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Api::V1::Timelines::GroupCollectionController < Api::BaseController
|
||||||
|
|
||||||
@groupIds = []
|
@groupIds = []
|
||||||
if @collection_type == 'featured'
|
if @collection_type == 'featured'
|
||||||
@groupIds = Group.where(is_featured: true, is_archived: false).limit(100).all.pluck(:id)
|
@groupIds = FetchGroupsService.new.call("featured")
|
||||||
elsif @collection_type == 'member' && !current_user.nil?
|
elsif @collection_type == 'member' && !current_user.nil?
|
||||||
@groupIds = current_user.account.groups.pluck(:id)
|
@groupIds = current_user.account.groups.pluck(:id)
|
||||||
else
|
else
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
} from '../actions/groups'
|
} from '../actions/groups'
|
||||||
import {
|
import {
|
||||||
GROUP_TIMELINE_SORTING_TYPE_TOP,
|
GROUP_TIMELINE_SORTING_TYPE_TOP,
|
||||||
GROUP_TIMELINE_SORTING_TYPE_TOP_OPTION_WEEKLY,
|
GROUP_TIMELINE_SORTING_TYPE_TOP_OPTION_TODAY,
|
||||||
GROUP_TIMELINE_SORTING_TYPE_NEWEST,
|
GROUP_TIMELINE_SORTING_TYPE_NEWEST,
|
||||||
} from '../constants'
|
} from '../constants'
|
||||||
import getSortBy from '../utils/group_sort_by'
|
import getSortBy from '../utils/group_sort_by'
|
||||||
|
@ -54,7 +54,7 @@ const mapDispatchToProps = (dispatch) => ({
|
||||||
},
|
},
|
||||||
setFeaturedTop() {
|
setFeaturedTop() {
|
||||||
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_TOP))
|
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_TOP))
|
||||||
dispatch(setGroupTimelineTopSort(GROUP_TIMELINE_SORTING_TYPE_TOP_OPTION_WEEKLY))
|
dispatch(setGroupTimelineTopSort(GROUP_TIMELINE_SORTING_TYPE_TOP_OPTION_TODAY))
|
||||||
},
|
},
|
||||||
setMemberNewest() {
|
setMemberNewest() {
|
||||||
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_NEWEST))
|
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_NEWEST))
|
||||||
|
|
|
@ -52,7 +52,7 @@ class GroupsPage extends PureComponent {
|
||||||
|
|
||||||
const tabs = !!me ? [
|
const tabs = !!me ? [
|
||||||
{
|
{
|
||||||
title: intl.formatMessage(dontShowChildren ? messages.myGroupsTimeline : messages.groups),
|
title: intl.formatMessage(messages.myGroupsTimeline),
|
||||||
to: '/groups',
|
to: '/groups',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1,8 @@
|
||||||
|
class AddIndexToStatusCreatedAt < ActiveRecord::Migration[5.2]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def change
|
||||||
|
add_index :statuses, :created_at, algorithm: :concurrently
|
||||||
|
add_index :statuses, :updated_at, algorithm: :concurrently
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
class AddIndexToUserCurrentSignInAt < ActiveRecord::Migration[5.2]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def change
|
||||||
|
add_index :users, :current_sign_in_at, algorithm: :concurrently
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2020_08_06_231714) do
|
ActiveRecord::Schema.define(version: 2020_08_08_170708) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_stat_statements"
|
enable_extension "pg_stat_statements"
|
||||||
|
@ -775,12 +775,14 @@ ActiveRecord::Schema.define(version: 2020_08_06_231714) do
|
||||||
t.datetime "expires_at"
|
t.datetime "expires_at"
|
||||||
t.boolean "has_quote"
|
t.boolean "has_quote"
|
||||||
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
|
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
|
||||||
|
t.index ["created_at"], name: "index_statuses_on_created_at"
|
||||||
t.index ["group_id"], name: "index_statuses_on_group_id"
|
t.index ["group_id"], name: "index_statuses_on_group_id"
|
||||||
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
|
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
|
||||||
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
|
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
|
||||||
t.index ["quote_of_id"], name: "index_statuses_on_quote_of_id"
|
t.index ["quote_of_id"], name: "index_statuses_on_quote_of_id"
|
||||||
t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
|
t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
|
||||||
t.index ["reply"], name: "index_statuses_on_reply"
|
t.index ["reply"], name: "index_statuses_on_reply"
|
||||||
|
t.index ["updated_at"], name: "index_statuses_on_updated_at"
|
||||||
t.index ["uri"], name: "index_statuses_on_uri", unique: true
|
t.index ["uri"], name: "index_statuses_on_uri", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -893,6 +895,7 @@ ActiveRecord::Schema.define(version: 2020_08_06_231714) do
|
||||||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||||
t.index ["created_at"], name: "index_users_on_created_at"
|
t.index ["created_at"], name: "index_users_on_created_at"
|
||||||
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
|
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
|
||||||
|
t.index ["current_sign_in_at"], name: "index_users_on_current_sign_in_at"
|
||||||
t.index ["email"], name: "index_users_on_email", unique: true
|
t.index ["email"], name: "index_users_on_email", unique: true
|
||||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||||
t.index ["unique_email"], name: "index_users_on_unique_email"
|
t.index ["unique_email"], name: "index_users_on_unique_email"
|
||||||
|
|
Loading…
Reference in New Issue