Skip to content

Commit

Permalink
Merge pull request #94 from Axinom/releases/iteration-73-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanAnushka authored Jun 16, 2023
2 parents ae7307b + 54e8ced commit 9bfe978
Show file tree
Hide file tree
Showing 68 changed files with 3,343 additions and 968 deletions.
4 changes: 2 additions & 2 deletions libs/media-messages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"build:compile": "tsc"
},
"devDependencies": {
"@axinom/mosaic-cli": "0.18.3",
"@axinom/mosaic-message-bus-abstractions": "0.5.4",
"@axinom/mosaic-cli": "0.18.4",
"@axinom/mosaic-message-bus-abstractions": "0.5.5",
"@types/glob": "^7.2.0",
"concurrently": "^5.3.0",
"rimraf": "^3.0.2",
Expand Down
35 changes: 35 additions & 0 deletions libs/media-messages/schemas/payloads/publish/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,27 @@
}
}
},
"cue_point":{
"description":"Cue point metadata.",
"type": "object",
"title":"cue_point",
"additionalProperties": false,
"required":["cue_point_type_key", "time_in_seconds"],
"properties": {
"cue_point_type_key": {
"description": "Key of the cue point type.",
"type": "string"
},
"time_in_seconds": {
"description": "Time in seconds at which the cue point is triggered within the video.",
"type": "number"
},
"value": {
"description": "Additional data associated with the cue point.",
"type": ["string", "null"]
}
}
},
"video": {
"description": "Video metadata.",
"type": "object",
Expand Down Expand Up @@ -254,6 +275,13 @@
"$ref": "#/definitions/video_stream"
}
},
"cue_points": {
"description": "Cue points associated with video.",
"type": "array",
"items": {
"$ref": "#/definitions/cue_point"
}
},
"is_protected": {
"description": "Indicates whether a stream is protected with DRM.",
"type": "boolean"
Expand Down Expand Up @@ -330,6 +358,13 @@
"$ref": "#/definitions/video_stream"
}
},
"cue_points": {
"description": "Cue points associated with video.",
"type": "array",
"items": {
"$ref": "#/definitions/cue_point"
}
},
"is_protected": {
"description": "Indicates whether a stream is protected with DRM.",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,37 @@
}
}
},
"cue_points": {
"description": "Cue points associated with video.",
"type": "array",
"items": {
"description": "Cue point metadata.",
"type": "object",
"title": "cue_point",
"additionalProperties": false,
"required": [
"cue_point_type_key",
"time_in_seconds"
],
"properties": {
"cue_point_type_key": {
"description": "Key of the cue point type.",
"type": "string"
},
"time_in_seconds": {
"description": "Time in seconds at which the cue point is triggered within the video.",
"type": "number"
},
"value": {
"description": "Additional data associated with the cue point.",
"type": [
"string",
"null"
]
}
}
}
},
"is_protected": {
"description": "Indicates whether a stream is protected with DRM.",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,37 @@
}
}
},
"cue_points": {
"description": "Cue points associated with video.",
"type": "array",
"items": {
"description": "Cue point metadata.",
"type": "object",
"title": "cue_point",
"additionalProperties": false,
"required": [
"cue_point_type_key",
"time_in_seconds"
],
"properties": {
"cue_point_type_key": {
"description": "Key of the cue point type.",
"type": "string"
},
"time_in_seconds": {
"description": "Time in seconds at which the cue point is triggered within the video.",
"type": "number"
},
"value": {
"description": "Additional data associated with the cue point.",
"type": [
"string",
"null"
]
}
}
}
},
"is_protected": {
"description": "Indicates whether a stream is protected with DRM.",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,37 @@
}
}
},
"cue_points": {
"description": "Cue points associated with video.",
"type": "array",
"items": {
"description": "Cue point metadata.",
"type": "object",
"title": "cue_point",
"additionalProperties": false,
"required": [
"cue_point_type_key",
"time_in_seconds"
],
"properties": {
"cue_point_type_key": {
"description": "Key of the cue point type.",
"type": "string"
},
"time_in_seconds": {
"description": "Time in seconds at which the cue point is triggered within the video.",
"type": "number"
},
"value": {
"description": "Additional data associated with the cue point.",
"type": [
"string",
"null"
]
}
}
}
},
"is_protected": {
"description": "Indicates whether a stream is protected with DRM.",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,37 @@
}
}
},
"cue_points": {
"description": "Cue points associated with video.",
"type": "array",
"items": {
"description": "Cue point metadata.",
"type": "object",
"title": "cue_point",
"additionalProperties": false,
"required": [
"cue_point_type_key",
"time_in_seconds"
],
"properties": {
"cue_point_type_key": {
"description": "Key of the cue point type.",
"type": "string"
},
"time_in_seconds": {
"description": "Time in seconds at which the cue point is triggered within the video.",
"type": "number"
},
"value": {
"description": "Additional data associated with the cue point.",
"type": [
"string",
"null"
]
}
}
}
},
"is_protected": {
"description": "Indicates whether a stream is protected with DRM.",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Cue point metadata.
*/
export interface CuePoint {
/**
* Key of the cue point type.
*/
cue_point_type_key: string;
/**
* Time in seconds at which the cue point is triggered within the video.
*/
time_in_seconds: number;
/**
* Additional data associated with the cue point.
*/
value?: string | null;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './cue-point';
export * from './format';
export * from './genre';
export * from './image';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CuePoint } from './cue-point';
import { Format } from './format';
import { VideoStream } from './video-stream';
import { VideoUsageType } from './video-usage-type';
Expand Down Expand Up @@ -41,6 +42,10 @@ export interface Video {
* Video Streams
*/
video_streams?: Array<VideoStream>;
/**
* Cue points associated with video.
*/
cue_points?: Array<CuePoint>;
/**
* Indicates whether a stream is protected with DRM.
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"build:media-workflows:prod": "yarn && wsrun -trm -p media-workflows -c build && pilet pack services/media/workflows"
},
"devDependencies": {
"@axinom/mosaic-cli": "0.18.3",
"@axinom/mosaic-cli": "0.18.4",
"@dbeining/react-atom": "^4.1.21",
"@jest/globals": "^29.1.2",
"@libre/atom": "^1.3.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--! Previous: sha1:ac06834674084dc237f4ac9168dfc87d7e85931c
--! Hash: sha1:75abcc71fe97b30f08804271eb66200151400e8c
--! Message: add-video-cue-points-tables

DROP TABLE IF EXISTS app_public.movie_video_cue_points CASCADE;
CREATE TABLE app_public.movie_video_cue_points(
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
movie_video_id INTEGER REFERENCES movie_videos ON DELETE CASCADE,
cue_point_type_key TEXT NOT NULL,
time_in_seconds NUMERIC(13,5) NOT NULL,
value TEXT
);
SELECT ax_define.define_index('movie_video_id', 'movie_video_cue_points', 'app_public');


DROP TABLE IF EXISTS app_public.episode_video_cue_points CASCADE;
CREATE TABLE app_public.episode_video_cue_points(
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
episode_video_id INTEGER REFERENCES episode_videos ON DELETE CASCADE,
cue_point_type_key TEXT NOT NULL,
time_in_seconds NUMERIC(13,5) NOT NULL,
value TEXT
);
SELECT ax_define.define_index('episode_video_id', 'episode_video_cue_points', 'app_public');


DROP TABLE IF EXISTS app_public.season_video_cue_points CASCADE;
CREATE TABLE app_public.season_video_cue_points(
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
season_video_id INTEGER REFERENCES season_videos ON DELETE CASCADE,
cue_point_type_key TEXT NOT NULL,
time_in_seconds NUMERIC(13,5) NOT NULL,
value TEXT
);
SELECT ax_define.define_index('season_video_id', 'season_video_cue_points', 'app_public');


DROP TABLE IF EXISTS app_public.tvshow_video_cue_points CASCADE;
CREATE TABLE app_public.tvshow_video_cue_points(
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
tvshow_video_id INTEGER REFERENCES tvshow_videos ON DELETE CASCADE,
cue_point_type_key TEXT NOT NULL,
time_in_seconds NUMERIC(13,5) NOT NULL,
value TEXT
);
SELECT ax_define.define_index('tvshow_video_id', 'tvshow_video_cue_points', 'app_public');

GRANT SELECT, INSERT, UPDATE, DELETE ON
app_public.movie_video_cue_points,
app_public.episode_video_cue_points,
app_public.season_video_cue_points,
app_public.tvshow_video_cue_points TO ":DATABASE_GQL_ROLE";
8 changes: 4 additions & 4 deletions services/catalog/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"util:define-func-migration": "yarn mosaic generate-define-func-migration"
},
"dependencies": {
"@axinom/mosaic-db-common": "0.24.3",
"@axinom/mosaic-message-bus": "0.14.4",
"@axinom/mosaic-message-bus-abstractions": "0.5.4",
"@axinom/mosaic-service-common": "0.32.0",
"@axinom/mosaic-db-common": "0.25.0",
"@axinom/mosaic-message-bus": "0.14.5",
"@axinom/mosaic-message-bus-abstractions": "0.5.5",
"@axinom/mosaic-service-common": "0.33.0",
"@graphile-contrib/pg-simplify-inflector": "^6.1.0",
"add": "^2.0.6",
"amqplib": "^0.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('MoviePublishEventHandler', () => {
const expectedVideos = message.videos.map((video) => {
return Object.fromEntries(
Object.entries(video).filter(
([key, _value]) => key !== 'video_streams',
([key, _value]) => key !== 'video_streams' && key !== 'cue_points',
),
);
});
Expand All @@ -88,6 +88,15 @@ describe('MoviePublishEventHandler', () => {
message.videos[0].video_streams!,
);

const videoCuePoints = (
await select('movie_video_cue_points', {
movie_video_id: videos[0].id,
}).run(ctx.ownerPool)
).map(({ id, movie_video_id, ...cuePoint }) => cuePoint);
expect(videoCuePoints).toIncludeSameMembers(
message.videos[0].cue_points!,
);

const licenses = await select('movie_licenses', {
movie_id: message.content_id,
}).run(ctx.ownerPool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as db from 'zapatos/db';
import {
movie_images,
movie_licenses,
movie_video_cue_points,
movie_video_streams,
} from 'zapatos/schema';
import { Config } from '../../../common';
Expand Down Expand Up @@ -49,7 +50,7 @@ export class MoviePublishedEventHandler extends MessageHandler<MoviePublishedEve
if (payload.videos) {
for (const video of payload.videos) {
// Remove `video_streams` array from `video` object
const { video_streams, ...videoToInsert } = video;
const { video_streams, cue_points, ...videoToInsert } = video;

const movieVideo = await db
.insert('movie_videos', {
Expand All @@ -71,6 +72,20 @@ export class MoviePublishedEventHandler extends MessageHandler<MoviePublishedEve
)
.run(txnClient);
}

if (cue_points !== undefined) {
await db
.insert(
'movie_video_cue_points',
cue_points.map(
(cuePoint): movie_video_cue_points.Insertable => ({
movie_video_id: movieVideo.id,
...cuePoint,
}),
),
)
.run(txnClient);
}
}
}

Expand Down
Loading

0 comments on commit 9bfe978

Please sign in to comment.