Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,24 @@ def aggregate_checkouts(checkouts_instances: Sequence[Checkouts]) -> None:
for checkout in checkouts_instances
]

with connection.cursor() as cursor:
cursor.executemany(
"""
INSERT INTO latest_checkout (
checkout_id, origin, tree_name,
git_repository_url, git_repository_branch, start_time
if len(values) > 0:
with connection.cursor() as cursor:
cursor.executemany(
"""
INSERT INTO latest_checkout (
checkout_id, origin, tree_name,
git_repository_url, git_repository_branch, start_time
)
VALUES (%s, %s, %s, %s, %s, %s)
ON CONFLICT (origin, tree_name, git_repository_url, git_repository_branch)
DO UPDATE SET
start_time = EXCLUDED.start_time,
checkout_id = EXCLUDED.checkout_id
WHERE latest_checkout.start_time < EXCLUDED.start_time
""",
values,
)
VALUES (%s, %s, %s, %s, %s, %s)
ON CONFLICT (origin, tree_name, git_repository_url, git_repository_branch)
DO UPDATE SET
start_time = EXCLUDED.start_time,
checkout_id = EXCLUDED.checkout_id
WHERE latest_checkout.start_time < EXCLUDED.start_time
""",
values,
)
out(f"inserted {len(checkouts_instances)} checkouts in {time.time() - t0:.3f}s")
out(f"inserted {len(checkouts_instances)} checkouts in {time.time() - t0:.3f}s")


def aggregate_tests(
Expand Down
Loading