6de2455917
- Added GLOBAL_MARKETS_TITLE to all translation files - Updated footer with 12 markets (4 active + 8 upcoming) - Translated market section to: zh-cn, zh-tw, ja, ko, th, vi, id, ms, hi - Built and deployed to production - CloudFront invalidation: I3RTMXVFDJXWLG3SYX208OP1CC
90 lines
2.5 KiB
JavaScript
90 lines
2.5 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Seed-script: ladda bounty-data och golden cases
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const Bounty = require('../src/models/bounty');
|
|
const Identify = require('../src/models/identify');
|
|
const logger = require('../src/utils/logger');
|
|
|
|
function seedBounties() {
|
|
const bountiesPath = path.join(__dirname, '../../10-data/lvx-zoomer-bounties-vag1.json');
|
|
const data = JSON.parse(fs.readFileSync(bountiesPath, 'utf8'));
|
|
|
|
let created = 0;
|
|
for (const b of data.bounties) {
|
|
try {
|
|
Bounty.create({
|
|
bounty_id: b.bounty_id,
|
|
titel: b.titel,
|
|
mal_lvx: b.mal_lvx,
|
|
foton: b.foton,
|
|
ocr_falt: b.ocr_falt,
|
|
poang: b.poang,
|
|
prioritet: b.prioritet,
|
|
sakerhet: b.sakerhet,
|
|
kommentar: b.kommentar,
|
|
status: 'oppen',
|
|
skapad_av: 'system'
|
|
});
|
|
created++;
|
|
} catch (e) {
|
|
logger.warn(`Kunde inte skapa bounty ${b.bounty_id}: ${e.message}`);
|
|
}
|
|
}
|
|
|
|
logger.info(`Seedade ${created} bounties`);
|
|
return created;
|
|
}
|
|
|
|
function seedGoldenCases() {
|
|
const cases = [
|
|
{
|
|
namn: 'GE Cobrahead (ERS2)',
|
|
beskrivning: 'Identifiera GE Evolve LED Scalable Cobrahead',
|
|
input_ocr: ['GE', 'ERS2', '4000K'],
|
|
input_position: { lat: 36.16, lon: -115.14, land: 'US' },
|
|
forvantat_svar: { lvx_id: 'LVX-P-0000002', konfidens: 0.90 }
|
|
},
|
|
{
|
|
namn: 'American-Darling B-84-B',
|
|
beskrivning: 'Hydrant åldersbestämd ur gjutgodset',
|
|
input_ocr: ['AMERICAN-DARLING', 'B-84-B-5', '1998'],
|
|
input_position: { lat: 32.78, lon: -96.80, land: 'US' },
|
|
forvantat_svar: { lvx_id: 'LVX-P-0000016', konfidens: 0.90 }
|
|
},
|
|
{
|
|
namn: 'Okänt kabelskåp UK',
|
|
beskrivning: 'Grått gatuskåp utan etikett',
|
|
input_ocr: [],
|
|
input_position: { lat: 51.51, lon: -0.13, land: 'UK' },
|
|
forvantat_svar: { lvx_id: 'LVX-ELN-0101', konfidens: 0.70 }
|
|
}
|
|
];
|
|
|
|
let created = 0;
|
|
for (const c of cases) {
|
|
try {
|
|
Identify.addGoldenCase(c);
|
|
created++;
|
|
} catch (e) {
|
|
logger.warn(`Kunde inte skapa golden case ${c.namn}: ${e.message}`);
|
|
}
|
|
}
|
|
|
|
logger.info(`Seedade ${created} golden cases`);
|
|
return created;
|
|
}
|
|
|
|
// Kör seed
|
|
Bounty.initTables();
|
|
Identify.initTables();
|
|
|
|
const bountyCount = seedBounties();
|
|
const goldenCount = seedGoldenCases();
|
|
|
|
logger.info('Seedning klar', { bounties: bountyCount, goldenCases: goldenCount });
|
|
console.log(`✅ Seedning klar: ${bountyCount} bounties, ${goldenCount} golden cases`);
|