clipper/backend/sql/queries.sql

35 lines
1.4 KiB
SQL

-- name: GetMediaSet :one
SELECT * FROM media_sets WHERE id = $1;
-- name: GetMediaSetByYoutubeID :one
SELECT * FROM media_sets WHERE youtube_id = $1;
-- name: CreateMediaSet :one
INSERT INTO media_sets (youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_sample_rate, audio_content_length, audio_encoded_mime_type, video_youtube_itag, video_content_length, video_mime_type, video_duration_nanos, created_at, updated_at)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, NOW(), NOW())
RETURNING *;
-- name: SetRawAudioUploaded :one
UPDATE media_sets
SET audio_raw_s3_bucket = $2, audio_raw_s3_key = $3, audio_frames = $4, audio_raw_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1
RETURNING *;
-- name: SetEncodedAudioUploaded :one
UPDATE media_sets
SET audio_encoded_s3_bucket = $2, audio_encoded_s3_key = $3, audio_encoded_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1
RETURNING *;
-- name: SetVideoUploaded :one
UPDATE media_sets
SET video_s3_bucket = $2, video_s3_key = $3, video_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1
RETURNING *;
-- name: SetVideoThumbnailUploaded :one
UPDATE media_sets
SET video_thumbnail_width = $2, video_thumbnail_height = $3, video_thumbnail_mime_type = $4, video_thumbnail_s3_bucket = $5, video_thumbnail_s3_key = $6, video_thumbnail_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1
RETURNING *;