-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1694 from dmitry-sinina/_fix_codec_ordering
fix codec ordering in new codec group loading logic
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
class FixLoadCodecGroups < ActiveRecord::Migration[7.2] | ||
def up | ||
execute %q{ | ||
CREATE OR REPLACE FUNCTION switch22.load_codec_groups() | ||
RETURNS TABLE(id integer, ptime smallint, codecs json) | ||
LANGUAGE plpgsql | ||
COST 10 | ||
AS $function$ | ||
BEGIN | ||
RETURN QUERY | ||
SELECT | ||
cg.id, | ||
cg.ptime, | ||
json_agg(json_build_object( | ||
'id', c.id, | ||
'name', c.name, | ||
'priority', cgc.priority, | ||
'dynamic_payload_type', cgc.dynamic_payload_type, | ||
'format_parameters', cgc.format_parameters | ||
) ORDER BY cgc.priority DESC ) as codecs | ||
FROM class4.codec_groups cg | ||
LEFT JOIN class4.codec_group_codecs cgc ON cg.id = cgc.codec_group_id | ||
LEFT JOIN class4.codecs c ON cgc.codec_id=c.id | ||
GROUP BY cg.id; | ||
END; | ||
$function$; | ||
} | ||
end | ||
|
||
|
||
def down | ||
execute %q{ | ||
CREATE OR REPLACE FUNCTION switch22.load_codec_groups() | ||
RETURNS TABLE(id integer, ptime smallint, codecs json) | ||
LANGUAGE plpgsql | ||
COST 10 | ||
AS $function$ | ||
BEGIN | ||
RETURN QUERY | ||
SELECT | ||
cg.id, | ||
cg.ptime, | ||
json_agg(json_build_object( | ||
'id', c.id, | ||
'name', c.name, | ||
'priority', cgc.priority, | ||
'dynamic_payload_type', cgc.dynamic_payload_type, | ||
'format_parameters', cgc.format_parameters | ||
)) as codecs | ||
FROM class4.codec_groups cg | ||
LEFT JOIN class4.codec_group_codecs cgc ON cg.id = cgc.codec_group_id | ||
LEFT JOIN class4.codecs c ON cgc.codec_id=c.id | ||
GROUP BY cg.id; | ||
END; | ||
$function$; | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters