From f4512b441185368ea11c6b8546ee9e78ade6e7c5 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Fri, 8 Jan 2021 21:46:03 -0500 Subject: [PATCH] Added/removed some functionality to better handle requests/load - Removed status counting in dashboard for admins - Added limit to notifications to only 7 days ago - Removed ability for non-logged in users to view group, group-collection timelines - Limited account realtime search on compose, list, chat actions - Removed fetching of user suggestions - Removed fetching of shortcuts - Removed featured groups, user suggestions timeline injections - Removed group featured panel from explore layout for non logged in users - Removed media gallery panel from profile layout - Removed lists, suggestions, groups panel from home page - Removed user suggestions to list page - Updated pro_timelie in status.rb to find only from 1 hour ago - Updated home timeline to not include groups and to find only latest from 5 days ago - Removed search for non logged in users --- app/controllers/admin/dashboard_controller.rb | 2 +- app/controllers/api/v1/notifications_controller.rb | 2 +- app/controllers/api/v1/search_controller.rb | 4 +++- .../api/v1/timelines/group_collection_controller.rb | 2 +- app/controllers/api/v1/timelines/group_controller.rb | 3 ++- app/controllers/api/v1/timelines/list_controller.rb | 2 +- app/javascript/gabsocial/actions/chats.js | 3 ++- app/javascript/gabsocial/actions/compose.js | 2 ++ app/javascript/gabsocial/actions/lists.js | 2 ++ .../gabsocial/components/panel/user_suggestions_panel.js | 5 +++-- .../gabsocial/components/sidebar/default_sidebar.js | 2 +- .../timeline_injections/timeline_injection_root.js | 2 ++ app/javascript/gabsocial/features/shortcuts.js | 4 +++- app/javascript/gabsocial/layouts/explore_layout.js | 4 ++-- app/javascript/gabsocial/layouts/profile_layout.js | 2 +- app/javascript/gabsocial/pages/home_page.js | 6 +++--- app/javascript/gabsocial/pages/list_page.js | 2 +- app/models/notification.rb | 1 + app/models/status.rb | 9 ++------- app/services/search_service.rb | 2 +- 20 files changed, 35 insertions(+), 26 deletions(-) diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 44b3ce02..02358900 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -5,7 +5,7 @@ module Admin class DashboardController < BaseController def index @users_count = User.count - @statuses_count = Status.count + @statuses_count = "." #Status.count @pro_accounts_count = Account.where(is_pro: true).count @donor_accounts_count = Account.where(is_donor: true).count @registrations_week = Redis.current.get("activity:accounts:local:#{current_week}") || 0 diff --git a/app/controllers/api/v1/notifications_controller.rb b/app/controllers/api/v1/notifications_controller.rb index f2e01cf5..e8ef7f86 100644 --- a/app/controllers/api/v1/notifications_controller.rb +++ b/app/controllers/api/v1/notifications_controller.rb @@ -36,7 +36,7 @@ class Api::V1::NotificationsController < Api::BaseController end def paginated_notifications - browserable_account_notifications.paginate_by_id( + browserable_account_notifications.latest.paginate_by_id( limit_param(DEFAULT_NOTIFICATIONS_LIMIT), params_slice(:max_id, :since_id, :min_id) ) diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index bb81ed9f..901c6ab3 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true -class Api::V1::SearchController < EmptyController +class Api::V1::SearchController < Api::BaseController + before_action :require_user! + RESULTS_LIMIT = 25 def index diff --git a/app/controllers/api/v1/timelines/group_collection_controller.rb b/app/controllers/api/v1/timelines/group_collection_controller.rb index 86597e55..c52e261f 100644 --- a/app/controllers/api/v1/timelines/group_collection_controller.rb +++ b/app/controllers/api/v1/timelines/group_collection_controller.rb @@ -13,7 +13,7 @@ class Api::V1::Timelines::GroupCollectionController < Api::BaseController each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_account.id) else - render json: @statuses, each_serializer: REST::StatusSerializer + render json: [], each_serializer: REST::StatusSerializer end end diff --git a/app/controllers/api/v1/timelines/group_controller.rb b/app/controllers/api/v1/timelines/group_controller.rb index 7b2f49df..defb7bf3 100644 --- a/app/controllers/api/v1/timelines/group_controller.rb +++ b/app/controllers/api/v1/timelines/group_controller.rb @@ -54,7 +54,8 @@ class Api::V1::Timelines::GroupController < Api::BaseController FeedManager.instance.filter?(:home, status, current_account.id) } else - SortingQueryBuilder.new.call(@sort_type, @group, params[:page]) + return [] + # SortingQueryBuilder.new.call(@sort_type, @group, params[:page]) end end diff --git a/app/controllers/api/v1/timelines/list_controller.rb b/app/controllers/api/v1/timelines/list_controller.rb index 1447817f..20960d13 100644 --- a/app/controllers/api/v1/timelines/list_controller.rb +++ b/app/controllers/api/v1/timelines/list_controller.rb @@ -9,7 +9,7 @@ class Api::V1::Timelines::ListController < Api::BaseController after_action :insert_pagination_headers, unless: -> { @statuses.empty? } def show - render json: @statuses, + render json: [], each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user.account_id) end diff --git a/app/javascript/gabsocial/actions/chats.js b/app/javascript/gabsocial/actions/chats.js index b9773618..1b1b92d1 100644 --- a/app/javascript/gabsocial/actions/chats.js +++ b/app/javascript/gabsocial/actions/chats.js @@ -21,7 +21,8 @@ export const fetchChatConversationAccountSuggestions = (query) => (dispatch, get export const debouncedFetchChatConversationAccountSuggestions = debounce((query, dispatch, getState) => { if (!query) return - + return false + api(getState).get('/api/v1/accounts/search', { params: { q: query, diff --git a/app/javascript/gabsocial/actions/compose.js b/app/javascript/gabsocial/actions/compose.js index b455a3be..bcccc8ba 100644 --- a/app/javascript/gabsocial/actions/compose.js +++ b/app/javascript/gabsocial/actions/compose.js @@ -537,6 +537,8 @@ const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) => cancelFetchComposeSuggestionsAccounts() } + return false + api(getState).get('/api/v1/accounts/search', { cancelToken: new CancelToken(cancel => { cancelFetchComposeSuggestionsAccounts = cancel diff --git a/app/javascript/gabsocial/actions/lists.js b/app/javascript/gabsocial/actions/lists.js index f943c5cf..858a137f 100644 --- a/app/javascript/gabsocial/actions/lists.js +++ b/app/javascript/gabsocial/actions/lists.js @@ -289,6 +289,8 @@ export const fetchListAccountsFail = (id, error) => ({ export const fetchListSuggestions = (q) => (dispatch, getState) => { if (!me) return + return false + const params = { q, resolve: false, diff --git a/app/javascript/gabsocial/components/panel/user_suggestions_panel.js b/app/javascript/gabsocial/components/panel/user_suggestions_panel.js index dcabd0c1..96d3da85 100644 --- a/app/javascript/gabsocial/components/panel/user_suggestions_panel.js +++ b/app/javascript/gabsocial/components/panel/user_suggestions_panel.js @@ -34,13 +34,13 @@ class UserSuggestionsPanel extends ImmutablePureComponent { componentDidUpdate(prevProps, prevState) { if (!prevState.fetched && this.state.fetched) { - this.handleFetch() + // this.handleFetch() } } componentDidMount() { if (!this.props.isLazy) { - this.handleFetch() + // this.handleFetch() } } @@ -60,6 +60,7 @@ class UserSuggestionsPanel extends ImmutablePureComponent { suggestionType, } = this.props + return null if (suggestions.isEmpty()) return null const Child = isLoading ? AccountPlaceholder : Account diff --git a/app/javascript/gabsocial/components/sidebar/default_sidebar.js b/app/javascript/gabsocial/components/sidebar/default_sidebar.js index 21883c31..3f140377 100644 --- a/app/javascript/gabsocial/components/sidebar/default_sidebar.js +++ b/app/javascript/gabsocial/components/sidebar/default_sidebar.js @@ -21,7 +21,7 @@ class DefaultSidebar extends ImmutablePureComponent { } componentDidMount() { - this.props.onFetchShortcuts() + // this.props.onFetchShortcuts() } handleOpenSidebarMorePopover = () => { diff --git a/app/javascript/gabsocial/components/timeline_injections/timeline_injection_root.js b/app/javascript/gabsocial/components/timeline_injections/timeline_injection_root.js index 05d8d27a..fbab3349 100644 --- a/app/javascript/gabsocial/components/timeline_injections/timeline_injection_root.js +++ b/app/javascript/gabsocial/components/timeline_injections/timeline_injection_root.js @@ -54,6 +54,8 @@ class TimelineInjectionRoot extends React.PureComponent { //If is not XS and popover is pwa, dont show //Since not on mobile this should not be visible if (!isXS && type === TIMELINE_INJECTION_PWA) return
+ + if (type === TIMELINE_INJECTION_FEATURED_GROUPS || type === TIMELINE_INJECTION_USER_SUGGESTIONS) return return (