2025-05-26 14:11:17 +07:00
|
|
|
use imphnen_cms::v1::landing::events::events_schema::EventsSchema;
|
2025-07-31 15:07:18 +07:00
|
|
|
use imphnen_utils::{get_iso_date};
|
2025-05-26 14:11:17 +07:00
|
|
|
use std::error::Error;
|
2025-06-28 20:21:20 +07:00
|
|
|
use surrealdb::engine::any;
|
2025-07-21 21:29:04 +07:00
|
|
|
use surrealdb::{opt::auth::Root, sql::Thing, Uuid}; // Added Uuid
|
2025-07-31 15:07:18 +07:00
|
|
|
|
2025-05-26 14:11:17 +07:00
|
|
|
#[tokio::main]
|
|
|
|
|
async fn main() -> Result<(), Box<dyn Error>> {
|
2025-09-26 23:15:33 +07:00
|
|
|
let env = &imphnen_libs::environment::ENV;
|
2025-06-28 20:21:20 +07:00
|
|
|
let db = any::connect(&env.surrealdb_url).await?;
|
2025-05-26 14:11:17 +07:00
|
|
|
db.signin(Root {
|
|
|
|
|
username: &env.surrealdb_username,
|
|
|
|
|
password: &env.surrealdb_password,
|
|
|
|
|
})
|
|
|
|
|
.await?;
|
2025-07-31 15:07:18 +07:00
|
|
|
db.use_ns(env.surrealdb_namespace.clone())
|
|
|
|
|
.use_db(env.surrealdb_dbname.clone())
|
2025-05-26 14:11:17 +07:00
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
let events = vec![
|
|
|
|
|
(
|
|
|
|
|
"Tech Conference 2025",
|
|
|
|
|
"Annual technology conference featuring the latest innovations in software development, AI, and cloud computing.",
|
|
|
|
|
"https://techconf2025.example.com",
|
|
|
|
|
150.0,
|
|
|
|
|
Some("Jakarta Convention Center".to_string()),
|
|
|
|
|
false,
|
|
|
|
|
"2025-06-15T09:00:00Z",
|
|
|
|
|
"2025-06-17T18:00:00Z",
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
"Online Web Development Workshop",
|
|
|
|
|
"Comprehensive workshop covering modern web development frameworks including React, Vue, and Angular.",
|
|
|
|
|
"https://webdev-workshop.example.com",
|
|
|
|
|
75.0,
|
|
|
|
|
None,
|
|
|
|
|
true,
|
|
|
|
|
"2025-07-10T14:00:00Z",
|
|
|
|
|
"2025-07-10T17:00:00Z",
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
"Startup Pitch Competition",
|
|
|
|
|
"Exciting competition where emerging startups present their innovative ideas to a panel of expert judges and investors.",
|
|
|
|
|
"https://startup-pitch.example.com",
|
|
|
|
|
25.0,
|
|
|
|
|
Some("Innovation Hub Surabaya".to_string()),
|
|
|
|
|
false,
|
|
|
|
|
"2025-08-05T10:00:00Z",
|
|
|
|
|
"2025-08-05T16:00:00Z",
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
"Digital Marketing Masterclass",
|
|
|
|
|
"Learn advanced digital marketing strategies, social media optimization, and data-driven marketing techniques.",
|
|
|
|
|
"https://digital-marketing.example.com",
|
|
|
|
|
100.0,
|
|
|
|
|
None,
|
|
|
|
|
true,
|
|
|
|
|
"2025-09-20T13:00:00Z",
|
|
|
|
|
"2025-09-22T15:00:00Z",
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
|
2025-07-21 21:29:04 +07:00
|
|
|
for (
|
|
|
|
|
name,
|
|
|
|
|
description,
|
|
|
|
|
detail_link,
|
|
|
|
|
price,
|
|
|
|
|
location,
|
|
|
|
|
is_online,
|
|
|
|
|
start_date,
|
|
|
|
|
end_date,
|
|
|
|
|
) in events
|
|
|
|
|
{
|
|
|
|
|
let uuid = Uuid::new_v4().to_string(); // Generate new UUID
|
2025-05-26 14:11:17 +07:00
|
|
|
let event = EventsSchema {
|
2025-07-21 21:29:04 +07:00
|
|
|
id: Thing::from(("app_events", uuid.as_str())), // Use generated UUID
|
2025-05-26 14:11:17 +07:00
|
|
|
name: name.into(),
|
|
|
|
|
description: description.into(),
|
|
|
|
|
detail_link: detail_link.into(),
|
|
|
|
|
price,
|
|
|
|
|
location,
|
|
|
|
|
is_online,
|
|
|
|
|
is_deleted: false,
|
|
|
|
|
start_date: start_date.into(),
|
|
|
|
|
end_date: end_date.into(),
|
|
|
|
|
created_at: get_iso_date(),
|
|
|
|
|
updated_at: get_iso_date(),
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-21 21:29:04 +07:00
|
|
|
db.create::<Option<EventsSchema>>(("app_events", uuid.as_str())) // Use generated UUID
|
2025-05-26 14:11:17 +07:00
|
|
|
.content(event)
|
|
|
|
|
.await?;
|
|
|
|
|
|
2025-07-21 21:29:04 +07:00
|
|
|
println!(
|
|
|
|
|
"✅ Inserted event: {} ({})",
|
|
|
|
|
name,
|
|
|
|
|
if is_online { "Online" } else { "In-person" }
|
|
|
|
|
);
|
2025-05-26 14:11:17 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
println!("✅ All Events seeded");
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|