Add a Cloud W17 destination beside Cloud M19 for the women's under-17 games.
It uses the organisation's existing FPA Nextcloud account and sends into Seleções Nacionais/W17, only when the photographer picks it.
This commit is contained in:
1 parent
413983a057
commit
cb2b887a48
8 files changed
+62
-9
No files matched your search
@@ -4,13 +4,19 @@ import type { Db } from "../db.js";
|
||||
/** The destination photographers pick to send an under-19 national game to the FPA cloud. */
|
||||
export const CLOUD_M19_TARGET = "Cloud M19";
|
||||
|
||||
/** The same kind of destination for the women's under-17 side. */
|
||||
export const CLOUD_W17_TARGET = "Cloud W17";
|
||||
|
||||
/**
|
||||
* One Nextcloud destination per organisation that already delivers club games to cloud.photoreport.pt.
|
||||
* Same account and file name as that destination; the folder is Seleções Nacionais/M19.
|
||||
* Same account and file name as that destination; the folder is under Seleções Nacionais.
|
||||
* It does not send on arrival: the photographer chooses it for this game.
|
||||
* Returns how many destinations were created.
|
||||
*/
|
||||
export async function ensureCloudM19Target(db: Db): Promise<number> {
|
||||
async function ensureNationalCloudTarget(
|
||||
db: Db,
|
||||
target: { name: string; folder: string; fileName: string },
|
||||
): Promise<number> {
|
||||
const sources = await db.deliveryTarget.findMany({
|
||||
where: {
|
||||
kind: "NEXTCLOUD",
|
||||
@@ -31,21 +37,21 @@ export async function ensureCloudM19Target(db: Db): Promise<number> {
|
||||
if (seen.has(source.organizationId)) continue;
|
||||
seen.add(source.organizationId);
|
||||
const exists = await db.deliveryTarget.findUnique({
|
||||
where: { organizationId_name: { organizationId: source.organizationId, name: CLOUD_M19_TARGET } },
|
||||
where: { organizationId_name: { organizationId: source.organizationId, name: target.name } },
|
||||
select: { id: true },
|
||||
});
|
||||
if (exists) continue;
|
||||
await db.deliveryTarget.create({
|
||||
data: {
|
||||
organizationId: source.organizationId,
|
||||
name: CLOUD_M19_TARGET,
|
||||
name: target.name,
|
||||
kind: source.kind,
|
||||
baseUrl: source.baseUrl,
|
||||
username: source.username,
|
||||
secretEnc: source.secretEnc,
|
||||
hostFingerprint: source.hostFingerprint,
|
||||
folderTemplate: DESTINATION_EXAMPLES.fpaM19.folder,
|
||||
fileNameTemplate: source.fileNameTemplate || DESTINATION_EXAMPLES.fpaM19.fileName,
|
||||
folderTemplate: target.folder,
|
||||
fileNameTemplate: source.fileNameTemplate || target.fileName,
|
||||
longEdge: source.longEdge,
|
||||
jpegQuality: source.jpegQuality,
|
||||
sharpen: source.sharpen,
|
||||
@@ -64,3 +70,19 @@ export async function ensureCloudM19Target(db: Db): Promise<number> {
|
||||
}
|
||||
return created;
|
||||
}
|
||||
|
||||
export function ensureCloudM19Target(db: Db): Promise<number> {
|
||||
return ensureNationalCloudTarget(db, {
|
||||
name: CLOUD_M19_TARGET,
|
||||
folder: DESTINATION_EXAMPLES.fpaM19.folder,
|
||||
fileName: DESTINATION_EXAMPLES.fpaM19.fileName,
|
||||
});
|
||||
}
|
||||
|
||||
export function ensureCloudW17Target(db: Db): Promise<number> {
|
||||
return ensureNationalCloudTarget(db, {
|
||||
name: CLOUD_W17_TARGET,
|
||||
folder: DESTINATION_EXAMPLES.fpaW17.folder,
|
||||
fileName: DESTINATION_EXAMPLES.fpaW17.fileName,
|
||||
});
|
||||
}
|
||||
@@ -17,6 +17,7 @@ describe("selectionKey", () => {
|
||||
expect(selectionKey(["Seleção Nacional sub-19 Masculina"])).toBe("m19");
|
||||
expect(selectionKey(["Portugal", "Espanha", "sub-19"])).toBe("m19");
|
||||
expect(selectionKey(["Seleção Nacional sub-19 feminina"])).toBe("w19");
|
||||
expect(selectionKey(["/FPA/Fotos/2026_2027/Seleções Nacionais/W17/20261127 - POR x ITA"])).toBe("w17");
|
||||
});
|
||||
|
||||
it("names no team for a club game, a gala, or a gathering", () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ensureCloudM19Target } from "./delivery/fpa-m19.js";
|
||||
import { ensureCloudM19Target, ensureCloudW17Target } from "./delivery/fpa-m19.js";
|
||||
import { preferIpv4 } from "./lib/prefer-ipv4.js";
|
||||
import { buildApp, reporterFor } from "./app.js";
|
||||
import { loadConfig } from "./config.js";
|
||||
@@ -21,6 +21,7 @@ process.on("SIGTERM", () => void shutdown("SIGTERM"));
|
||||
process.on("SIGINT", () => void shutdown("SIGINT"));
|
||||
|
||||
ensureCloudM19Target(db).catch((err) => app.log.warn({ err }, "delivery: Cloud M19 profile not created"));
|
||||
ensureCloudW17Target(db).catch((err) => app.log.warn({ err }, "delivery: Cloud W17 profile not created"));
|
||||
|
||||
try {
|
||||
await app.listen({ port: config.PORT, host: "0.0.0.0" });
|
||||
|
||||
@@ -16,7 +16,7 @@ import { RenderPool, RenderProcess } from "./develop/engine.js";
|
||||
import { DevelopService, RenderWorker } from "./develop/service.js";
|
||||
import { FaceProcess, GrowingFacePool } from "./faces/process.js";
|
||||
import { AutopilotService, AutopilotWorker } from "./autopilot/service.js";
|
||||
import { ensureCloudM19Target } from "./delivery/fpa-m19.js";
|
||||
import { ensureCloudM19Target, ensureCloudW17Target } from "./delivery/fpa-m19.js";
|
||||
import { jogaClientFromConfig } from "./sports/joga.js";
|
||||
import { SportsService, SportsWorker } from "./sports/service.js";
|
||||
import { ArchiveService, ArchiveWorker, localDirs } from "./archive/service.js";
|
||||
@@ -177,6 +177,7 @@ const sports = config.SPORTS_SYNC === "on"
|
||||
: undefined;
|
||||
|
||||
ensureCloudM19Target(db).catch((err) => log.warn({ err }, "delivery: Cloud M19 profile not created"));
|
||||
ensureCloudW17Target(db).catch((err) => log.warn({ err }, "delivery: Cloud W17 profile not created"));
|
||||
scanner.start();
|
||||
if (secrets) archive.start();
|
||||
autopilot.start();
|
||||
|
||||
@@ -139,6 +139,13 @@ const PRESETS = {
|
||||
longEdge: 4000,
|
||||
...DESTINATION_EXAMPLES.fpaM19,
|
||||
},
|
||||
fpaW17: {
|
||||
label: "Cloud W17",
|
||||
kind: "NEXTCLOUD",
|
||||
baseUrl: "https://cloud.photoreport.pt",
|
||||
longEdge: 4000,
|
||||
...DESTINATION_EXAMPLES.fpaW17,
|
||||
},
|
||||
liga: {
|
||||
label: "Estrutura Liga",
|
||||
kind: "NEXTCLOUD",
|
||||
|
||||
@@ -342,7 +342,8 @@ every 6 hours (`SPORTS_SYNC=off` turns it off). It is shared by every organisati
|
||||
seed when that team is still empty. Those friendlies are fixtures (`m19-por-esp-20261105`,
|
||||
`m19-esp-por-20261107`) so picking the game links that plantel, not the senior one. A folder or title that
|
||||
says sub-19 / M19 (not "Encontro Nacional") is that age group. Cloud delivery for these games is the
|
||||
destination "Cloud M19" (`/FPA/Fotos/{season}/Seleções Nacionais/M19/…`), created from the organisation's
|
||||
destination "Cloud M19" (`/FPA/Fotos/{season}/Seleções Nacionais/M19/…`) and "Cloud W17"
|
||||
(`…/Seleções Nacionais/W17/…`), each created from the organisation's
|
||||
existing FPA Nextcloud account and never sent on arrival. FPA licence or an older EHF club photo fills
|
||||
gaps. People and reference faces are created when the event syncs those teams (`POST …/squads/sync`), not on
|
||||
every sports refresh. Example match: Portugal–Switzerland `202811130101002`.
|
||||
|
||||
@@ -238,6 +238,21 @@ describe("delivery paths", () => {
|
||||
expect(renderFileName(DESTINATION_EXAMPLES.fpaM19.fileName, { ...m19, n: 3 }, "R1_0003.JPG")).toBe("PS_POR x ESP_3.jpg");
|
||||
});
|
||||
|
||||
it("matches the women's under-17 cloud folder", () => {
|
||||
const w17 = buildVars({
|
||||
home: "Portugal",
|
||||
away: "Itália",
|
||||
homeShort: "POR",
|
||||
awayShort: "ITA",
|
||||
competition: "W17 EHF EURO",
|
||||
startsAt: new Date("2026-11-27T19:00:00Z"),
|
||||
});
|
||||
expect(renderFolder(DESTINATION_EXAMPLES.fpaW17.folder, w17)).toBe(
|
||||
"/FPA/Fotos/2026_2027/Seleções Nacionais/W17/20261127 - POR x ITA/",
|
||||
);
|
||||
expect(renderFileName(DESTINATION_EXAMPLES.fpaW17.fileName, { ...w17, n: 1 }, "R1_0001.JPG")).toBe("PS_POR x ITA_1.jpg");
|
||||
});
|
||||
|
||||
it("matches the Liga folder and keeps the camera name", () => {
|
||||
const liga = buildVars({ home: "Casa Pia", away: "Sporting", round: 1, matchNumber: 1, startsAt: new Date("2025-08-09T18:00:00Z") });
|
||||
expect(renderFolder(DESTINATION_EXAMPLES.liga.folder, liga)).toBe("/LPBetclic 25-26/Jornada 1/1. Casa Pia x Sporting/");
|
||||
|
||||
@@ -82,6 +82,11 @@ export const DESTINATION_EXAMPLES = {
|
||||
folder: "/FPA/Fotos/{season}/Seleções Nacionais/M19/{dateCompact} - {homeShort} x {awayShort}/",
|
||||
fileName: "PS_{homeShort} x {awayShort}_{n}.jpg",
|
||||
},
|
||||
/** Women's under-17. Same account as the club cloud; its own folder under Seleções Nacionais. */
|
||||
fpaW17: {
|
||||
folder: "/FPA/Fotos/{season}/Seleções Nacionais/W17/{dateCompact} - {homeShort} x {awayShort}/",
|
||||
fileName: "PS_{homeShort} x {awayShort}_{n}.jpg",
|
||||
},
|
||||
liga: {
|
||||
folder: "/LPBetclic {seasonShort}/Jornada {round}/{matchNumber}. {home} x {away}/",
|
||||
fileName: "{originalName}",
|
||||
|
||||
Reference in new issue
Block a user