fix: Repo-only-Projekte bekommen keine Subdomain vom Webhook; WOID numerisch

- Webhook: Subdomain-Fallback auf Repo-Name nur noch bei aktivierter Preview,
  Projekte ohne Website behalten leere Subdomain/previewUrl
- generateNextWoid: numerisches Maximum statt String-Sortierung (gemischt
  5-/6-stellige WOIDs im Bestand)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-11 18:14:41 +00:00
parent d4bd510dcd
commit 1c1826d25d
2 changed files with 11 additions and 7 deletions

View File

@@ -58,7 +58,9 @@ router.post('/gitea', async (req, res) => {
const previewConfigFile = await fetchPreviewConfig(repoFullName, branch)
const previewConfig = previewConfigFile || defaultPreviewConfig(repoFullName)
const hasPreview = Boolean(previewConfigFile?.enabled !== false && previewConfigFile)
const subdomain = previewConfig.subdomain || repoFullName.split('/').pop()
// Nur Projekte mit aktivierter Preview bekommen eine Subdomain zugewiesen -
// Repo-only-Projekte (enabled:false, keine Subdomain) bleiben ohne Website.
const subdomain = hasPreview ? previewConfig.subdomain || repoFullName.split('/').pop() : ''
const previewUrl = subdomain ? buildPreviewUrl(subdomain) : ''
let deployResult = { deployed: false, skipped: true }

View File

@@ -11,12 +11,14 @@ import {
const WOID_BASE = 9999
async function generateNextWoid() {
const docs = await listDocuments(config.collections.workorders, [
Query.orderDesc('woid'),
Query.limit(1),
])
const highest = docs[0]?.woid ? parseInt(docs[0].woid, 10) : WOID_BASE
return String(Math.max(WOID_BASE, highest) + 1)
// Numerisches Maximum ueber alle Tickets - orderDesc('woid') sortiert Strings
// und liefert bei gemischt 5-/6-stelligen WOIDs falsche Ergebnisse.
const docs = await listDocuments(config.collections.workorders, [Query.limit(1000)])
const highest = docs.reduce((max, doc) => {
const n = parseInt(doc.woid, 10)
return Number.isNaN(n) ? max : Math.max(max, n)
}, WOID_BASE)
return String(highest + 1)
}
/**