steelforesight/panel/insert-events.mjs

107 lines
6.9 KiB
JavaScript

import { db, pool } from './db.js';
// Gregorian ISO → Jalali parts using Intl (same engine the site's calendar uses)
function jalali(iso) {
const d = new Date(iso + 'T00:00:00');
const en = new Intl.DateTimeFormat('en-US-u-ca-persian', { day: 'numeric', month: 'numeric', year: 'numeric' }).formatToParts(d);
const get = (t) => en.find((p) => p.type === t).value;
const day = Number(get('day'));
const year = Number(get('year'));
const monthFa = new Intl.DateTimeFormat('fa-IR-u-ca-persian', { month: 'long' }).format(d);
const monthEn = new Intl.DateTimeFormat('en-US-u-ca-persian', { month: 'long' }).format(d);
return { day, year, monthFa, monthEn };
}
// 9 real, verified, upcoming steel-industry events (all after 2026-06-15)
const events = [
{ id: 'gulf-steel-expo-2026', iso: '2026-09-20', type: 'exhibition',
titleFa: 'نمایشگاه فولاد خلیج ۲۰۲۶', titleEn: 'Gulf Steel Expo 2026',
cityFa: 'دمام', cityEn: 'Dammam', countryFa: 'عربستان سعودی',
descFa: 'نمایشگاه و کنفرانس عربستان سعودی با پوشش کامل زنجیره ارزش صنعت فولاد.',
descEn: "Saudi Arabia's exhibition and conference covering the entire steel value chain." },
{ id: 'arab-steel-summit-2026', iso: '2026-11-03', type: 'conference',
titleFa: 'نوزدهمین اجلاس فولاد عرب ۲۰۲۶', titleEn: '19th Arab Steel Summit 2026',
cityFa: 'دوحه', cityEn: 'Doha', countryFa: 'قطر',
descFa: 'اجلاس پرچم‌دار اتحادیه آهن و فولاد عرب همراه با نمایشگاه بین‌المللی آهن و فولاد.',
descEn: "The Arab Iron and Steel Union's flagship summit and international iron & steel exhibition." },
{ id: 'meis-2026', iso: '2026-11-16', type: 'conference',
titleFa: 'کنفرانس آهن و فولاد خاورمیانه ۲۰۲۶', titleEn: 'Middle East Iron & Steel 2026',
cityFa: 'دبی', cityEn: 'Dubai', countryFa: 'امارات متحده عربی',
descFa: 'مهم‌ترین کنفرانس تجارت آهن و فولاد خاورمیانه با حضور بیش از ۱۴۵۰ مدیر ارشد صنعت.',
descEn: "Fastmarkets' premier Middle East iron and steel trading conference with 1,450+ senior executives." },
{ id: 'iran-metafo-2026', iso: '2026-11-20', type: 'exhibition',
titleFa: 'نمایشگاه بین‌المللی متالورژی ایران (متافو) ۲۰۲۶', titleEn: 'Iran Metafo 2026',
cityFa: 'تهران', cityEn: 'Tehran', countryFa: 'ایران',
descFa: 'بزرگ‌ترین نمایشگاه بین‌المللی متالورژی، فولاد، معدن و ریخته‌گری ایران در محل دائمی نمایشگاه‌های بین‌المللی تهران.',
descEn: "Iran's largest international metallurgy, steel, mining and foundry exhibition in Tehran." },
{ id: 'made-in-steel-2027', iso: '2027-05-11', type: 'exhibition',
titleFa: 'نمایشگاه و کنفرانس مید این استیل ۲۰۲۷', titleEn: 'Made in Steel 2027',
cityFa: 'میلان', cityEn: 'Milan', countryFa: 'ایتالیا',
descFa: 'بزرگ‌ترین نمایشگاه و کنفرانس دوسالانه صنعت فولاد ایتالیا در مرکز نمایشگاهی میلان.',
descEn: "Italy's leading biennial steel-industry conference and exhibition at Fiera Milano Rho." },
{ id: 'seaisi-2027', iso: '2027-05-17', type: 'conference',
titleFa: 'کنفرانس و نمایشگاه فولاد جنوب شرق آسیا (SEAISI) ۲۰۲۷', titleEn: 'SEAISI Conference & Exhibition 2027',
cityFa: 'کوالالامپور', cityEn: 'Kuala Lumpur', countryFa: 'مالزی',
descFa: 'کنفرانس سالانه مؤسسه آهن و فولاد جنوب شرق آسیا برای صنعت فولاد منطقه آ‌سه‌آن.',
descEn: "The South East Asia Iron and Steel Institute's annual conference for the ASEAN steel industry." },
{ id: 'future-steel-forum-2027', iso: '2027-06-09', type: 'conference',
titleFa: 'فروم آینده فولاد ۲۰۲۷', titleEn: 'Future Steel Forum 2027',
cityFa: 'بولونیا', cityEn: 'Bologna', countryFa: 'ایتالیا',
descFa: 'کنفرانس شاخص جهانی در حوزه تحول دیجیتال، تولید هوشمند و کربن‌زدایی صنعت فولاد.',
descEn: 'A flagship conference on digital transformation, smart manufacturing and decarbonisation in steel.' },
{ id: 'gifa-metec-2027', iso: '2027-06-21', type: 'exhibition',
titleFa: 'نمایشگاه متالورژی و ریخته‌گری METEC / GIFA ۲۰۲۷', titleEn: 'GIFA / METEC 2027',
cityFa: 'دوسلدورف', cityEn: 'Düsseldorf', countryFa: 'آلمان',
descFa: 'مجموعه نمایشگاه‌های پیشروی جهان در حوزه ریخته‌گری و متالورژی، شامل متک برای فناوری فولادسازی.',
descEn: "The world's leading combined foundry and metallurgy trade-fairs, including METEC for steelmaking technology." },
{ id: 'stainless-steel-world-2027', iso: '2027-11-30', type: 'exhibition',
titleFa: 'کنفرانس و نمایشگاه جهانی فولاد ضدزنگ ۲۰۲۷', titleEn: 'Stainless Steel World 2027',
cityFa: 'ماستریخت', cityEn: 'Maastricht', countryFa: 'هلند',
descFa: 'کنفرانس و نمایشگاه پیشروی جهانی در حوزه فولاد ضدزنگ و آلیاژهای مقاوم به خوردگی.',
descEn: 'The leading global conference and exhibition dedicated to stainless steel and corrosion-resistant alloys.' },
];
// replace the old mock events with the real future ones
await db.prepare('DELETE FROM events').run();
const stmt = db.prepare(`
INSERT INTO events
(id, title_fa, title_en, date_fa, date_en, month_fa, month_en, year, type,
location_fa, location_en, city_fa, city_en, description_fa, description_en,
registration_open, sort_order)
VALUES
(@id, @title_fa, @title_en, @date_fa, @date_en, @month_fa, @month_en, @year, @type,
@location_fa, @location_en, @city_fa, @city_en, @description_fa, @description_en,
@registration_open, @sort_order)
`);
for (let i = 0; i < events.length; i++) {
const e = events[i];
const j = jalali(e.iso);
await stmt.run({
id: e.id,
title_fa: e.titleFa, title_en: e.titleEn,
date_fa: j.day, date_en: j.day,
month_fa: j.monthFa, month_en: j.monthEn,
year: j.year,
type: e.type,
location_fa: `${e.cityFa}، ${e.countryFa}`, location_en: `${e.cityEn}, ${e.countryFa}`,
city_fa: e.cityFa, city_en: e.cityEn,
description_fa: e.descFa, description_en: e.descEn,
registration_open: 1, sort_order: i,
});
console.log(`${e.id}${j.day} ${j.monthFa} ${j.year}`);
}
console.log(`\nDone: ${events.length} events inserted`);
await pool.end();