From d69e05c5496d310e923989d392b436fbbf9b4299 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 8 Oct 2018 11:18:20 +0200 Subject: Optionnal use of indexes for cached label for finds --- archaeological_finds/models_finds.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'archaeological_finds') diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index bea9b8048..26993aa32 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1382,6 +1382,12 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, profile = get_current_profile() + index = "" + if profile.find_use_index: + index = """|| '-' || + to_char(find_cached_bulk_update.index, 'fm{zeros}') + """.format(zeros=settings.ISHTAR_FINDS_INDEX_ZERO_LEN * "0") + sql = """ UPDATE "archaeological_finds_find" AS f SET cached_label = @@ -1404,8 +1410,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, '{main_ope_prefix}' || find_cached_bulk_update.main_ope_code END - || '-' || - to_char(find_cached_bulk_update.index, 'fm{zeros}') + {index} || '{join}' || find_cached_bulk_update.label @@ -1419,7 +1424,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, """.format(main_ope_prefix=profile.operation_prefix, ope_prefix=profile.default_operation_prefix, join=settings.JOINT, filters=filters, - zeros=settings.ISHTAR_FINDS_INDEX_ZERO_LEN * "0") + index=index) with connection.cursor() as c: c.execute(sql, args) -- cgit v1.2.3