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
Dima Krasner
Sharkey
Commits
132b0146
Commit
132b0146
authored
1 year ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
refactor
parent
dab205ed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/backend/src/core/FeaturedService.ts
+5
-3
5 additions, 3 deletions
packages/backend/src/core/FeaturedService.ts
with
5 additions
and
3 deletions
packages/backend/src/core/FeaturedService.ts
+
5
−
3
View file @
132b0146
...
...
@@ -9,6 +9,8 @@ import type { MiNote } from '@/models/_.js';
import
{
DI
}
from
'
@/di-symbols.js
'
;
import
{
bindThis
}
from
'
@/decorators.js
'
;
const
GLOBAL_NOTES_RANKING_WINDOW
=
1000
*
60
*
60
*
24
*
3
;
// 3日ごと
@
Injectable
()
export
class
FeaturedService
{
constructor
(
...
...
@@ -26,7 +28,7 @@ export class FeaturedService {
@
bindThis
private
getCurrentGlobalNotesRankingWindow
():
number
{
const
passed
=
new
Date
().
getTime
()
-
new
Date
(
new
Date
().
getFullYear
(),
0
,
1
).
getTime
();
return
Math
.
floor
(
passed
/
(
1000
*
60
*
60
*
24
*
3
));
// 3日ごと
return
Math
.
floor
(
passed
/
GLOBAL_NOTES_RANKING_WINDOW
);
}
@
bindThis
...
...
@@ -40,7 +42,7 @@ export class FeaturedService {
noteId
);
redisTransaction
.
expire
(
`featuredGlobalNotesRanking:
${
currentWindow
}
`
,
60
*
60
*
24
*
9
,
// 9日間保持
(
GLOBAL_NOTES_RANKING_WINDOW
*
3
)
/
1000
,
'
NX
'
);
// "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
await
redisTransaction
.
exec
();
}
...
...
@@ -55,7 +57,7 @@ export class FeaturedService {
noteId
);
redisTransaction
.
expire
(
`featuredInChannelNotesRanking:
${
channelId
}
:
${
currentWindow
}
`
,
60
*
60
*
24
*
9
,
// 9日間保持
(
GLOBAL_NOTES_RANKING_WINDOW
*
3
)
/
1000
,
'
NX
'
);
// "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
await
redisTransaction
.
exec
();
}
...
...
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