[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/18: Handle conflicts when inserting lint warning message sets
From: |
Christopher Baines |
Subject: |
05/18: Handle conflicts when inserting lint warning message sets |
Date: |
Mon, 16 Dec 2024 04:02:40 -0500 (EST) |
cbaines pushed a commit to branch master
in repository data-service.
commit 930169751ca748ee3a604a3942a05a1d1b28a7b6
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Fri Nov 29 13:48:10 2024 +0000
Handle conflicts when inserting lint warning message sets
---
guix-data-service/model/lint-warning-message.scm | 53 ++++++++++++------------
1 file changed, 26 insertions(+), 27 deletions(-)
diff --git a/guix-data-service/model/lint-warning-message.scm
b/guix-data-service/model/lint-warning-message.scm
index 72a8617..7dd0e28 100644
--- a/guix-data-service/model/lint-warning-message.scm
+++ b/guix-data-service/model/lint-warning-message.scm
@@ -35,22 +35,6 @@
(list locale message)))
messages-by-locale)))
-(define (insert-lint-warning-message-set conn lint-message-ids)
- (let ((query
- (string-append
- "INSERT INTO lint_warning_message_sets (message_ids) VALUES "
- (string-append
- "('{"
- (string-join
- (map number->string
- (sort lint-message-ids <))
- ", ")
- "}')")
- " RETURNING id")))
-
- (match (exec-query conn query)
- (((id)) id))))
-
(define (lint-warning-message-data->lint-warning-message-set-id
conn
messages-by-locale)
@@ -58,21 +42,36 @@
(let* ((lint-warning-message-ids
(lint-warning-message-data->lint-warning-message-ids
conn messages-by-locale))
- (lint-message-set-id
- (exec-query
- conn
- (string-append
- "SELECT id FROM lint_warning_message_sets "
- "WHERE message_ids = ARRAY["
- (string-join (map number->string
- (sort lint-warning-message-ids <)) ", ")
- "]"))))
+ (select-query
+ (string-append
+ "SELECT id FROM lint_warning_message_sets "
+ "WHERE message_ids = ARRAY["
+ (string-join (map number->string
+ (sort lint-warning-message-ids <)) ", ")
+ "]")))
(string->number
- (match lint-message-set-id
+ (match (exec-query conn select-query)
(((id)) id)
(()
- (insert-lint-warning-message-set conn lint-warning-message-ids))))))
+ (match (exec-query
+ conn
+ (string-append
+ "
+INSERT INTO lint_warning_message_sets (message_ids) VALUES "
+ (string-append
+ "('{"
+ (string-join
+ (map number->string
+ (sort lint-warning-message-ids <))
+ ", ")
+ "}')") "
+ON CONFLICT DO NOTHING RETURNING id"))
+ (((id)) id)
+ (()
+ (match (exec-query conn select-query)
+ (((id)) id)))))))))
+
(define (lint-warning-message-locales-for-revision conn commit-hash)
(exec-query
- branch master updated (64aeeff -> 62d6b59), Christopher Baines, 2024/12/16
- 10/18: Fix wrong number of values from channel-derivations-by-system->guix-store-item, Christopher Baines, 2024/12/16
- 12/18: Fix hash display for formatted derivations, Christopher Baines, 2024/12/16
- 09/18: Rework loading revision data, Christopher Baines, 2024/12/16
- 06/18: Memoize field-can-be-null?, Christopher Baines, 2024/12/16
- 02/18: Move log message, Christopher Baines, 2024/12/16
- 15/18: Add a comment, Christopher Baines, 2024/12/16
- 13/18: Avoid getting the load-new-guix-revision-inserts lock twice, Christopher Baines, 2024/12/16
- 04/18: Use insert-missing-data-and-return-all-ids for locations, Christopher Baines, 2024/12/16
- 14/18: Log differently when using the load-new-guix-revision-inserts lock, Christopher Baines, 2024/12/16
- 05/18: Handle conflicts when inserting lint warning message sets,
Christopher Baines <=
- 18/18: Make build_servers.id just generated by default, Christopher Baines, 2024/12/16
- 11/18: Improve some query formatting, Christopher Baines, 2024/12/16
- 07/18: Handle conflicts in insert-missing-data-and-return-all-ids, Christopher Baines, 2024/12/16
- 08/18: Improve null handling, Christopher Baines, 2024/12/16
- 03/18: Add in call-with-worker-thread to try to avoid sort problems, Christopher Baines, 2024/12/16
- 17/18: Add utility functions for configuring the database, Christopher Baines, 2024/12/16
- 16/18: Use knots, Christopher Baines, 2024/12/16
- 01/18: Don't lookup #f in the hash table, Christopher Baines, 2024/12/16