@@ -55,23 +55,24 @@ def aggregate_checkouts(checkouts_instances: Sequence[Checkouts]) -> None:
5555 for checkout in checkouts_instances
5656 ]
5757
58- with connection .cursor () as cursor :
59- cursor .executemany (
60- """
61- INSERT INTO latest_checkout (
62- checkout_id, origin, tree_name,
63- git_repository_url, git_repository_branch, start_time
58+ if len (values ) > 0 :
59+ with connection .cursor () as cursor :
60+ cursor .executemany (
61+ """
62+ INSERT INTO latest_checkout (
63+ checkout_id, origin, tree_name,
64+ git_repository_url, git_repository_branch, start_time
65+ )
66+ VALUES (%s, %s, %s, %s, %s, %s)
67+ ON CONFLICT (origin, tree_name, git_repository_url, git_repository_branch)
68+ DO UPDATE SET
69+ start_time = EXCLUDED.start_time,
70+ checkout_id = EXCLUDED.checkout_id
71+ WHERE latest_checkout.start_time < EXCLUDED.start_time
72+ """ ,
73+ values ,
6474 )
65- VALUES (%s, %s, %s, %s, %s, %s)
66- ON CONFLICT (origin, tree_name, git_repository_url, git_repository_branch)
67- DO UPDATE SET
68- start_time = EXCLUDED.start_time,
69- checkout_id = EXCLUDED.checkout_id
70- WHERE latest_checkout.start_time < EXCLUDED.start_time
71- """ ,
72- values ,
73- )
74- out (f"inserted { len (checkouts_instances )} checkouts in { time .time () - t0 :.3f} s" )
75+ out (f"inserted { len (checkouts_instances )} checkouts in { time .time () - t0 :.3f} s" )
7576
7677
7778def aggregate_tests (
0 commit comments