Zertifizierung erforderlich ist weg
Dieser Commit ist enthalten in:
@ -31,8 +31,8 @@ function main() {
|
||||
}
|
||||
|
||||
const insert = db.prepare(`
|
||||
INSERT OR IGNORE INTO skills (id, name, category, description, requires_certification, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
INSERT OR IGNORE INTO skills (id, name, category, description, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`)
|
||||
|
||||
let count = 0
|
||||
@ -43,9 +43,8 @@ function main() {
|
||||
const id = `${categoryKey}.${sk.id}`
|
||||
const name = sk.name
|
||||
const description = null
|
||||
const requires = cat.id === 'certifications' || sub.id === 'weapons' ? 1 : 0
|
||||
const expires = cat.id === 'certifications' ? 36 : null
|
||||
const res = insert.run(id, name, categoryKey, description, requires, expires)
|
||||
const res = insert.run(id, name, categoryKey, description, expires)
|
||||
if (res.changes > 0) count++
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,6 @@ function ensureTables(db) {
|
||||
name TEXT NOT NULL,
|
||||
category TEXT NOT NULL,
|
||||
description TEXT,
|
||||
requires_certification INTEGER DEFAULT 0,
|
||||
expires_after INTEGER
|
||||
)
|
||||
`)
|
||||
@ -71,8 +70,8 @@ function seed(db, hierarchy) {
|
||||
`)
|
||||
|
||||
const insertSkill = db.prepare(`
|
||||
INSERT OR IGNORE INTO skills (id, name, category, description, requires_certification, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
INSERT OR IGNORE INTO skills (id, name, category, description, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`)
|
||||
|
||||
let catCount = 0
|
||||
@ -101,9 +100,8 @@ function seed(db, hierarchy) {
|
||||
for (const sk of (sub.skills || [])) {
|
||||
const sId = `${key}.${sk.id}`
|
||||
const sName = String(sk.name || sk.id)
|
||||
const requires = (catId === 'certifications' || subId === 'weapons') ? 1 : 0
|
||||
const expires = (catId === 'certifications') ? 36 : null
|
||||
const sRes = insertSkill.run(sId, sName, key, null, requires, expires)
|
||||
const sRes = insertSkill.run(sId, sName, key, null, expires)
|
||||
if (sRes.changes > 0) skillCount++
|
||||
}
|
||||
}
|
||||
@ -131,4 +129,3 @@ function main() {
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
|
||||
@ -237,7 +237,6 @@ export function initializeSecureDatabase() {
|
||||
name TEXT NOT NULL,
|
||||
category TEXT NOT NULL,
|
||||
description TEXT,
|
||||
requires_certification INTEGER DEFAULT 0,
|
||||
expires_after INTEGER
|
||||
)
|
||||
`)
|
||||
|
||||
@ -11,7 +11,7 @@ const router = Router()
|
||||
router.get('/', authenticate, async (req: AuthRequest, res, next) => {
|
||||
try {
|
||||
const skills = db.prepare(`
|
||||
SELECT id, name, category, description, requires_certification, expires_after
|
||||
SELECT id, name, category, description, expires_after
|
||||
FROM skills
|
||||
ORDER BY category, name
|
||||
`).all()
|
||||
@ -116,8 +116,8 @@ router.post('/initialize',
|
||||
async (req: AuthRequest, res, next) => {
|
||||
try {
|
||||
const insertSkill = db.prepare(`
|
||||
INSERT OR IGNORE INTO skills (id, name, category, description, requires_certification, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
INSERT OR IGNORE INTO skills (id, name, category, description, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`)
|
||||
|
||||
let count = 0
|
||||
@ -128,7 +128,6 @@ router.post('/initialize',
|
||||
skillName,
|
||||
category,
|
||||
null,
|
||||
category === 'certificates' || category === 'weapons' ? 1 : 0,
|
||||
category === 'certificates' ? 36 : null // 3 years for certificates
|
||||
)
|
||||
if (result.changes > 0) count++
|
||||
@ -151,7 +150,7 @@ router.post('/',
|
||||
authorize('admin', 'superuser'),
|
||||
async (req: AuthRequest, res, next) => {
|
||||
try {
|
||||
const { id, name, category, description, requiresCertification, expiresAfter } = req.body
|
||||
const { id, name, category, description, expiresAfter } = req.body
|
||||
|
||||
// Optional custom id to keep stable
|
||||
let skillId = id && typeof id === 'string' && id.length > 0 ? id : uuidv4()
|
||||
@ -171,14 +170,13 @@ router.post('/',
|
||||
return res.status(400).json({ success: false, error: { message: 'Unknown subcategory' } })
|
||||
}
|
||||
db.prepare(`
|
||||
INSERT INTO skills (id, name, category, description, requires_certification, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO skills (id, name, category, description, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`).run(
|
||||
skillId,
|
||||
name,
|
||||
category,
|
||||
description || null,
|
||||
requiresCertification ? 1 : 0,
|
||||
expiresAfter || null
|
||||
)
|
||||
|
||||
@ -188,7 +186,6 @@ router.post('/',
|
||||
name,
|
||||
category,
|
||||
description: description || null,
|
||||
requiresCertification: requiresCertification || false,
|
||||
expiresAfter: expiresAfter || null
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,6 @@ export function ensureSkillsSeeded() {
|
||||
name TEXT NOT NULL,
|
||||
category TEXT NOT NULL,
|
||||
description TEXT,
|
||||
requires_certification INTEGER DEFAULT 0,
|
||||
expires_after INTEGER
|
||||
)
|
||||
`)
|
||||
@ -63,8 +62,8 @@ export function ensureSkillsSeeded() {
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
`)
|
||||
const insertSkill = db.prepare(`
|
||||
INSERT OR IGNORE INTO skills (id, name, category, description, requires_certification, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
INSERT OR IGNORE INTO skills (id, name, category, description, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`)
|
||||
|
||||
let cats = 0, subs = 0, skills = 0
|
||||
@ -87,9 +86,8 @@ export function ensureSkillsSeeded() {
|
||||
for (const sk of (sub.skills || [])) {
|
||||
const sId = `${key}.${sk.id}`
|
||||
const sName = String(sk.name || sk.id)
|
||||
const requires = (catId === 'certifications' || subId === 'weapons') ? 1 : 0
|
||||
const expires = (catId === 'certifications') ? 36 : null
|
||||
insertSkill.run(sId, sName, key, null, requires, expires)
|
||||
insertSkill.run(sId, sName, key, null, expires)
|
||||
skills++
|
||||
}
|
||||
}
|
||||
@ -109,4 +107,3 @@ function cryptoRandomUUID() {
|
||||
return v.toString(16)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -74,9 +74,9 @@ async function syncSkill(action: string, data: any) {
|
||||
switch (action) {
|
||||
case 'create':
|
||||
db.prepare(`
|
||||
INSERT INTO skills (id, name, category, description, requires_certification, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
`).run(data.id, data.name, data.category, data.description || null, data.requiresCertification ? 1 : 0, data.expiresAfter || null)
|
||||
INSERT INTO skills (id, name, category, description, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`).run(data.id, data.name, data.category, data.description || null, data.expiresAfter || null)
|
||||
break
|
||||
case 'update':
|
||||
db.prepare(`
|
||||
|
||||
@ -388,11 +388,11 @@ export class SyncService {
|
||||
switch (action) {
|
||||
case 'create':
|
||||
db.prepare(`
|
||||
INSERT INTO skills (id, name, category, description, requires_certification, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO skills (id, name, category, description, expires_after)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`).run(
|
||||
data.id, data.name, data.category, data.description,
|
||||
data.requiresCertification ? 1 : 0, data.expiresAfter
|
||||
data.expiresAfter
|
||||
)
|
||||
break
|
||||
|
||||
@ -570,4 +570,4 @@ export class SyncService {
|
||||
}
|
||||
}
|
||||
|
||||
export const syncService = SyncService.getInstance()
|
||||
export const syncService = SyncService.getInstance()
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren