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
786f1d8b
Commit
786f1d8b
authored
2 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
remove unused files
parent
c8f6bc0d
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
packages/backend/src/server/api/common/inject-featured.ts
+0
-53
0 additions, 53 deletions
packages/backend/src/server/api/common/inject-featured.ts
packages/backend/src/server/api/common/inject-promo.ts
+0
-33
0 additions, 33 deletions
packages/backend/src/server/api/common/inject-promo.ts
with
0 additions
and
86 deletions
packages/backend/src/server/api/common/inject-featured.ts
deleted
100644 → 0
+
0
−
53
View file @
c8f6bc0d
import
rndstr
from
'
rndstr
'
;
import
type
{
Note
}
from
'
@/models/entities/Note.js
'
;
import
type
{
User
}
from
'
@/models/entities/User.js
'
;
// TODO: リアクション、Renote、返信などをしたノートは除外する
export
async
function
injectFeatured
(
timeline
:
Note
[],
user
?:
User
|
null
)
{
if
(
timeline
.
length
<
5
)
return
;
if
(
user
)
{
const
profile
=
await
UserProfiles
.
findOneByOrFail
({
userId
:
user
.
id
});
if
(
!
profile
.
injectFeaturedNote
)
return
;
}
const
max
=
30
;
const
day
=
1000
*
60
*
60
*
24
*
3
;
// 3日前まで
const
query
=
Notes
.
createQueryBuilder
(
'
note
'
)
.
addSelect
(
'
note.score
'
)
.
where
(
'
note.userHost IS NULL
'
)
.
andWhere
(
'
note.score > 0
'
)
.
andWhere
(
'
note.createdAt > :date
'
,
{
date
:
new
Date
(
Date
.
now
()
-
day
)
})
.
andWhere
(
'
note.visibility =
\'
public
\'
'
)
.
innerJoinAndSelect
(
'
note.user
'
,
'
user
'
);
if
(
user
)
{
query
.
andWhere
(
'
note.userId != :userId
'
,
{
userId
:
user
.
id
});
generateMutedUserQuery
(
query
,
user
);
generateBlockedUserQuery
(
query
,
user
);
const
reactionQuery
=
NoteReactions
.
createQueryBuilder
(
'
reaction
'
)
.
select
(
'
reaction.noteId
'
)
.
where
(
'
reaction.userId = :userId
'
,
{
userId
:
user
.
id
});
query
.
andWhere
(
`note.id NOT IN (
${
reactionQuery
.
getQuery
()
}
)`
);
}
const
notes
=
await
query
.
orderBy
(
'
note.score
'
,
'
DESC
'
)
.
take
(
max
)
.
getMany
();
if
(
notes
.
length
===
0
)
return
;
// Pick random one
const
featured
=
notes
[
Math
.
floor
(
Math
.
random
()
*
notes
.
length
)];
(
featured
as
any
).
_featuredId_
=
rndstr
(
'
a-z0-9
'
,
8
);
// Inject featured
timeline
.
splice
(
3
,
0
,
featured
);
}
This diff is collapsed.
Click to expand it.
packages/backend/src/server/api/common/inject-promo.ts
deleted
100644 → 0
+
0
−
33
View file @
c8f6bc0d
import
rndstr
from
'
rndstr
'
;
import
type
{
Note
}
from
'
@/models/entities/Note.js
'
;
import
type
{
User
}
from
'
@/models/entities/User.js
'
;
export
async
function
injectPromo
(
timeline
:
Note
[],
user
?:
User
|
null
)
{
if
(
timeline
.
length
<
5
)
return
;
// TODO: readやexpireフィルタはクエリ側でやる
const
reads
=
user
?
await
PromoReads
.
findBy
({
userId
:
user
.
id
,
})
:
[];
let
promos
=
await
PromoNotes
.
find
();
promos
=
promos
.
filter
(
n
=>
n
.
expiresAt
.
getTime
()
>
Date
.
now
());
promos
=
promos
.
filter
(
n
=>
!
reads
.
map
(
r
=>
r
.
noteId
).
includes
(
n
.
noteId
));
if
(
promos
.
length
===
0
)
return
;
// Pick random promo
const
promo
=
promos
[
Math
.
floor
(
Math
.
random
()
*
promos
.
length
)];
const
note
=
await
Notes
.
findOneByOrFail
({
id
:
promo
.
noteId
});
// Join
note
.
user
=
await
Users
.
findOneByOrFail
({
id
:
note
.
userId
});
(
note
as
any
).
_prId_
=
rndstr
(
'
a-z0-9
'
,
8
);
// Inject promo
timeline
.
splice
(
3
,
0
,
note
);
}
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