Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend_api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Container registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
videoag
backend_api
Commits
a3d0708a
Commit
a3d0708a
authored
9 months ago
by
Simon Künzel
Browse files
Options
Downloads
Patches
Plain Diff
Set media process in migration and migrate videos with source
parent
cdaeb1f9
No related branches found
No related tags found
No related merge requests found
Pipeline
#6730
failed
9 months ago
Stage: build
Stage: test
Pipeline: development
#6731
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
migration.sql
+133
-41
133 additions, 41 deletions
migration.sql
submodules/backend_common_py
+1
-1
1 addition, 1 deletion
submodules/backend_common_py
with
134 additions
and
42 deletions
migration.sql
+
133
−
41
View file @
a3d0708a
...
...
@@ -135,9 +135,21 @@ SELECT
internal
,
downloadable
,
NOT
embedinvisible
,
json_build_object
(),
-- TODO
'inherit'
,
False
,
False
,
NULL
,
NULL
,
True
json_build_object
(
'producers'
,
json_build_array
(
json_build_object
(
'type'
,
'source_file'
,
'tag'
,
''
,
'output_id'
,
'legacy_video'
)
),
'publish_target_ids'
,
json_build_array
(
'legacy_video'
),
'publish_wait_for_full_process'
,
True
),
-- TODO
'inherit'
,
False
,
False
,
NULL
,
NULL
,
-- view_perm
True
-- disable_automatic_media_process_scheduler
FROM
old_data
.
courses_data
;
-- TODO migrate legacy responsible to internal comment
...
...
@@ -196,30 +208,104 @@ DO $$
DECLARE
lecture
record
;
video
record
;
legacy_source
record
;
use_custom_process
bool
;
created_legacy_source_ids
int
[];
custom_process_producers
jsonb
;
custom_process_publish_target_ids
jsonb
;
target_id
int
;
source_tag
text
;
process_target_id
text
;
BEGIN
FOR
lecture
IN
(
SELECT
*
FROM
old_data
.
lectures_data
)
LOOP
FOR
video
IN
(
SELECT
*
FROM
old_data
.
videos_data
WHERE
lecture_id
=
lecture
.
id
)
LOOP
SELECT
array
[]::
int
[]
INTO
created_legacy_source_ids
;
SELECT
jsonb_build_array
()
INTO
custom_process_producers
;
SELECT
jsonb_build_array
()
INTO
custom_process_publish_target_ids
;
SELECT
NULL
INTO
target_id
;
SELECT
NULL
INTO
source_tag
;
SELECT
NULL
INTO
process_target_id
;
SELECT
False
INTO
use_custom_process
;
IF
(
SELECT
COUNT
(
*
)
FROM
old_data
.
videos_data
WHERE
lecture_id
=
lecture
.
id
AND
NOT
deleted
)
>
1
THEN
SELECT
TRUE
INTO
use_custom_process
;
ELSIF
(
SELECT
COUNT
(
*
)
FROM
old_data
.
videos_data
WHERE
lecture_id
=
lecture
.
id
AND
NOT
deleted
AND
source
IS
NOT
NULL
)
>
0
THEN
SELECT
TRUE
INTO
use_custom_process
;
END
IF
;
FOR
video
IN
(
SELECT
*
FROM
old_data
.
videos_data
WHERE
lecture_id
=
lecture
.
id
AND
NOT
deleted
)
LOOP
SELECT
'legacy_video'
INTO
process_target_id
;
SELECT
''
INTO
source_tag
;
IF
use_custom_process
THEN
SELECT
'legacy_video_'
||
video
.
id
::
text
INTO
process_target_id
;
SELECT
'input_'
||
video
.
id
::
text
INTO
source_tag
;
IF
video
.
source
IS
NULL
THEN
SELECT
custom_process_producers
||
jsonb_build_object
(
'type'
,
'source_file'
,
'tag'
,
source_tag
,
'output_id'
,
process_target_id
)
INTO
custom_process_producers
;
ELSE
SELECT
custom_process_producers
||
jsonb_build_object
(
'type'
,
'downscale_video'
,
'source_id'
,
'legacy_source_'
||
video
.
source
::
text
,
'target_vertical_resolution'
,
CASE
WHEN
video
.
video_format
=
32
THEN
1440
WHEN
video
.
video_format
=
10
THEN
360
WHEN
video
.
video_format
=
5
THEN
720
WHEN
video
.
video_format
=
4
THEN
1080
END
,
'output_id'
,
process_target_id
)
INTO
custom_process_producers
;
END
IF
;
SELECT
custom_process_publish_target_ids
||
jsonb_build_array
(
process_target_id
)
INTO
custom_process_publish_target_ids
;
END
IF
;
IF
video
.
source
IS
NULL
THEN
INSERT
INTO
data
.
source_medium
(
file_path
,
sorting_paused_due_to_recent_modification
,
update_time
,
course_id
,
lecture_id
,
sha256
,
tag
,
visible
,
deleted
)
VALUES
(
video
.
path
,
False
,
video
.
time_updated
,
lecture
.
course_id
,
lecture
.
id
,
video
.
id
::
text
,
video
.
visible
,
'0000000000000000000000000000000000000000000000000000000000000000'
,
source_tag
,
video
.
deleted
);
ELSIF
video
.
source
NOT
IN
(
SELECT
*
FROM
unnest
(
created_legacy_source_ids
))
THEN
SELECT
*
INTO
legacy_source
FROM
old_data
.
sources
WHERE
id
=
video
.
source
;
INSERT
INTO
data
.
source_medium
(
file_path
,
sorting_paused_due_to_recent_modification
,
update_time
,
lecture_id
,
sha256
,
tag
,
deleted
)
VALUES
(
legacy_source
.
path
,
False
,
video
.
time_created
,
lecture
.
id
,
'0000000000000000000000000000000000000000000000000000000000000000'
,
'legacy_source_'
||
legacy_source
.
id
::
text
,
False
);
SELECT
custom_process_producers
||
jsonb_build_object
(
'type'
,
'source_file'
,
'tag'
,
'source_input_'
||
legacy_source
.
id
::
text
,
'output_id'
,
'legacy_source_'
||
legacy_source
.
id
::
text
)
INTO
custom_process_producers
;
SELECT
created_legacy_source_ids
||
legacy_source
.
id
INTO
created_legacy_source_ids
;
END
IF
;
INSERT
INTO
data
.
target_medium
(
lecture_id
,
...
...
@@ -233,9 +319,9 @@ DO $$
deleted
)
VALUES
(
lecture
.
id
,
'0123456789012345678901234567890123456789012345678901234567891234
'
,
video
.
id
::
text
,
'0123456789012345678901234567890123456789012345678901234567891234
'
,
'0000000000000000000000000000000000000000000000000000000000000000
'
,
process_target_id
,
'0000000000000000000000000000000000000000000000000000000000000000
'
,
true
,
false
,
video
.
path
,
...
...
@@ -258,9 +344,15 @@ DO $$
video
.
visible
,
video
.
deleted
);
-- TODO ELSE
END
IF
;
END
LOOP
;
IF
use_custom_process
THEN
UPDATE
data
.
lecture
as
lecture_table
SET
media_process
=
json_build_object
(
'producers'
,
custom_process_producers
::
json
,
'publish_target_ids'
,
custom_process_publish_target_ids
::
json
,
'publish_wait_for_full_process'
,
True
)
WHERE
id
=
lecture
.
id
;
END
IF
;
END
LOOP
;
END
;
$$
;
...
...
This diff is collapsed.
Click to expand it.
backend_common_py
@
13f3e789
Compare
b7fbed22
...
13f3e789
Subproject commit
b7fbed22e328de18cb96dd9c982e3e5bcec89c68
Subproject commit
13f3e7890c92284456e8b06c7baf67dfb2c70e30
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment