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
ff196401
Commit
ff196401
authored
3 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
perf(server): reduce db query
parent
81ee9025
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
locales/ja-JP.yml
+1
-0
1 addition, 0 deletions
locales/ja-JP.yml
packages/backend/src/services/note/create.ts
+27
-11
27 additions, 11 deletions
packages/backend/src/services/note/create.ts
packages/client/src/pages/settings/word-mute.vue
+1
-1
1 addition, 1 deletion
packages/client/src/pages/settings/word-mute.vue
with
29 additions
and
12 deletions
locales/ja-JP.yml
+
1
−
0
View file @
ff196401
...
...
@@ -840,6 +840,7 @@ tenMinutes: "10分"
oneHour
:
"
1時間"
oneDay
:
"
1日"
oneWeek
:
"
1週間"
reflectMayTakeTime
:
"
反映されるまで時間がかかる場合があります。"
_emailUnavailable
:
used
:
"
既に使用されています"
...
...
This diff is collapsed.
Click to expand it.
packages/backend/src/services/note/create.ts
+
27
−
11
View file @
ff196401
...
...
@@ -35,6 +35,12 @@ import { Channel } from '@/models/entities/channel.js';
import
{
normalizeForSearch
}
from
'
@/misc/normalize-for-search.js
'
;
import
{
getAntennas
}
from
'
@/misc/antenna-cache.js
'
;
import
{
endedPollNotificationQueue
}
from
'
@/queue/queues.js
'
;
import
{
Cache
}
from
'
@/misc/cache.js
'
;
import
{
UserProfile
}
from
'
@/models/entities/user-profile.js
'
;
const
usersCache
=
new
Cache
<
MinimumUser
>
(
Infinity
);
const
mutedWordsCache
=
new
Cache
<
{
userId
:
UserProfile
[
'
userId
'
];
mutedWords
:
UserProfile
[
'
mutedWords
'
];
}[]
>
(
1000
*
60
*
5
);
type
NotificationType
=
'
reply
'
|
'
renote
'
|
'
quote
'
|
'
mention
'
;
...
...
@@ -91,6 +97,13 @@ class NotificationManager {
}
}
type
MinimumUser
=
{
id
:
User
[
'
id
'
];
host
:
User
[
'
host
'
];
username
:
User
[
'
username
'
];
uri
:
User
[
'
uri
'
];
};
type
Option
=
{
createdAt
?:
Date
|
null
;
name
?:
string
|
null
;
...
...
@@ -102,9 +115,9 @@ type Option = {
localOnly
?:
boolean
|
null
;
cw
?:
string
|
null
;
visibility
?:
string
;
visibleUsers
?:
User
[]
|
null
;
visibleUsers
?:
Minimum
User
[]
|
null
;
channel
?:
Channel
|
null
;
apMentions
?:
User
[]
|
null
;
apMentions
?:
Minimum
User
[]
|
null
;
apHashtags
?:
string
[]
|
null
;
apEmojis
?:
string
[]
|
null
;
uri
?:
string
|
null
;
...
...
@@ -199,7 +212,7 @@ export default async (user: { id: User['id']; username: User['username']; host:
tags
=
tags
.
filter
(
tag
=>
Array
.
from
(
tag
||
''
).
length
<=
128
).
splice
(
0
,
32
);
if
(
data
.
reply
&&
(
user
.
id
!==
data
.
reply
.
userId
)
&&
!
mentionedUsers
.
some
(
u
=>
u
.
id
===
data
.
reply
!
.
userId
))
{
mentionedUsers
.
push
(
await
Users
.
findOneOrFail
(
data
.
reply
.
userId
));
mentionedUsers
.
push
(
await
usersCache
.
fetch
(
data
.
reply
.
userId
,
()
=>
Users
.
findOneOrFail
(
data
.
reply
!
.
userId
))
)
;
}
if
(
data
.
visibility
===
'
specified
'
)
{
...
...
@@ -212,7 +225,7 @@ export default async (user: { id: User['id']; username: User['username']; host:
}
if
(
data
.
reply
&&
!
data
.
visibleUsers
.
some
(
x
=>
x
.
id
===
data
.
reply
!
.
userId
))
{
data
.
visibleUsers
.
push
(
await
Users
.
findOneOrFail
(
data
.
reply
.
userId
));
data
.
visibleUsers
.
push
(
await
usersCache
.
fetch
(
data
.
reply
.
userId
,
()
=>
Users
.
findOneOrFail
(
data
.
reply
!
.
userId
))
)
;
}
}
...
...
@@ -241,10 +254,12 @@ export default async (user: { id: User['id']; username: User['username']; host:
incNotesCountOfUser
(
user
);
// Word mute
// TODO: cache
UserProfiles
.
find
({
enableWordMute
:
true
,
}).
then
(
us
=>
{
mutedWordsCache
.
fetch
(
null
,
()
=>
UserProfiles
.
find
({
where
:
{
enableWordMute
:
true
,
},
select
:
[
'
userId
'
,
'
mutedWords
'
],
})).
then
(
us
=>
{
for
(
const
u
of
us
)
{
checkWordMute
(
note
,
{
id
:
u
.
userId
},
u
.
mutedWords
).
then
(
shouldMute
=>
{
if
(
shouldMute
)
{
...
...
@@ -260,11 +275,12 @@ export default async (user: { id: User['id']; username: User['username']; host:
});
// Antenna
// TODO: キャッシュしたい
Followings
.
createQueryBuilder
(
'
following
'
)
.
andWhere
(
`following.followeeId = :userId`
,
{
userId
:
note
.
userId
})
.
getMany
()
.
then
(
async
followings
=>
{
const
blockings
=
await
Blockings
.
find
({
blockerId
:
user
.
id
});
// TODO: キャッシュしたい
const
blockings
=
await
Blockings
.
find
({
blockerId
:
user
.
id
});
const
followers
=
followings
.
map
(
f
=>
f
.
followerId
);
for
(
const
antenna
of
(
await
getAntennas
()))
{
if
(
blockings
.
some
(
blocking
=>
blocking
.
blockeeId
===
antenna
.
userId
))
continue
;
// この処理は checkHitAntenna 内でやるようにしてもいいかも
...
...
@@ -465,7 +481,7 @@ function incRenoteCount(renote: Note) {
.
execute
();
}
async
function
insertNote
(
user
:
{
id
:
User
[
'
id
'
];
host
:
User
[
'
host
'
];
},
data
:
Option
,
tags
:
string
[],
emojis
:
string
[],
mentionedUsers
:
User
[])
{
async
function
insertNote
(
user
:
{
id
:
User
[
'
id
'
];
host
:
User
[
'
host
'
];
},
data
:
Option
,
tags
:
string
[],
emojis
:
string
[],
mentionedUsers
:
Minimum
User
[])
{
const
insert
=
new
Note
({
id
:
genId
(
data
.
createdAt
!
),
createdAt
:
data
.
createdAt
!
,
...
...
@@ -597,7 +613,7 @@ async function notifyToWatchersOfReplyee(reply: Note, user: { id: User['id']; },
}
}
async
function
createMentionedEvents
(
mentionedUsers
:
User
[],
note
:
Note
,
nm
:
NotificationManager
)
{
async
function
createMentionedEvents
(
mentionedUsers
:
Minimum
User
[],
note
:
Note
,
nm
:
NotificationManager
)
{
for
(
const
u
of
mentionedUsers
.
filter
(
u
=>
Users
.
isLocalUser
(
u
)))
{
const
threadMuted
=
await
NoteThreadMutings
.
findOne
({
userId
:
u
.
id
,
...
...
This diff is collapsed.
Click to expand it.
packages/client/src/pages/settings/word-mute.vue
+
1
−
1
View file @
ff196401
...
...
@@ -13,7 +13,7 @@
</FormTextarea>
</div>
<div
v-show=
"tab === 'hard'"
>
<MkInfo
class=
"_formBlock"
>
{{ $ts._wordMute.hardDescription }}
</MkInfo>
<MkInfo
class=
"_formBlock"
>
{{ $ts._wordMute.hardDescription
}} {{ $ts.reflectMayTakeTime
}}
</MkInfo>
<FormTextarea
v-model=
"hardMutedWords"
class=
"_formBlock"
>
<span>
{{ $ts._wordMute.muteWords }}
</span>
<
template
#caption
>
{{
$ts
.
_wordMute
.
muteWordsDescription
}}
<br>
{{
$ts
.
_wordMute
.
muteWordsDescription2
}}
</
template
>
...
...
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