Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Pierre Boudes
mastodon
Commits
575dc11c
Unverified
Commit
575dc11c
authored
5 years ago
by
Eugen Rochko
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix needlessly indexing unsearchable statuses into ElasticSearch (#12041)
parent
699f53c4
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
app/chewy/statuses_index.rb
+4
-4
4 additions, 4 deletions
app/chewy/statuses_index.rb
app/models/status.rb
+6
-4
6 additions, 4 deletions
app/models/status.rb
with
10 additions
and
8 deletions
app/chewy/statuses_index.rb
+
4
−
4
View file @
575dc11c
...
...
@@ -31,19 +31,19 @@ class StatusesIndex < Chewy::Index
},
}
define_type
::
Status
.
unscoped
.
without_reblogs
.
includes
(
:media_attachments
)
do
define_type
::
Status
.
unscoped
.
kept
.
without_reblogs
.
includes
(
:media_attachments
)
,
delete_if:
->
(
status
)
{
status
.
searchable_by
.
empty?
}
do
crutch
:mentions
do
|
collection
|
data
=
::
Mention
.
where
(
status_id:
collection
.
map
(
&
:id
)).
pluck
(
:status_id
,
:account_id
)
data
=
::
Mention
.
where
(
status_id:
collection
.
map
(
&
:id
)).
where
(
account:
Account
.
local
).
pluck
(
:status_id
,
:account_id
)
data
.
each
.
with_object
({})
{
|
(
id
,
name
),
result
|
(
result
[
id
]
||=
[]).
push
(
name
)
}
end
crutch
:favourites
do
|
collection
|
data
=
::
Favourite
.
where
(
status_id:
collection
.
map
(
&
:id
)).
pluck
(
:status_id
,
:account_id
)
data
=
::
Favourite
.
where
(
status_id:
collection
.
map
(
&
:id
)).
where
(
account:
Account
.
local
).
pluck
(
:status_id
,
:account_id
)
data
.
each
.
with_object
({})
{
|
(
id
,
name
),
result
|
(
result
[
id
]
||=
[]).
push
(
name
)
}
end
crutch
:reblogs
do
|
collection
|
data
=
::
Status
.
where
(
reblog_of_id:
collection
.
map
(
&
:id
)).
pluck
(
:reblog_of_id
,
:account_id
)
data
=
::
Status
.
where
(
reblog_of_id:
collection
.
map
(
&
:id
)).
where
(
account:
Account
.
local
).
pluck
(
:reblog_of_id
,
:account_id
)
data
.
each
.
with_object
({})
{
|
(
id
,
name
),
result
|
(
result
[
id
]
||=
[]).
push
(
name
)
}
end
...
...
This diff is collapsed.
Click to expand it.
app/models/status.rb
+
6
−
4
View file @
575dc11c
...
...
@@ -129,12 +129,14 @@ class Status < ApplicationRecord
REAL_TIME_WINDOW
=
6
.
hours
def
searchable_by
(
preloaded
=
nil
)
ids
=
[
account_id
]
ids
=
[]
ids
<<
account_id
if
local?
if
preloaded
.
nil?
ids
+=
mentions
.
pluck
(
:account_id
)
ids
+=
favourites
.
pluck
(
:account_id
)
ids
+=
reblogs
.
pluck
(
:account_id
)
ids
+=
mentions
.
where
(
account:
Account
.
local
).
pluck
(
:account_id
)
ids
+=
favourites
.
where
(
account:
Account
.
local
).
pluck
(
:account_id
)
ids
+=
reblogs
.
where
(
account:
Account
.
local
).
pluck
(
:account_id
)
else
ids
+=
preloaded
.
mentions
[
id
]
||
[]
ids
+=
preloaded
.
favourites
[
id
]
||
[]
...
...
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