SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
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
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
SciPost
SciPost
Commits
6fb24a35
Commit
6fb24a35
authored
6 years ago
by
Jean-Sébastien Caux
Browse files
Options
Downloads
Patches
Plain Diff
Temporary version, using pickle (since json crashes; needs yaml)
parent
03dc0e78
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SciPost_v1/signalprocessors.py
+19
-4
19 additions, 4 deletions
SciPost_v1/signalprocessors.py
with
19 additions
and
4 deletions
SciPost_v1/signalprocessors.py
+
19
−
4
View file @
6fb24a35
...
@@ -5,10 +5,14 @@ __license__ = "AGPL v3"
...
@@ -5,10 +5,14 @@ __license__ = "AGPL v3"
from
haystack
import
signals
from
haystack
import
signals
from
haystack.exceptions
import
NotHandled
from
haystack.exceptions
import
NotHandled
from
SciPost_v1.celery
import
app
from
submissions.models
import
Submission
from
submissions.models
import
Submission
class
AutoSearchIndexingProcessor
(
signals
.
RealtimeSignalProcessor
):
class
AutoSearchIndexingProcessor
(
signals
.
RealtimeSignalProcessor
):
@app.task
(
bind
=
True
,
name
=
'
signalprocessors.remove_object_indexes
'
,
serializer
=
'
pickle
'
)
def
remove_objects_indexes
(
self
,
sender
,
objects
):
def
remove_objects_indexes
(
self
,
sender
,
objects
):
"""
"""
Given a set of `objects` model instances, remove them from the index as preparation
Given a set of `objects` model instances, remove them from the index as preparation
...
@@ -29,6 +33,8 @@ class AutoSearchIndexingProcessor(signals.RealtimeSignalProcessor):
...
@@ -29,6 +33,8 @@ class AutoSearchIndexingProcessor(signals.RealtimeSignalProcessor):
# TODO: Maybe log it or let the exception bubble?
# TODO: Maybe log it or let the exception bubble?
pass
pass
@app.task
(
bind
=
True
,
name
=
'
signalprocessors.update_instance_indexes
'
,
serializer
=
'
pickle
'
)
def
update_instance_indexes
(
self
,
sender
,
instance
):
def
update_instance_indexes
(
self
,
sender
,
instance
):
"""
"""
Given an individual model instance, update its entire indexes.
Given an individual model instance, update its entire indexes.
...
@@ -51,11 +57,20 @@ class AutoSearchIndexingProcessor(signals.RealtimeSignalProcessor):
...
@@ -51,11 +57,20 @@ class AutoSearchIndexingProcessor(signals.RealtimeSignalProcessor):
if
isinstance
(
instance
,
Submission
):
if
isinstance
(
instance
,
Submission
):
# Submission have complex status handling, so a status change should lead to
# Submission have complex status handling, so a status change should lead to
# more drastic reindexing.
# more drastic reindexing.
self
.
remove_objects_indexes
(
sender
,
instance
.
thread
.
public
())
chain
=
(
self
.
update_instance_indexes
(
sender
,
instance
)
self
.
remove_objects_indexes
.
s
(
sender
,
instance
.
thread
.
public
())
|
self
.
update_instance_indexes
.
s
(
sender
,
instance
)
)
chain
()
else
:
else
:
# Objects such as Reports, Comments, Commentaries, etc. may get rejected. This
# Objects such as Reports, Comments, Commentaries, etc. may get rejected. This
# does not remove them from the index. Therefore, do a complete rebuild_index
# does not remove them from the index. Therefore, do a complete rebuild_index
# action on that specific instance every time the index signal is triggered.
# action on that specific instance every time the index signal is triggered.
self
.
remove_objects_indexes
(
sender
,
[
instance
])
chain
=
(
self
.
update_instance_indexes
(
sender
,
instance
)
self
.
remove_objects_indexes
.
s
(
sender
,
[
instance
])
|
self
.
update_instance_indexes
.
s
(
sender
,
instance
)
)
chain
()
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