From 12b99cfcf6080841eeddee43823cdaff6259dc19 Mon Sep 17 00:00:00 2001 From: Jose Javier Merchante Date: Thu, 8 Aug 2024 10:25:37 +0200 Subject: [PATCH] Fix identity refresh bug for all roles This commit resolves an issue where role identities (like `reviewed_by` or `merged_by` among others) were not refreshed. The bug occurred because the queries to OpenSearch filtered items in which `author_uuid` was the individual pk, but not when the `_uuid` was the individual pk. That causes many items that contain the `_uuid` but not the `author_uuid` not to be refreshed. For example, the `Author` role was not affected because it matched `author_uuid`, but roles like `reviewed_by` did not match and were missed. Signed-off-by: Jose Javier Merchante --- .../identity-refresh-bug-for-some-items.yml | 12 ++++++++++++ sirmordred/task_enrich.py | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 releases/unreleased/identity-refresh-bug-for-some-items.yml diff --git a/releases/unreleased/identity-refresh-bug-for-some-items.yml b/releases/unreleased/identity-refresh-bug-for-some-items.yml new file mode 100644 index 00000000..04765d5b --- /dev/null +++ b/releases/unreleased/identity-refresh-bug-for-some-items.yml @@ -0,0 +1,12 @@ +--- +title: Identity refresh bug for some items +category: fixed +author: Jose Javier Merchante +issue: null +notes: > + Fix issue where some fields were not refreshed. + The bug occurred because the queries to OpenSearch filtered + items in which `author_uuid` was the individual pk, but not + when the `_uuid` was the individual pk. That causes many + items that contain the `_uuid` but not the `author_uuid` + not to be refreshed. diff --git a/sirmordred/task_enrich.py b/sirmordred/task_enrich.py index 4d27e755..bb107e43 100644 --- a/sirmordred/task_enrich.py +++ b/sirmordred/task_enrich.py @@ -249,12 +249,16 @@ def __autorefresh(self, enrich_backend, studies=False): next_autorefresh = self.__update_last_autorefresh() logger.debug('Getting last modified identities from SH since %s for %s', after, self.backend_section) + author_fields = ["author_uuid"] + for role in enrich_backend.roles: + author_fields.append(role + '_uuid') try: meta_fields = enrich_backend.meta_fields author_fields += meta_fields except AttributeError: pass + logger.debug("Refreshing identity ids for %s", self.backend_section) total = 0 time_start = datetime.now()