Compare commits

..
Author SHA1 Message Date
1sonhador b97b768057 chore: limit CODEOWNERS to active Gitea reviewers
Tests / writer-pipeline tests (push) Successful in 26s
Tests / bridge tests (push) Successful in 25s
Tests / frontend lib tests (push) Successful in 29s
Tests / writer-pipeline tests (pull_request) Successful in 26s
Tests / bridge tests (pull_request) Successful in 28s
Tests / frontend lib tests (pull_request) Successful in 37s
Only owners that review in practice are listed, so official review
requests from code owners never block merges on protected branches.
2026-10-22 04:45:01 +01:00
1sonhador fe9a19603c chore: corrige CODEOWNERS para contas existentes no Gitea
Tests / writer-pipeline tests (pull_request) Successful in 29s
Tests / bridge tests (pull_request) Successful in 32s
Tests / frontend lib tests (pull_request) Successful in 47s
Tests / writer-pipeline tests (push) Successful in 46s
Tests / bridge tests (push) Successful in 41s
Tests / frontend lib tests (push) Successful in 41s
2026-10-21 17:39:13 +01:00
spark b23ca87102 Merge pull request 'fix(writer-pipeline): decode literal \u2013 in revista PDF URLs (BIT-31118)' (#53) from fix/BIT-31118-revista-imprensa-u2013-404 into main
Tests / writer-pipeline tests (push) Successful in 36s
Tests / bridge tests (push) Successful in 37s
Tests / frontend lib tests (push) Successful in 41s
fix(writer-pipeline): decode literal \u2013 in revista PDF URLs (BIT-31118)

Merged PR #53.

Paperclip-Issue: BIT-31118
Paperclip-ERRSIG: 97ac27c4c5df
Paperclip-ERRCLUSTER: ddda2b9e3d39
2026-10-13 06:25:21 +01:00
tiago-neves dc1b6dd4f0 ci: retrigger push status checks for BIT-31118
Tests / writer-pipeline tests (push) Successful in 46s
Tests / bridge tests (push) Successful in 48s
Tests / frontend lib tests (push) Successful in 55s
Tests / writer-pipeline tests (pull_request) Successful in 54s
Tests / bridge tests (pull_request) Successful in 54s
Tests / frontend lib tests (pull_request) Successful in 56s
Paperclip-Issue: BIT-31118
Paperclip-ERRSIG: 97ac27c4c5df
Paperclip-ERRCLUSTER: ddda2b9e3d39
Paperclip-Run: 567916ae-2a3f-4379-8780-9eeaaa781a04
2026-10-13 06:23:06 +01:00
tiago-neves ded3c71ed6 fix(writer-pipeline): decode literal \u2013 in revista PDF URLs (BIT-31118)
Tests / writer-pipeline tests (pull_request) Successful in 38s
Tests / bridge tests (pull_request) Successful in 38s
Tests / frontend lib tests (pull_request) Successful in 43s
FPA media embeds Revista-de-Imprensa filenames with a literal JSON \u2013
escape; new URL turned the backslash into /u2013 and the fetch 404'd.
Decode \uXXXX before parsing and accept en-dash / hashed date filenames.

Paperclip-Issue: BIT-31118
Paperclip-ERRSIG: 97ac27c4c5df
Paperclip-ERRCLUSTER: ddda2b9e3d39
Paperclip-Run: 3f65156a-de49-43a1-876d-75f6285b4bc4
2026-10-13 06:19:06 +01:00
spark c7329a7ea5 Merge pull request 'feat(andebol): Classificação link on FPA agenda cards (BIT-31056)' (#52) from fix/BIT-31056-fpa-agenda-standings-link into main
Tests / writer-pipeline tests (push) Successful in 39s
Tests / bridge tests (push) Successful in 41s
Tests / frontend lib tests (push) Successful in 44s
2026-10-10 18:02:03 +01:00
tiago-neves de19fb7e1a feat(andebol): add Classificação link on FPA agenda game cards (BIT-31056)
Tests / writer-pipeline tests (push) Successful in 47s
Tests / bridge tests (push) Successful in 49s
Tests / frontend lib tests (push) Successful in 56s
Tests / writer-pipeline tests (pull_request) Successful in 51s
Tests / bridge tests (pull_request) Successful in 51s
Tests / frontend lib tests (pull_request) Successful in 54s
Map PROVA competition codes to public standings URLs so every "Próximos jogos"
card links to the competition table (Flashscore for Betclic leagues; FPA portal
hubs otherwise).

Paperclip-Issue: BIT-31056
Paperclip-Run: 5901136e-753a-494f-bd36-250d1b822690
2026-10-10 17:47:03 +01:00
spark e43f04705a Merge pull request 'fix(writer-pipeline): demote sitemap gateway 502/503/504 to warning (BIT-30847)' (#51) from fix/BIT-30847-eurohandball-sitemap-502-demote into main
Tests / writer-pipeline tests (push) Successful in 37s
Tests / bridge tests (push) Successful in 39s
Tests / frontend lib tests (push) Successful in 42s
2026-10-04 06:30:57 +01:00
tiago-neves c61c19216c fix(writer-pipeline): demote sitemap gateway 502/503/504 to warning
Tests / writer-pipeline tests (pull_request) Successful in 49s
Tests / bridge tests (pull_request) Successful in 50s
Tests / writer-pipeline tests (push) Successful in 56s
Tests / bridge tests (push) Successful in 56s
Tests / frontend lib tests (pull_request) Successful in 1m3s
Tests / frontend lib tests (push) Successful in 1m0s
EHF google-news-sitemap already retries; residual gateway blips (BIT-30847 /
ERRSIG a92b3521aec8) must not open Error Loop tickets. Keep HTTP 500 as error
so broken endpoints like the old /sitemap.xml stay actionable.

Paperclip-Agent: Bug Squasher (urlKey bug-squasher; id 4669adc7-6368-43ef-bf27-5a601a6b7b83)
Paperclip-Issue: BIT-30847
Paperclip-Run: ce265bf3-24dc-4532-b87d-92188cc55399
2026-10-04 06:17:33 +01:00
spark da539f33aa Merge pull request 'fix(writer-pipeline): retry WP draft POSTs; demote transient fetch noise (BIT-30583)' (#49) from fix/BIT-30583-draft-fetch-retry into main
Tests / writer-pipeline tests (push) Successful in 44s
Tests / bridge tests (push) Successful in 44s
Tests / frontend lib tests (push) Successful in 49s
2026-10-01 07:18:09 +01:00
14 changed files with 245 additions and 16 deletions

No files matched your search

+4 -4
View File
@@ -2,11 +2,11 @@
# Replace/add owners as needed per repository domain.
# CI and forge metadata
/.gitea/ @tiago-neves @david-santos
/.gitea/workflows/ @tiago-neves @david-santos
/.gitea/ @devops-engineer @founding-engineer
/.gitea/workflows/ @devops-engineer @founding-engineer
# Documentation
/docs/ @david-santos @planner
/docs/ @founding-engineer
# Catch-all
* @david-santos
* @founding-engineer
+4 -4
View File
@@ -2,11 +2,11 @@
# Replace/add owners as needed per repository domain.
# CI and forge metadata
/.gitea/ @tiago-neves @david-santos
/.gitea/workflows/ @tiago-neves @david-santos
/.gitea/ @devops-engineer @founding-engineer
/.gitea/workflows/ @devops-engineer @founding-engineer
# Documentation
/docs/ @david-santos @planner
/docs/ @founding-engineer
# Catch-all
* @david-santos
* @founding-engineer
+2 -2
View File
@@ -9,8 +9,8 @@
"build": "tsc",
"start": "node dist/server.js",
"typecheck": "tsc --noEmit",
"test": "npm run build && node --test dist/lib/sanitize-html.test.js dist/services/ranking.test.js dist/services/aggregator-mapper.test.js dist/services/andeboltv.test.js dist/services/fpa-stream-match.test.js",
"test:coverage": "npm run build && node --experimental-test-coverage --test dist/lib/sanitize-html.test.js dist/services/ranking.test.js dist/services/aggregator-mapper.test.js dist/services/andeboltv.test.js dist/services/fpa-stream-match.test.js"
"test": "npm run build && node --test dist/lib/sanitize-html.test.js dist/services/ranking.test.js dist/services/aggregator-mapper.test.js dist/services/andeboltv.test.js dist/services/fpa-stream-match.test.js dist/services/fpa-standings-url.test.js",
"test:coverage": "npm run build && node --experimental-test-coverage --test dist/lib/sanitize-html.test.js dist/services/ranking.test.js dist/services/aggregator-mapper.test.js dist/services/andeboltv.test.js dist/services/fpa-stream-match.test.js dist/services/fpa-standings-url.test.js"
},
"dependencies": {
"@fastify/cors": "^9.0.1",
+3 -1
View File
@@ -8,6 +8,7 @@ import type { AndebolTvStreamEvent } from '../services/andeboltv.js';
import { fetch_andeboltv_stream_events } from '../services/andeboltv.js';
import { get_fpa_agenda_from_store } from '../services/fpa-agenda.js';
import { enrich_fpa_agenda_with_streams } from '../services/fpa-stream-match.js';
import { enrich_fpa_agenda_with_standings_urls } from '../services/fpa-standings-url.js';
// Number of articles per section
const HERO_COUNT = 3;
@@ -151,7 +152,8 @@ export async function homepage_routes(app: FastifyInstance): Promise<void> {
}
}),
]);
return enrich_fpa_agenda_with_streams(games, streams);
const with_streams = enrich_fpa_agenda_with_streams(games, streams);
return enrich_fpa_agenda_with_standings_urls(with_streams);
} catch (err) {
app.log.warn({ err, host }, 'FPA agenda fetch failed');
return [];
@@ -0,0 +1,48 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
enrich_fpa_agenda_with_standings_urls,
extract_fpa_competition_code,
FPA_STANDINGS_FALLBACK_URL,
resolve_fpa_standings_url,
} from './fpa-standings-url.js';
test('extract_fpa_competition_code reads leading PO codes', () => {
assert.equal(extract_fpa_competition_code('PO01 - Campeonato Betclic Masculino'), 'PO01');
assert.equal(extract_fpa_competition_code('PO01A - Divisao de Honra Masculina'), 'PO01A');
assert.equal(extract_fpa_competition_code('PO09 - Campeonato Betclic Feminino'), 'PO09');
assert.equal(extract_fpa_competition_code('PARTICULARES SELECOES NACIONAIS'), null);
});
test('resolve_fpa_standings_url maps Betclic leagues to Flashscore tables', () => {
assert.match(
resolve_fpa_standings_url('PO01 - Campeonato Betclic Masculino'),
/campeonato-betclic-masculino\/classificacao\/$/,
);
assert.match(
resolve_fpa_standings_url('PO09 - Campeonato Betclic Feminino'),
/campeonato-betclic-feminino\/classificacao\/$/,
);
});
test('resolve_fpa_standings_url falls back by gender then national hub', () => {
assert.match(
resolve_fpa_standings_url('PO02 - Campeonato Nacional 2a Divisao Masculina'),
/competicoes-nacionais-andebol-masculino\/$/,
);
assert.match(
resolve_fpa_standings_url('PO10 - Campeonato Nacional 2a Divisao Feminina'),
/competicoes-nacionais-andebol-feminino\/$/,
);
assert.equal(resolve_fpa_standings_url('PARTICULARES SELECOES NACIONAIS'), FPA_STANDINGS_FALLBACK_URL);
});
test('enrich_fpa_agenda_with_standings_urls always sets standings_url', () => {
const games: Array<{ competition: string; standings_url?: string | null }> = [
{ competition: 'PO01 - Campeonato Betclic Masculino' },
{ competition: 'Unknown cup', standings_url: null },
];
const enriched = enrich_fpa_agenda_with_standings_urls(games);
assert.ok(enriched[0]?.standings_url.startsWith('https://'));
assert.equal(enriched[1]?.standings_url, FPA_STANDINGS_FALLBACK_URL);
});
+74
View File
@@ -0,0 +1,74 @@
/**
* Resolve a public standings (classificação) URL for an FPA agenda competition name.
*
* Agenda rows only expose `PROVA` as a free-text label (e.g. "PO01 - Campeonato Betclic
* Masculino"). There is no competition id in the feed. We map known competition codes to
* public standings pages (Flashscore for top leagues that publish tables; FPA portal hubs
* otherwise), with a national competitions fallback.
*/
const FLASHSCORE_PT = 'https://www.flashscore.pt/andebol/portugal';
const PORTAL_FPA = 'https://portal.fpa.pt';
/** General FPA national competitions hub (final fallback). */
export const FPA_STANDINGS_FALLBACK_URL = `${PORTAL_FPA}/competicoes-nacionais/`;
const PORTAL_MASCULINO = `${PORTAL_FPA}/competicoes-nacionais-andebol-masculino/`;
const PORTAL_FEMININO = `${PORTAL_FPA}/competicoes-nacionais-andebol-feminino/`;
/**
* Competition code (from PROVA prefix) → public standings page.
* Prefer pages that actually render a league table when available.
*/
const STANDINGS_BY_CODE: Record<string, string> = {
PO01: `${FLASHSCORE_PT}/campeonato-betclic-masculino/classificacao/`,
PO01A: PORTAL_MASCULINO,
PO02: PORTAL_MASCULINO,
PO03: PORTAL_MASCULINO,
PO06: PORTAL_MASCULINO,
PO09: `${FLASHSCORE_PT}/campeonato-betclic-feminino/classificacao/`,
PO09A: PORTAL_FEMININO,
PO10: PORTAL_FEMININO,
PO12: PORTAL_FEMININO,
PO20: `${FLASHSCORE_PT}/taca-de-portugal/`,
PO23: PORTAL_FEMININO,
};
/** Extract leading competition code such as PO01 / PO01A / PO09A from a PROVA label. */
export function extract_fpa_competition_code(competition: string): string | null {
const m = competition.trim().match(/^([A-Z]{1,3}\d{1,3}[A-Z]?)\b/i);
return m?.[1] ? m[1].toUpperCase() : null;
}
function gender_hub_url(competition: string): string | null {
const lower = competition.toLowerCase();
if (/\bfemin/i.test(lower)) {
return PORTAL_FEMININO;
}
if (/\bmascul/i.test(lower)) {
return PORTAL_MASCULINO;
}
return null;
}
/**
* Always returns a URL suitable for an external "Classificação" link.
*/
export function resolve_fpa_standings_url(competition: string): string {
const code = extract_fpa_competition_code(competition);
if (code && STANDINGS_BY_CODE[code]) {
return STANDINGS_BY_CODE[code]!;
}
return gender_hub_url(competition) ?? FPA_STANDINGS_FALLBACK_URL;
}
/** Attach `standings_url` to each agenda game (idempotent). */
export function enrich_fpa_agenda_with_standings_urls<T extends { competition: string; standings_url?: string | null }>(
games: T[],
): Array<T & { standings_url: string }> {
return games.map((game) => ({
...game,
standings_url: game.standings_url || resolve_fpa_standings_url(game.competition),
}));
}
+5
View File
@@ -40,6 +40,11 @@ export interface FpaAgendaGame {
stream_status?: 'live' | 'upcoming' | null;
/** Convenience flag when `stream_status === 'live'`. */
is_live?: boolean;
/**
* Public standings (classificação) page for this competition.
* Resolved from the PROVA label (code map + gender hub + FPA national fallback).
*/
standings_url?: string | null;
}
export interface CategoryConfig {
+3
View File
@@ -60,6 +60,7 @@ export type UiStrings = {
fpa_status_live: string;
fpa_watch_live: string;
fpa_watch_stream: string;
fpa_standings_link: string;
fpa_games_on_date: (count: number) => string;
/** News archive page title */
news_archive_title: string;
@@ -172,6 +173,7 @@ const en: UiStrings = {
fpa_status_live: 'Live',
fpa_watch_live: 'Watch live',
fpa_watch_stream: 'Watch on AndebolTV',
fpa_standings_link: 'Standings',
fpa_games_on_date: count => (count === 1 ? '1 match' : `${count} matches`),
news_archive_title: 'News',
news_all_filter: 'All',
@@ -268,6 +270,7 @@ const pt: UiStrings = {
fpa_status_live: 'Em direto',
fpa_watch_live: 'Ver em direto',
fpa_watch_stream: 'Ver na AndebolTV',
fpa_standings_link: 'Classificação',
fpa_games_on_date: count => (count === 1 ? '1 jogo' : `${count} jogos`),
news_archive_title: 'Notícias',
news_all_filter: 'Todas',
@@ -70,6 +70,7 @@ const date_groups = [...by_date.entries()];
const finished = is_finished(g);
const score = format_score(g);
const has_stream = Boolean(g.stream_url);
const standings_url = g.standings_url || 'https://portal.fpa.pt/competicoes-nacionais/';
const is_live = Boolean(g.is_live);
const status_label = finished
? ui.fpa_status_finished
@@ -173,6 +174,14 @@ const date_groups = [...by_date.entries()];
<span>{g.venue}</span>
</span>
)}
<a
class="fpa-agenda__standings-link"
href={standings_url}
target="_blank"
rel="noopener noreferrer"
>
{ui.fpa_standings_link}
</a>
{has_stream && (
<a
class="fpa-agenda__stream-link"
@@ -603,15 +612,24 @@ const date_groups = [...by_date.entries()];
opacity: 0.7;
}
.fpa-agenda__standings-link,
.fpa-agenda__stream-link {
margin-left: auto;
font-size: 0.8125rem;
font-weight: 700;
color: #a20c17;
text-decoration: none;
white-space: nowrap;
}
.fpa-agenda__standings-link {
margin-left: auto;
color: var(--color-primary);
}
.fpa-agenda__stream-link {
color: #a20c17;
}
.fpa-agenda__standings-link:hover,
.fpa-agenda__stream-link:hover {
text-decoration: underline;
}
+5
View File
@@ -55,6 +55,11 @@ export interface FpaAgendaGame {
stream_status?: 'live' | 'upcoming' | null;
/** Convenience flag when `stream_status === 'live'`. */
is_live?: boolean;
/**
* Public standings (classificação) page for this competition.
* Resolved from the PROVA label (code map + gender hub + FPA national fallback).
*/
standings_url?: string | null;
}
export interface Article {
+20 -1
View File
@@ -22,9 +22,28 @@ describe('cycleErrorMessageLevel', () => {
);
});
it('keeps whole-source sitemap failures as error', () => {
it('downgrades whole-source sitemap gateway blips to warning (BIT-30847)', () => {
assert.equal(
cycleErrorMessageLevel(
'sitemap eurohandball_sitemap (https://www.eurohandball.com/google-news-sitemap.xml): HTTP 502',
),
'warning',
);
assert.equal(
cycleErrorMessageLevel('sitemap eurohandball_sitemap (https://www.eurohandball.com/sitemap.xml): HTTP 503'),
'warning',
);
assert.equal(
cycleErrorMessageLevel(
'sitemap eurohandball_sitemap (https://www.eurohandball.com/google-news-sitemap.xml): HTTP 504',
),
'warning',
);
});
it('keeps whole-source sitemap HTTP 500 as error (actionable upstream/config)', () => {
assert.equal(
cycleErrorMessageLevel('sitemap eurohandball_sitemap (https://www.eurohandball.com/sitemap.xml): HTTP 500'),
'error',
);
});
@@ -5,6 +5,7 @@ import {
titleFromArticleUrl,
} from './html-listing.js';
import {
decodeJsonUnicodeEscapes,
extractRevistaPdfUrls,
isHandballRevistaLead,
leadUrlForRevistaEntry,
@@ -88,6 +89,21 @@ test('extractRevistaPdfUrls finds absolute and relative PDF hrefs', () => {
assert.ok(urls[0].includes('18.06.2026'));
});
test('decodeJsonUnicodeEscapes turns literal \\u2013 into en-dash (BIT-31118)', () => {
assert.equal(decodeJsonUnicodeEscapes('Revista-de-Imprensa-\\u2013-12.10.2026.pdf'), 'Revista-de-Imprensa-\u2013-12.10.2026.pdf');
});
test('extractRevistaPdfUrls decodes literal \\u2013 so URL is not /u2013 (BIT-31118)', () => {
const html = `
"pdf":"https://portal.fpa.pt/wp-content/uploads/2026/10/Revista-de-Imprensa-\\u2013-12.10.2026.pdf"
`;
const urls = extractRevistaPdfUrls(html, 'https://portal.fpa.pt/media/');
assert.equal(urls.length, 1);
assert.ok(!urls[0].includes('/u2013'), urls[0]);
assert.ok(urls[0].includes('%E2%80%93') || urls[0].includes('\u2013'), urls[0]);
assert.ok(urls[0].includes('12.10.2026'));
});
test('publishedAtFromPtDate parses DD/MM/YYYY', () => {
const iso = publishedAtFromPtDate('17/06/2026', '2026-01-01T00:00:00.000Z');
assert.equal(iso.slice(0, 10), '2026-06-17');
@@ -98,6 +114,18 @@ test('pdfDateFromRevistaUrl parses filename date', () => {
pdfDateFromRevistaUrl('https://portal.fpa.pt/wp-content/uploads/2026/06/Revista-de-Imprensa-18.06.2026.pdf'),
'2026-06-18',
);
assert.equal(
pdfDateFromRevistaUrl(
'https://portal.fpa.pt/wp-content/uploads/2026/10/Revista-de-Imprensa-%E2%80%93-12.10.2026.pdf',
),
'2026-10-12',
);
assert.equal(
pdfDateFromRevistaUrl(
'https://portal.fpa.pt/wp-content/uploads/2026/10/Revista-de-Imprensa-12.10.2026-9a3f277b.pdf',
),
'2026-10-12',
);
});
test('isHandballRevistaLead detects andebol keywords', () => {
@@ -16,6 +16,15 @@ export function cycleErrorMessageLevel(message: string): 'warning' | 'error' {
if (message.includes('truncating')) return 'warning';
// Per-URL HTML probe failed but other pages in the same source may have succeeded.
if (/^sitemap .+ page \(https?:\/\//.test(message)) return 'warning';
// Whole-source fetch already retries (http-retry); remaining gateway blips are upstream
// noise (BIT-30847 / ERRSIG a92b3521aec8). Keep HTTP 500 as error — that flagged the
// broken /sitemap.xml URL fixed in BIT-30741.
if (
/^sitemap .+ \(https?:\/\//.test(message) &&
/: HTTP (502|503|504)\b/.test(message)
) {
return 'warning';
}
return 'error';
}
+20 -2
View File
@@ -100,13 +100,25 @@ export function isHandballRevistaLead(title: string, source: string): boolean {
return /andebol|handball|\behf\b|liga dos campeões de andebol|fpa\b/.test(hay);
}
/**
* FPA media JSON sometimes embeds PDF filenames with a *literal* `\u2013`
* (en-dash) escape. `new URL` treats `\` as a path separator and turns that
* into `/u2013`, which 404s. Decode JSON-style `\uXXXX` before URL parsing
* (BIT-31118 / ERRSIG 97ac27c4c5df).
*/
export function decodeJsonUnicodeEscapes(raw: string): string {
return raw.replace(/\\u([0-9a-fA-F]{4})/g, (_, hex: string) =>
String.fromCharCode(parseInt(hex, 16)),
);
}
export function extractRevistaPdfUrls(html: string, pageUrl: string): string[] {
const seen = new Set<string>();
const out: string[] = [];
const add = (raw: string) => {
try {
const href = new URL(raw, pageUrl).href;
const href = new URL(decodeJsonUnicodeEscapes(raw), pageUrl).href;
if (!seen.has(href)) {
seen.add(href);
out.push(href);
@@ -134,7 +146,13 @@ export async function parseRevistaPdfBuffer(buffer: Buffer): Promise<RevistaEntr
}
export function pdfDateFromRevistaUrl(pdfUrl: string): string | null {
const m = pdfUrl.match(/Revista-de-Imprensa-(\d{2})\.(\d{2})\.(\d{4})\.pdf/i);
// Accept hyphen or en-dash before the date, and optional WP hash suffix:
// Revista-de-Imprensa-12.10.2026.pdf
// Revista-de-Imprensa-–-12.10.2026.pdf
// Revista-de-Imprensa-12.10.2026-9a3f277b.pdf
const m = pdfUrl.match(
/Revista-de-Imprensa-(?:(?:\u2013|%E2%80%93)-)?(\d{2})\.(\d{2})\.(\d{4})(?:-[a-f0-9]+)?\.pdf/i,
);
if (!m) return null;
return `${m[3]}-${m[2]}-${m[1]}`;
}