Skip to content

Commit

Permalink
🐛 Fixed degraded database performance when using the Post Analytics s…
Browse files Browse the repository at this point in the history
…creen (#22031)

ref
https://linear.app/ghost/issue/ONC-717/support-escalation-re-dashboard-unresponsive

This reverts commit 9082a9f, which
introduced an automatic refresh interval on the Post Analytics screen in
Admin. This change led to an increase in the number of requests to the
`/ghost/api/admin/members/events/` endpoint, which is a particularly
database intensive endpoint. Ultimately this led to significantly higher
load on the database which degraded performance for sites with a large
`email_recipients` table.
  • Loading branch information
cmraible committed Jan 21, 2025
1 parent ff45459 commit 3857d2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
8 changes: 8 additions & 0 deletions ghost/admin/app/components/posts/analytics.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
{{/let}}
</div>
<div style="display: flex; gap: 8px;">
<GhTaskButton
@buttonText="Refresh"
@task={{this.fetchPostTask}}
@showIcon={{true}}
@idleIcon="reload"
@successText="Refreshed"
@class="gh-btn gh-btn-icon refresh"
@successClass="gh-btn gh-btn-icon refresh" />
{{#unless this.post.emailOnly}}
<button type="button" class="gh-btn gh-btn-icon share" {{on "click" this.togglePublishFlowModal}}>
<span>{{svg-jar "share" title="Share post"}} Share</span>
Expand Down
13 changes: 1 addition & 12 deletions ghost/admin/app/components/posts/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import DeletePostModal from '../modals/delete-post';
import PostSuccessModal from '../modal-post-success';
import anime from 'animejs/lib/anime.es.js';
import {action} from '@ember/object';
import {didCancel, task, timeout} from 'ember-concurrency';
import {didCancel, task} from 'ember-concurrency';
import {inject as service} from '@ember/service';
import {tracked} from '@glimmer/tracking';

Expand All @@ -19,8 +19,6 @@ const DISPLAY_OPTIONS = [{
value: 'paid'
}];

const AUTO_REFRESH_RATE = 7500;

export default class Analytics extends Component {
@service ajax;
@service ghostPaths;
Expand Down Expand Up @@ -53,8 +51,6 @@ export default class Analytics extends Component {
constructor() {
super(...arguments);
this.checkPublishFlowModal();
this.fetchPostTask.perform();
this.autoRefreshTask.perform();
}

openPublishFlowModal() {
Expand Down Expand Up @@ -394,13 +390,6 @@ export default class Analytics extends Component {
return true;
}

@task
*autoRefreshTask() {
yield timeout(AUTO_REFRESH_RATE);
yield this.fetchPostTask.perform();
this.autoRefreshTask.perform();
}

@action
applyClasses(element) {
if (!this.shouldAnimate ||
Expand Down

0 comments on commit 3857d2f

Please sign in to comment.