Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ jobs:
- 'dev_env/Dockerfile.init'
- 'dev_env/init-db.mjs'
- 'dev_env/package.init.json'
- 'dev_env/seed_db.sql'
- 'shared/database/src/migrations/**'
- 'shared/database/src/schema.ts'
docs-only:
- '**/*.md'
- 'docs/**'
Expand Down
10 changes: 5 additions & 5 deletions apps/backend/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ components:
type: integer
show_id:
type: integer
rotation_play_freq:
rotation_bin:
type: string
message:
type: string
Expand Down Expand Up @@ -183,7 +183,7 @@ components:
type: string
genre_name:
type: string
play_freq:
rotation_bin:
type: string
nullable: true
add_date:
Expand Down Expand Up @@ -219,7 +219,7 @@ components:
add_date:
type: string
format: date
play_freq:
rotation_bin:
type: string
enum: ['S', 'L', 'M', 'H']
kill_date:
Expand All @@ -231,11 +231,11 @@ components:

NewRotationRequest:
type: object
required: ['album_id', 'play_freq']
required: ['album_id', 'rotation_bin']
properties:
album_id:
type: integer
play_freq:
rotation_bin:
type: string
enum: ['S', 'L', 'M', 'H']
kill_date:
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/controllers/flowsheet.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface IFSEntryMetadata {
}

export interface IFSEntry extends FSEntry {
rotation_play_freq: string | null;
rotation_bin: string | null;
metadata: IFSEntryMetadata;
}

Expand Down
4 changes: 2 additions & 2 deletions apps/backend/controllers/library.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export const getRotation: RequestHandler = async (req, res, next) => {

export type RotationAddRequest = Omit<NewRotationRelease, 'id'>;
export const addRotation: RequestHandler<object, unknown, NewRotationRelease> = async (req, res, next) => {
if (req.body.album_id === undefined || req.body.play_freq === undefined) {
res.status(400).send('Missing Parameters: album_id or play_freq');
if (req.body.album_id === undefined || req.body.rotation_bin === undefined) {
res.status(400).send('Missing Parameters: album_id or rotation_bin');
} else {
try {
const rotationRelease: RotationRelease = await libraryService.addToRotation(req.body);
Expand Down
8 changes: 4 additions & 4 deletions apps/backend/services/flowsheet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const FSEntryFieldsRaw = {
track_title: flowsheet.track_title,
record_label: flowsheet.record_label,
rotation_id: flowsheet.rotation_id,
rotation_play_freq: rotation.play_freq,
rotation_bin: rotation.rotation_bin,
request_flag: flowsheet.request_flag,
message: flowsheet.message,
play_order: flowsheet.play_order,
Expand Down Expand Up @@ -81,7 +81,7 @@ type FSEntryRaw = {
track_title: string | null;
record_label: string | null;
rotation_id: number | null;
rotation_play_freq: string | null;
rotation_bin: string | null;
request_flag: boolean | null;
message: string | null;
play_order: number | null;
Expand Down Expand Up @@ -109,7 +109,7 @@ const transformToIFSEntry = (raw: FSEntryRaw): IFSEntry => ({
track_title: raw.track_title,
record_label: raw.record_label,
rotation_id: raw.rotation_id,
rotation_play_freq: raw.rotation_play_freq,
rotation_bin: raw.rotation_bin,
request_flag: raw.request_flag ?? false,
message: raw.message,
play_order: raw.play_order ?? 0,
Expand Down Expand Up @@ -602,7 +602,7 @@ export const transformToV2 = (entry: IFSEntry): Record<string, unknown> => {
track_title: entry.track_title,
record_label: entry.record_label,
request_flag: entry.request_flag,
rotation_play_freq: entry.rotation_play_freq,
rotation_bin: entry.rotation_bin,
artwork_url: entry.metadata?.artwork_url ?? null,
discogs_url: entry.metadata?.discogs_url ?? null,
release_year: entry.metadata?.release_year ?? null,
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/services/library.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface Rotation {
rotation_id: number;
add_date: Date;
rotation_add_date: string;
play_freq: 'S' | 'L' | 'M' | 'H';
rotation_bin: 'S' | 'L' | 'M' | 'H';
rotation_kill_date: string | null;
plays: number;
}
Expand All @@ -64,7 +64,7 @@ export const getRotationFromDB = async (): Promise<Rotation[]> => {
rotation_id: rotation.id,
add_date: library.add_date,
rotation_add_date: rotation.add_date,
play_freq: rotation.play_freq,
rotation_bin: rotation.rotation_bin,
rotation_kill_date: rotation.kill_date,
plays: library.plays,
})
Expand Down
4 changes: 2 additions & 2 deletions dev_env/seed_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ INSERT INTO wxyc_schema.library(
artist_id, genre_id, format_id, album_title, code_number)
VALUES (6, 1, 2, 'Homogenic', 1);

INSERT INTO wxyc_schema.rotation(album_id, play_freq) VALUES (1, 'L');
INSERT INTO wxyc_schema.rotation(album_id, rotation_bin) VALUES (1, 'L');

-- Add album 4 to rotation for metadata.spec.js rotation tests
INSERT INTO wxyc_schema.rotation(album_id, play_freq) VALUES (4, 'M');
INSERT INTO wxyc_schema.rotation(album_id, rotation_bin) VALUES (4, 'M');
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-- Rename play_freq column to rotation_bin on the rotation table.
-- The enum type (freq_enum) stays the same; only the column name changes.

-- Drop views that reference the column
DROP VIEW IF EXISTS "wxyc_schema"."library_artist_view";
--> statement-breakpoint
DROP VIEW IF EXISTS "wxyc_schema"."rotation_library_view";
--> statement-breakpoint

-- Rename the column
ALTER TABLE "wxyc_schema"."rotation" RENAME COLUMN "play_freq" TO "rotation_bin";
--> statement-breakpoint

-- Recreate library_artist_view with the new column name
CREATE VIEW "wxyc_schema"."library_artist_view" AS
SELECT "wxyc_schema"."library"."id",
"wxyc_schema"."artists"."code_letters",
"wxyc_schema"."artists"."code_artist_number",
"wxyc_schema"."library"."code_number",
"wxyc_schema"."artists"."artist_name",
"wxyc_schema"."library"."album_title",
"wxyc_schema"."format"."format_name",
"wxyc_schema"."genres"."genre_name",
"wxyc_schema"."rotation"."rotation_bin",
"wxyc_schema"."library"."add_date",
"wxyc_schema"."library"."label"
FROM "wxyc_schema"."library"
INNER JOIN "wxyc_schema"."artists" ON "wxyc_schema"."artists"."id" = "wxyc_schema"."library"."artist_id"
INNER JOIN "wxyc_schema"."format" ON "wxyc_schema"."format"."id" = "wxyc_schema"."library"."format_id"
INNER JOIN "wxyc_schema"."genres" ON "wxyc_schema"."genres"."id" = "wxyc_schema"."library"."genre_id"
LEFT JOIN "wxyc_schema"."rotation"
ON "wxyc_schema"."rotation"."album_id" = "wxyc_schema"."library"."id"
AND ("wxyc_schema"."rotation"."kill_date" < CURRENT_DATE OR "wxyc_schema"."rotation"."kill_date" IS NULL);
--> statement-breakpoint

-- Recreate rotation_library_view with the new column name
CREATE VIEW "wxyc_schema"."rotation_library_view" AS
SELECT "wxyc_schema"."library"."id",
"wxyc_schema"."rotation"."id" AS "rotation_id",
"wxyc_schema"."library"."label",
"wxyc_schema"."rotation"."rotation_bin",
"wxyc_schema"."library"."album_title",
"wxyc_schema"."artists"."artist_name",
"wxyc_schema"."rotation"."kill_date"
FROM "wxyc_schema"."library"
INNER JOIN "wxyc_schema"."rotation" ON "wxyc_schema"."library"."id" = "wxyc_schema"."rotation"."album_id"
INNER JOIN "wxyc_schema"."artists" ON "wxyc_schema"."artists"."id" = "wxyc_schema"."library"."artist_id";
Loading
Loading