-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
circulation: anonymize loans by tasks
A new daily job in place to anonymize loans for all organisations, scheduled for execution at 7h00. Loans are automatically anonymized after updates. Anonymized loans are not returned for public and pro searches. Co-Authored-by: Aly Badr <aly.badr@rero.ch>
- Loading branch information
Aly Badr
committed
Nov 26, 2020
1 parent
7b66c51
commit ec3cd09
Showing
9 changed files
with
265 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# RERO ILS | ||
# Copyright (C) 2020 RERO | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, version 3 of the License. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Celery tasks for loan records.""" | ||
|
||
from __future__ import absolute_import, print_function | ||
|
||
from celery import shared_task | ||
|
||
from ..loans.api import anonymize_loans | ||
from ..organisations.api import Organisation | ||
|
||
|
||
@shared_task(ignore_result=True) | ||
def loan_anonymizer(dbcommit=True, reindex=True): | ||
"""Job to anonymize loans for all organisations. | ||
:param reindex: reindex the records. | ||
:param dbcommit: commit record to database. | ||
:return a count of updated loans. | ||
""" | ||
loans_count = 0 | ||
for org_pid in Organisation.get_all_pids(): | ||
loans_count_org = anonymize_loans( | ||
org_pid=org_pid, dbcommit=dbcommit, reindex=reindex) | ||
loans_count = loans_count + loans_count_org | ||
msg = 'number_of_loans_anonymized: {loans_count}'.format( | ||
loans_count=loans_count | ||
) | ||
|
||
return msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.