v18
This commit is contained in:
parent
c0f0a02ee2
commit
241cf7f5b9
133
generate_startup_content.php
Normal file
133
generate_startup_content.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
function generate_startup_updates() {
|
||||
$db = db();
|
||||
|
||||
// Fetch all startups and their founders
|
||||
$stmt = $db->query("SELECT s.id as startup_id, s.name as startup_name, s.founder_id, u.full_name as founder_name
|
||||
FROM startups s
|
||||
JOIN users u ON s.founder_id = u.id");
|
||||
$startups = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$update_templates = [
|
||||
"Product Milestone" => [
|
||||
"We've just hit our first 1,000 active users!",
|
||||
"Major update: Version 2.0 is now live with enhanced AI features.",
|
||||
"Our Beta testing phase is officially complete, and the feedback has been incredible.",
|
||||
"Excited to announce our new partnership with a leading industry provider."
|
||||
],
|
||||
"Funding Update" => [
|
||||
"We've reached 50% of our funding goal! Huge thanks to our early supporters.",
|
||||
"New institutional investor joined our seed round today.",
|
||||
"Only $50k left to close our current funding round. Don't miss out!",
|
||||
"We are extending our round due to high demand from strategic partners."
|
||||
],
|
||||
"Team & Growth" => [
|
||||
"Welcoming our new CTO, who brings 10+ years of experience in the sector.",
|
||||
"We've just moved into our new office space to accommodate our growing team.",
|
||||
"Hiring alert: We are looking for talented developers and marketing specialists.",
|
||||
"Our team just won the 'Most Innovative Startup' award at the local tech summit!"
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($startups as $startup) {
|
||||
$num_updates = rand(2, 3);
|
||||
for ($i = 0; $i < $num_updates; $i++) {
|
||||
$category = array_rand($update_templates);
|
||||
$title = $category . ": " . $startup['startup_name'] . " Progress";
|
||||
$content = $update_templates[$category][array_rand($update_templates[$category])];
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO startup_updates (startup_id, founder_id, title, content, created_at)
|
||||
VALUES (:sid, :fid, :title, :content, :created)");
|
||||
// Randomize creation date over the last 30 days
|
||||
$days_ago = rand(1, 30);
|
||||
$created_at = date('Y-m-d H:i:s', strtotime("-$days_ago days"));
|
||||
|
||||
$stmt->execute([
|
||||
'sid' => $startup['startup_id'],
|
||||
'fid' => $startup['founder_id'],
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'created' => $created_at
|
||||
]);
|
||||
}
|
||||
echo "Generated updates for " . $startup['startup_name'] . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function simulate_funding_progress() {
|
||||
$db = db();
|
||||
|
||||
// Fetch all active funding rounds
|
||||
$stmt = $db->query("SELECT fr.id as round_id, fr.startup_id, fr.funding_goal, fr.funding_raised
|
||||
FROM funding_rounds fr
|
||||
WHERE fr.status = 'Active'");
|
||||
$rounds = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Fetch all investors
|
||||
$stmt = $db->query("SELECT id FROM users WHERE role = 'investor'");
|
||||
$investors = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
if (empty($investors)) return;
|
||||
|
||||
foreach ($rounds as $round) {
|
||||
// Decide how many investments to simulate for this round
|
||||
$num_investments = rand(1, 4);
|
||||
$total_new_raised = 0;
|
||||
|
||||
for ($i = 0; $i < $num_investments; $i++) {
|
||||
$investor_id = $investors[array_rand($investors)];
|
||||
|
||||
// Random investment amount between $5,000 and $50,000
|
||||
$amount = rand(5, 50) * 1000;
|
||||
|
||||
// Don't exceed the goal significantly
|
||||
if ($round['funding_raised'] + $total_new_raised + $amount > $round['funding_goal'] * 1.1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$status = (rand(0, 10) > 2) ? 'approved' : 'pending'; // 80% chance of being approved
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO investments (investor_id, startup_id, funding_round_id, amount, status, created_at)
|
||||
VALUES (:iid, :sid, :frid, :amount, :status, :created)");
|
||||
|
||||
$days_ago = rand(1, 15);
|
||||
$created_at = date('Y-m-d H:i:s', strtotime("-$days_ago days"));
|
||||
|
||||
$stmt->execute([
|
||||
'iid' => $investor_id,
|
||||
'sid' => $round['startup_id'],
|
||||
'frid' => $round['round_id'],
|
||||
'amount' => $amount,
|
||||
'status' => $status,
|
||||
'created' => $created_at
|
||||
]);
|
||||
|
||||
if ($status === 'approved') {
|
||||
$total_new_raised += $amount;
|
||||
}
|
||||
}
|
||||
|
||||
// Update funding_raised in both tables
|
||||
if ($total_new_raised > 0) {
|
||||
$stmt = $db->prepare("UPDATE funding_rounds SET funding_raised = funding_raised + :amount WHERE id = :id");
|
||||
$stmt->execute(['amount' => $total_new_raised, 'id' => $round['round_id']]);
|
||||
|
||||
$stmt = $db->prepare("UPDATE startups SET funding_raised = funding_raised + :amount WHERE id = :id");
|
||||
$stmt->execute(['amount' => $total_new_raised, 'id' => $round['startup_id']]);
|
||||
}
|
||||
|
||||
echo "Simulated " . $num_investments . " investments for startup ID " . $round['startup_id'] . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
echo "Starting startup content generation...\n";
|
||||
generate_startup_updates();
|
||||
echo "Starting funding simulation...\n";
|
||||
simulate_funding_progress();
|
||||
echo "Success!\n";
|
||||
} catch (Exception $e) {
|
||||
echo "Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user