diff --git a/package.json b/package.json index 179bc5d..7ac0009 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "harheimertc-website", - "version": "1.8.11", + "version": "1.8.12", "description": "Moderne Webseite für den Harheimer Tischtennis Club", "private": true, "type": "module", diff --git a/server/plugins/spielplan-import-scheduler.js b/server/plugins/spielplan-import-scheduler.js index d647e05..d06e122 100755 --- a/server/plugins/spielplan-import-scheduler.js +++ b/server/plugins/spielplan-import-scheduler.js @@ -141,7 +141,7 @@ function createQttrJob() { return { run: async (reason) => { const qttr = await importQttrValues() - loggerInfo(`[qttr-import] ${reason}: ${qttr.rowCount} QTTR-Werte importiert`, { + loggerInfo(`[qttr-import] ${reason}: ${qttr.rowCount} TTR-/QTTR-Werte importiert`, { outputFile: qttr.outputFile, tableCount: qttr.tableCount }) diff --git a/server/utils/qttr-import.js b/server/utils/qttr-import.js index a2222a2..cb38a60 100755 --- a/server/utils/qttr-import.js +++ b/server/utils/qttr-import.js @@ -287,15 +287,21 @@ async function importAuthenticatedTtrValues(connection) { }) await sendOwnTtrChangePush(changes) if (previousQttrSignature && previousQttrSignature !== nextQttrSignature) { - await sendQttrListUpdatedPush({ importedAt, rowCount: rows.length }) + await sendQttrListUpdatedPush({ + importedAt, + rowCount: rows.filter(row => row.currentQttr != null).length + }) } await saveMyTischtennisConnection({ ...connection, lastSuccessfulImportAt: importedAt, lastImportError: null }) return { outputFile: OUTPUT_FILE, tableCount: 1, ...payload } } -function qttrListSignature(rows) { +export function qttrListSignature(rows) { if (!Array.isArray(rows) || rows.length === 0) return '' return rows + // TTR-only players are refreshed daily. They must neither alter the + // quarterly QTTR signature nor trigger a QTTR-list notification. + .filter(row => row?.currentQttr != null) .map(row => [ String(row?.playerNumber || row?.playerName || '').trim().toLocaleLowerCase('de-DE'), row?.currentQttr ?? '' diff --git a/tests/qttr-import.spec.ts b/tests/qttr-import.spec.ts new file mode 100644 index 0000000..e79b1da --- /dev/null +++ b/tests/qttr-import.spec.ts @@ -0,0 +1,23 @@ +import { describe, expect, it } from 'vitest' +import { qttrListSignature } from '../server/utils/qttr-import.js' + +describe('QTTR import signature', () => { + it('ignores TTR-only players so daily TTR changes cannot trigger a QTTR push', () => { + const qttrRows = [ + { playerNumber: 1, playerName: 'QTTR Spieler', currentQttr: 1500, currentTtr: 1512 } + ] + const withChangedTtrOnlyPlayer = [ + ...qttrRows, + { playerNumber: 2, playerName: 'Nur TTR', currentQttr: null, currentTtr: 1333 } + ] + + expect(qttrListSignature(withChangedTtrOnlyPlayer)).toBe(qttrListSignature(qttrRows)) + }) + + it('changes when an actual QTTR value changes', () => { + const previous = [{ playerNumber: 1, playerName: 'QTTR Spieler', currentQttr: 1500 }] + const updated = [{ playerNumber: 1, playerName: 'QTTR Spieler', currentQttr: 1501 }] + + expect(qttrListSignature(updated)).not.toBe(qttrListSignature(previous)) + }) +})