- Removed manual refresh button from frontend (kept auto-refresh functionality) - Fixed WebKit 'object cannot be found' error by replacing absolute positioning with flexbox - Added lazy loading to images to prevent preload warnings - Cleaned up unused imports and variables: - Removed unused useRef import - Removed unused colors state variable and colorService - Removed unused ColorSwatch import from FilamentTableV2 - Removed unused getModifierIcon function from MaterialBadge - Updated tests to match current implementation - Improved layout stability for better cross-browser compatibility - Removed temporary migration scripts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
65 lines
1.9 KiB
JavaScript
65 lines
1.9 KiB
JavaScript
const { Pool } = require('pg');
|
|
require('dotenv').config();
|
|
|
|
const pool = new Pool({
|
|
connectionString: process.env.DATABASE_URL,
|
|
ssl: process.env.DATABASE_URL?.includes('amazonaws.com') ? { rejectUnauthorized: false } : false
|
|
});
|
|
|
|
async function addBasicRefills() {
|
|
try {
|
|
// First, let's insert filaments for all existing colors
|
|
const result = await pool.query(`
|
|
INSERT INTO filaments (tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena)
|
|
SELECT
|
|
'PLA' as tip,
|
|
'Basic' as finish,
|
|
c.name as boja,
|
|
c.hex as boja_hex,
|
|
'1' as refill,
|
|
'0 vakuum' as vakum,
|
|
'0 otvorena' as otvoreno,
|
|
1 as kolicina,
|
|
'3999' as cena
|
|
FROM colors c
|
|
WHERE NOT EXISTS (
|
|
-- Only insert if this exact combination doesn't already exist
|
|
SELECT 1 FROM filaments f
|
|
WHERE f.tip = 'PLA'
|
|
AND f.finish = 'Basic'
|
|
AND f.boja = c.name
|
|
)
|
|
`);
|
|
|
|
console.log(`Inserted ${result.rowCount} new PLA Basic filaments with 1 refill each`);
|
|
|
|
// Update any existing PLA Basic filaments to have at least 1 refill
|
|
const updateResult = await pool.query(`
|
|
UPDATE filaments
|
|
SET refill = '1'
|
|
WHERE tip = 'PLA'
|
|
AND finish = 'Basic'
|
|
AND (refill IS NULL OR refill = '0' OR refill = '')
|
|
`);
|
|
|
|
console.log(`Updated ${updateResult.rowCount} existing PLA Basic filaments to have 1 refill`);
|
|
|
|
// Show summary
|
|
const summary = await pool.query(`
|
|
SELECT COUNT(*) as count
|
|
FROM filaments
|
|
WHERE tip = 'PLA'
|
|
AND finish = 'Basic'
|
|
AND refill = '1'
|
|
`);
|
|
|
|
console.log(`\nTotal PLA Basic filaments with 1 refill: ${summary.rows[0].count}`);
|
|
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('Error adding basic refills:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
addBasicRefills(); |