dev #56
28
package-lock.json
generated
28
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "harheimertc-website",
|
"name": "harheimertc-website",
|
||||||
"version": "1.8.9",
|
"version": "1.8.12",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "harheimertc-website",
|
"name": "harheimertc-website",
|
||||||
"version": "1.8.9",
|
"version": "1.8.12",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pinia/nuxt": "^0.11.2",
|
"@pinia/nuxt": "^0.11.2",
|
||||||
@@ -3921,9 +3921,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/archiver-utils/node_modules/brace-expansion": {
|
"node_modules/archiver-utils/node_modules/brace-expansion": {
|
||||||
"version": "2.1.4",
|
"version": "2.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz",
|
||||||
"integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
|
"integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^1.0.0"
|
"balanced-match": "^1.0.0"
|
||||||
@@ -4318,9 +4318,9 @@
|
|||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/brace-expansion": {
|
"node_modules/brace-expansion": {
|
||||||
"version": "5.0.9",
|
"version": "5.0.12",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
|
||||||
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^4.0.2"
|
"balanced-match": "^4.0.2"
|
||||||
@@ -9410,9 +9410,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/readdir-glob/node_modules/brace-expansion": {
|
"node_modules/readdir-glob/node_modules/brace-expansion": {
|
||||||
"version": "2.1.4",
|
"version": "2.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz",
|
||||||
"integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
|
"integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^1.0.0"
|
"balanced-match": "^1.0.0"
|
||||||
@@ -9492,9 +9492,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/replace-in-file/node_modules/brace-expansion": {
|
"node_modules/replace-in-file/node_modules/brace-expansion": {
|
||||||
"version": "1.1.18",
|
"version": "1.1.21",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz",
|
||||||
"integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
|
"integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "harheimertc-website",
|
"name": "harheimertc-website",
|
||||||
"version": "1.8.11",
|
"version": "1.8.12",
|
||||||
"description": "Moderne Webseite für den Harheimer Tischtennis Club",
|
"description": "Moderne Webseite für den Harheimer Tischtennis Club",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ function createQttrJob() {
|
|||||||
return {
|
return {
|
||||||
run: async (reason) => {
|
run: async (reason) => {
|
||||||
const qttr = await importQttrValues()
|
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,
|
outputFile: qttr.outputFile,
|
||||||
tableCount: qttr.tableCount
|
tableCount: qttr.tableCount
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -287,15 +287,21 @@ async function importAuthenticatedTtrValues(connection) {
|
|||||||
})
|
})
|
||||||
await sendOwnTtrChangePush(changes)
|
await sendOwnTtrChangePush(changes)
|
||||||
if (previousQttrSignature && previousQttrSignature !== nextQttrSignature) {
|
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 })
|
await saveMyTischtennisConnection({ ...connection, lastSuccessfulImportAt: importedAt, lastImportError: null })
|
||||||
return { outputFile: OUTPUT_FILE, tableCount: 1, ...payload }
|
return { outputFile: OUTPUT_FILE, tableCount: 1, ...payload }
|
||||||
}
|
}
|
||||||
|
|
||||||
function qttrListSignature(rows) {
|
export function qttrListSignature(rows) {
|
||||||
if (!Array.isArray(rows) || rows.length === 0) return ''
|
if (!Array.isArray(rows) || rows.length === 0) return ''
|
||||||
return rows
|
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 => [
|
.map(row => [
|
||||||
String(row?.playerNumber || row?.playerName || '').trim().toLocaleLowerCase('de-DE'),
|
String(row?.playerNumber || row?.playerName || '').trim().toLocaleLowerCase('de-DE'),
|
||||||
row?.currentQttr ?? ''
|
row?.currentQttr ?? ''
|
||||||
|
|||||||
23
tests/qttr-import.spec.ts
Normal file
23
tests/qttr-import.spec.ts
Normal file
@@ -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))
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user