<?php

namespace App\Services;

use App\Core\Database;

class HomepageDeploymentService
{

public static function deploy(
int $conferenceId,
int $userId
): bool
{

$db=
Database::getInstance();

return
$db
->prepare("

INSERT INTO
conference_home_deployments(

conference_id,

deployment_name,

ring_name,

traffic_percent,

deployment_state,

created_by

)

VALUES(

?,

?,

'canary',

10,

'running',

?

)

")

->execute([

$conferenceId,

'Deploy '
.
date(
'Ymd_His'
),

$userId

]);

}

public static function latest(
int $conferenceId
)
{

$db=
Database::getInstance();

$stmt=
$db
->prepare("

SELECT *

FROM
conference_home_deployments

WHERE conference_id=?

ORDER BY id DESC

LIMIT 1

");

$stmt
->execute([

$conferenceId

]);

return
$stmt
->fetch()

??

[];

}

}
