Skip to content

Commit

Permalink
refactor: replace repeptive instance querying with a function
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanDavlyatshin committed Jun 19, 2024
1 parent 3c8cbd3 commit d96c723
Showing 1 changed file with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ BEGIN
RETURN (
WITH
InstanceIds AS (
SELECT id
FROM raw_data.instances
WHERE
build_id = _build_id
SELECT * FROM raw_data.get_instance_ids(_build_id)
),
Methods AS (
SELECT * FROM raw_data.get_methods(_build_id)
Expand Down Expand Up @@ -71,10 +68,7 @@ BEGIN
RETURN QUERY
WITH
InstanceIds AS (
SELECT id
FROM raw_data.instances
WHERE
build_id = _build_id
SELECT * FROM raw_data.get_instance_ids(_build_id)
),
Classnames AS (
SELECT classname
Expand Down Expand Up @@ -115,10 +109,7 @@ BEGIN
RETURN QUERY
WITH
InstanceIds AS (
SELECT id
FROM raw_data.instances
WHERE
build_id = _build_id
SELECT * FROM raw_data.get_instance_ids(_build_id)
),
Methods AS (
SELECT * FROM raw_data.get_methods(_build_id)
Expand Down Expand Up @@ -164,10 +155,7 @@ BEGIN
RETURN QUERY
WITH
InstanceIds AS (
SELECT id
FROM raw_data.instances
WHERE
build_id = _build_id
SELECT * FROM raw_data.get_instance_ids(_build_id)
),
Methods AS (
SELECT * FROM raw_data.get_methods(_build_id)
Expand Down Expand Up @@ -463,10 +451,7 @@ BEGIN
RETURN QUERY
WITH
InstanceIds AS (
SELECT id
FROM raw_data.instances
WHERE
build_id = input_build_id
SELECT * FROM raw_data.get_instance_ids(input_build_id)
),
Methods AS (
SELECT * FROM raw_data.get_methods(input_build_id)
Expand Down Expand Up @@ -588,3 +573,19 @@ BEGIN
AND methods.probes_count > 0;
END;
$$ LANGUAGE plpgsql;

-----------------------------------------------------------------

-----------------------------------------------------------------
CREATE OR REPLACE FUNCTION get_instance_ids(input_build_id VARCHAR)
RETURNS TABLE (
id VARCHAR
)
AS $$
BEGIN
RETURN QUERY
SELECT id
FROM raw_data.instances
WHERE build_id = input_build_id;
END;
$$ LANGUAGE plpgsql;

0 comments on commit d96c723

Please sign in to comment.