Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Essem
Sharkey
Commits
33b22a32
Commit
33b22a32
authored
2 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
perf(server): improve stats api performance
parent
f032fb62
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
packages/backend/src/server/api/endpoints/stats.ts
+13
-8
13 additions, 8 deletions
packages/backend/src/server/api/endpoints/stats.ts
with
14 additions
and
8 deletions
CHANGELOG.md
+
1
−
0
View file @
33b22a32
...
...
@@ -62,6 +62,7 @@ You should also include the user name that made the change.
-
Server: improve syslog performance @syuilo
-
Server: improve note scoring for featured notes @CyberRex0
-
Server: アンケート選択肢の文字数制限を緩和 @syuilo
-
Server: improve stats api performance @syuilo
-
Server: delete outdated notifications regularly to improve db performance @syuilo
-
Server: delete outdated hard-mutes regularly to improve db performance @syuilo
-
Server: delete outdated notes of antenna regularly to improve db performance @syuilo
...
...
This diff is collapsed.
Click to expand it.
packages/backend/src/server/api/endpoints/stats.ts
+
13
−
8
View file @
33b22a32
...
...
@@ -3,6 +3,8 @@ import { IsNull } from 'typeorm';
import
type
{
InstancesRepository
,
NoteReactionsRepository
,
NotesRepository
,
UsersRepository
}
from
'
@/models/index.js
'
;
import
{
Endpoint
}
from
'
@/server/api/endpoint-base.js
'
;
import
{
DI
}
from
'
@/di-symbols.js
'
;
import
NotesChart
from
'
@/core/chart/charts/notes.js
'
;
import
UsersChart
from
'
@/core/chart/charts/users.js
'
;
export
const
meta
=
{
requireCredential
:
false
,
...
...
@@ -66,21 +68,24 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
@
Inject
(
DI
.
noteReactionsRepository
)
private
noteReactionsRepository
:
NoteReactionsRepository
,
private
notesChart
:
NotesChart
,
private
usersChart
:
UsersChart
,
)
{
super
(
meta
,
paramDef
,
async
()
=>
{
const
notesChart
=
await
this
.
notesChart
.
getChart
(
'
hour
'
,
1
,
null
);
const
notesCount
=
notesChart
.
local
.
total
[
0
]
+
notesChart
.
remote
.
total
[
0
];
const
originalNotesCount
=
notesChart
.
local
.
total
[
0
];
const
usersChart
=
await
this
.
usersChart
.
getChart
(
'
hour
'
,
1
,
null
);
const
usersCount
=
usersChart
.
local
.
total
[
0
]
+
usersChart
.
remote
.
total
[
0
];
const
originalUsersCount
=
usersChart
.
local
.
total
[
0
];
const
[
notesCount
,
originalNotesCount
,
usersCount
,
originalUsersCount
,
reactionsCount
,
//originalReactionsCount,
instances
,
]
=
await
Promise
.
all
([
this
.
notesRepository
.
count
({
cache
:
3600000
}),
// 1 hour
this
.
notesRepository
.
count
({
where
:
{
userHost
:
IsNull
()
},
cache
:
3600000
}),
this
.
usersRepository
.
count
({
cache
:
3600000
}),
this
.
usersRepository
.
count
({
where
:
{
host
:
IsNull
()
},
cache
:
3600000
}),
this
.
noteReactionsRepository
.
count
({
cache
:
3600000
}),
// 1 hour
//this.noteReactionsRepository.count({ where: { userHost: IsNull() }, cache: 3600000 }),
this
.
instancesRepository
.
count
({
cache
:
3600000
}),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment