[WIP] feat(issues): add next checkout after last seen - #2054
[WIP] feat(issues): add next checkout after last seen#2054felipebergamin wants to merge 2 commits into
Conversation
Expose the earliest later checkout on the same tree in issue extras, using start_time since parent-commit hierarchy is unavailable (kernelci#1958).
Add a Next Checkout section after last-seen incident data using the extras payload (kernelci#1958).
alanpeixinho
left a comment
There was a problem hiding this comment.
looking great so far
| """ | ||
|
|
||
| with connection.cursor() as cursor: | ||
| cursor.execute(query, params) |
There was a problem hiding this comment.
might be worth adding cache here
|
|
||
| query = """ | ||
| WITH last_seen AS ( | ||
| SELECT DISTINCT ON (IC.issue_id) |
There was a problem hiding this comment.
we might be able to be faster using a subquery to get strictly the next checkout on subquery.
This suggestion was made on cursor, so we need to validate if it is correct.
WITH last_seen AS (
SELECT DISTINCT ON (IC.issue_id)
IC.issue_id,
C.id AS last_checkout_id,
C.start_time AS last_start_time,
C.origin,
C.tree_name,
C.git_repository_url,
C.git_repository_branch
FROM
incidents IC
LEFT JOIN tests T ON IC.test_id = T.id
LEFT JOIN builds B ON (
IC.build_id = B.id
OR T.build_id = B.id
)
LEFT JOIN checkouts C ON B.checkout_id = C.id
WHERE
IC.issue_id = ANY(ARRAY['issue-id-1', 'issue-id-2']) -- %(issue_id_list)s
ORDER BY
IC.issue_id,
IC.issue_version DESC,
IC._timestamp DESC
)
SELECT
LS.issue_id,
C.id AS checkout_id,
C.start_time,
C.git_commit_hash,
C.git_commit_name,
C.git_repository_url,
C.git_repository_branch,
C.tree_name,
C.origin
FROM
last_seen LS
CROSS JOIN LATERAL (
SELECT
C.id,
C.start_time,
C.git_commit_hash,
C.git_commit_name,
C.git_repository_url,
C.git_repository_branch,
C.tree_name,
C.origin
FROM
checkouts C
WHERE
C.origin = LS.origin
AND C.tree_name IS NOT DISTINCT FROM LS.tree_name
AND C.git_repository_url IS NOT DISTINCT FROM LS.git_repository_url
AND C.git_repository_branch IS NOT DISTINCT FROM LS.git_repository_branch
AND C.start_time > LS.last_start_time
ORDER BY
C.start_time ASC,
C.id ASC
LIMIT 1
) C
WHERE
LS.last_checkout_id IS NOT NULL
AND LS.last_start_time IS NOT NULL;
In simple tests it was reasonably faster. But at the same time, the issues query is not a slow one. So fell free to ignore if it can make the endpoint more complex.
### Original
Planning:
Buffers: shared hit=53 read=1
Planning Time: 1.421 ms
Execution Time: 1499.004 ms
### Subquery
Planning:
Buffers: shared hit=54
Planning Time: 1.093 ms
Execution Time: 73.985 ms
| }); | ||
| }, [data?.extra, formatMessage, issueId]); | ||
|
|
||
| const nextCheckoutSection: ISection | undefined = useMemo(() => { |
There was a problem hiding this comment.
Unrelated to this task. But at some point I think we need to do a full layout improvement on this page.
This presented information is already quite sparse, and could find a better way to organize it.
Again, for this specific task, we should focus on just providing the information.
Expose the earliest later checkout on the same tree in issue extras, using start_time since parent-commit hierarchy is unavailable (#1958).
Visual reference