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
69de8cad
Commit
69de8cad
authored
1 year ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
refactor
parent
fb333802
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/server/api/endpoints/users/notes.ts
+26
-28
26 additions, 28 deletions
packages/backend/src/server/api/endpoints/users/notes.ts
with
26 additions
and
28 deletions
packages/backend/src/server/api/endpoints/users/notes.ts
+
26
−
28
View file @
69de8cad
...
...
@@ -81,38 +81,36 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
let
timeline
:
MiNote
[]
=
[];
const
limit
=
ps
.
limit
+
(
ps
.
untilId
?
1
:
0
)
+
(
ps
.
sinceId
?
1
:
0
);
// untilIdに指定したものも含まれるため+1
let
noteIdsRes
:
[
string
,
string
[]][]
=
[];
let
repliesNoteIdsRes
:
[
string
,
string
[]][]
=
[];
let
channelNoteIdsRes
:
[
string
,
string
[]][]
=
[];
if
(
!
ps
.
sinceId
&&
!
ps
.
sinceDate
)
{
[
noteIdsRes
,
repliesNoteIdsRes
,
channelNoteIdsRes
]
=
await
Promise
.
all
([
this
.
redisForTimelines
.
xrevrange
(
ps
.
withFiles
?
`userTimelineWithFiles:
${
ps
.
userId
}
`
:
`userTimeline:
${
ps
.
userId
}
`
,
const
[
noteIdsRes
,
repliesNoteIdsRes
,
channelNoteIdsRes
]
=
await
Promise
.
all
([
this
.
redisForTimelines
.
xrevrange
(
ps
.
withFiles
?
`userTimelineWithFiles:
${
ps
.
userId
}
`
:
`userTimeline:
${
ps
.
userId
}
`
,
ps
.
untilId
?
this
.
idService
.
parse
(
ps
.
untilId
).
date
.
getTime
()
:
ps
.
untilDate
??
'
+
'
,
ps
.
sinceId
?
this
.
idService
.
parse
(
ps
.
sinceId
).
date
.
getTime
()
:
ps
.
sinceDate
??
'
-
'
,
'
COUNT
'
,
limit
,
).
then
(
res
=>
res
.
map
(
x
=>
x
[
1
][
1
]).
filter
(
x
=>
x
!==
ps
.
untilId
&&
x
!==
ps
.
sinceId
)),
ps
.
withReplies
?
this
.
redisForTimelines
.
xrevrange
(
`userTimelineWithReplies:
${
ps
.
userId
}
`
,
ps
.
untilId
?
this
.
idService
.
parse
(
ps
.
untilId
).
date
.
getTime
()
:
ps
.
untilDate
??
'
+
'
,
ps
.
sinceId
?
this
.
idService
.
parse
(
ps
.
sinceId
).
date
.
getTime
()
:
ps
.
sinceDate
??
'
-
'
,
'
COUNT
'
,
limit
),
ps
.
withReplies
?
this
.
redisForTimelines
.
xrevrange
(
`userTimelineWithReplies:
${
ps
.
userId
}
`
,
ps
.
untilId
?
this
.
idService
.
parse
(
ps
.
untilId
).
date
.
getTime
()
:
ps
.
untilDate
??
'
+
'
,
ps
.
sinceId
?
this
.
idService
.
parse
(
ps
.
sinceId
).
date
.
getTime
()
:
ps
.
sinceDate
??
'
-
'
,
'
COUNT
'
,
limit
)
:
Promise
.
resolve
([]),
ps
.
withChannelNotes
?
this
.
redisForTimelines
.
xrevrange
(
`userTimelineWithChannel:
${
ps
.
userId
}
`
,
ps
.
untilId
?
this
.
idService
.
parse
(
ps
.
untilId
).
date
.
getTime
()
:
ps
.
untilDate
??
'
+
'
,
ps
.
sinceId
?
this
.
idService
.
parse
(
ps
.
sinceId
).
date
.
getTime
()
:
ps
.
sinceDate
??
'
-
'
,
'
COUNT
'
,
limit
)
:
Promise
.
resolve
([]),
]);
}
'
COUNT
'
,
limit
,
).
then
(
res
=>
res
.
map
(
x
=>
x
[
1
][
1
]).
filter
(
x
=>
x
!==
ps
.
untilId
&&
x
!==
ps
.
sinceId
))
:
Promise
.
resolve
([]),
ps
.
withChannelNotes
?
this
.
redisForTimelines
.
xrevrange
(
`userTimelineWithChannel:
${
ps
.
userId
}
`
,
ps
.
untilId
?
this
.
idService
.
parse
(
ps
.
untilId
).
date
.
getTime
()
:
ps
.
untilDate
??
'
+
'
,
ps
.
sinceId
?
this
.
idService
.
parse
(
ps
.
sinceId
).
date
.
getTime
()
:
ps
.
sinceDate
??
'
-
'
,
'
COUNT
'
,
limit
,
).
then
(
res
=>
res
.
map
(
x
=>
x
[
1
][
1
]).
filter
(
x
=>
x
!==
ps
.
untilId
&&
x
!==
ps
.
sinceId
))
:
Promise
.
resolve
([]),
]);
let
noteIds
=
Array
.
from
(
new
Set
([
...
noteIdsRes
.
map
(
x
=>
x
[
1
][
1
]).
filter
(
x
=>
x
!==
ps
.
untilId
&&
x
!==
ps
.
sinceId
)
,
...
repliesNoteIdsRes
.
map
(
x
=>
x
[
1
][
1
]).
filter
(
x
=>
x
!==
ps
.
untilId
&&
x
!==
ps
.
sinceId
)
,
...
channelNoteIdsRes
.
map
(
x
=>
x
[
1
][
1
]).
filter
(
x
=>
x
!==
ps
.
untilId
&&
x
!==
ps
.
sinceId
)
,
...
noteIdsRes
,
...
repliesNoteIdsRes
,
...
channelNoteIdsRes
,
]));
noteIds
.
sort
((
a
,
b
)
=>
a
>
b
?
-
1
:
1
);
noteIds
=
noteIds
.
slice
(
0
,
ps
.
limit
);
...
...
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