Skip to content

Commit

Permalink
[Revision] Save history of updated papers via OpenAlex
Browse files Browse the repository at this point in the history
  • Loading branch information
yattias committed Jun 4, 2024
1 parent 7ead27e commit 260ce30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/paper/openalex_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from django.core.exceptions import ValidationError
from django.db import IntegrityError, transaction
from django.db.models import Q
from django.utils.timezone import now
from simple_history.utils import bulk_update_with_history

import utils.sentry as sentry
from user.related_models.author_contribution_summary_model import (
Expand Down Expand Up @@ -162,7 +164,7 @@ def process_openalex_works(works):
fields_to_update = [*PAPER_FIELDS_ALLOWED_TO_UPDATE]
papers_to_update = [paper for paper, _ in update_papers]
try:
Paper.objects.bulk_update(papers_to_update, fields_to_update)
bulk_update_with_history(papers_to_update, Paper, fields_to_update)
except Exception as e:
sentry.log_error(e, message="Failed to bulk update papers")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def handle(self, *args, **kwargs):
)

process_openalex_works([work])
return
elif openalex_author_id:
print("Fetching full author works for author: " + openalex_author_id)

Expand Down

0 comments on commit 260ce30

Please sign in to comment.