mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 00:25:38 -04:00
feat: refactor platforms to support multiple TMDB provider IDs per platform
- Replace `tmdbProviderId` (single int) with a many-to-many `platformTmdbProviders` join table so one platform entry can map to multiple TMDB provider IDs (e.g. a single "Max" platform covers several regional TMDB IDs) - Add `isSubscription` flag to platforms to distinguish subscription services from transactional ones, replacing the old `displayOrder` field in API responses - Add `getPlatformTmdbIds` / `getPlatformTmdbIdMap` helpers in `@sofa/core/platforms` and thread them through discover, explore, and platform list procedures - Replace `providerId: number` with `platformId: string` (UUID) in discover input schema so the client never needs to resolve TMDB IDs - Add `scripts/sync-tmdb-providers.ts` script to pull live provider data from TMDB and update `platforms.json` - Split native title detail availability into separate "Stream" and "Buy or Rent" sections matching the web pattern - Add two new DB migrations for the join table and platform schema changes
This commit is contained in:
@@ -294,7 +294,35 @@ describe("streaming provider", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("returns null when no flatrate provider exists", () => {
|
||||
test("attaches ads-supported streaming provider", () => {
|
||||
const tomorrow = daysFromNow(1);
|
||||
insertTvShow("tv-1", 100, 1, 1, { airDates: [tomorrow] });
|
||||
insertStatus("user-1", "tv-1", "in_progress");
|
||||
const pId = insertPlatform({ id: "p-tubi", name: "Tubi", tmdbProviderId: 73 });
|
||||
insertTitleAvailability("tv-1", pId, { offerType: "ads" });
|
||||
|
||||
const result = getUpcomingFeed("user-1", { days: 7 });
|
||||
expect(result.items[0].streamingProvider).toEqual({
|
||||
platformId: "p-tubi",
|
||||
providerName: "Tubi",
|
||||
logoPath: "/logo.png",
|
||||
});
|
||||
});
|
||||
|
||||
test("prefers flatrate over ads when both exist", () => {
|
||||
const tomorrow = daysFromNow(1);
|
||||
insertTvShow("tv-1", 100, 1, 1, { airDates: [tomorrow] });
|
||||
insertStatus("user-1", "tv-1", "in_progress");
|
||||
const pAds = insertPlatform({ id: "p-tubi", name: "Tubi", tmdbProviderId: 73 });
|
||||
const pFlat = insertPlatform({ id: "p-netflix", name: "Netflix", tmdbProviderId: 8 });
|
||||
insertTitleAvailability("tv-1", pAds, { offerType: "ads" });
|
||||
insertTitleAvailability("tv-1", pFlat, { offerType: "flatrate" });
|
||||
|
||||
const result = getUpcomingFeed("user-1", { days: 7 });
|
||||
expect(result.items[0].streamingProvider!.platformId).toBe("p-netflix");
|
||||
});
|
||||
|
||||
test("returns null when only purchase providers exist", () => {
|
||||
const tomorrow = daysFromNow(1);
|
||||
insertTvShow("tv-1", 100, 1, 1, { airDates: [tomorrow] });
|
||||
insertStatus("user-1", "tv-1", "in_progress");
|
||||
|
||||
Reference in New Issue
Block a user