Skip to content

Commit

Permalink
Build: Allow getting latest per platform
Browse files Browse the repository at this point in the history
  • Loading branch information
AniLeo committed Sep 23, 2024
1 parent 65bf47f commit 2e7ba40
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions objects/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,24 @@ public static function query_to_builds(mysqli_result $query) : array
return $a_builds;
}

public static function get_latest() : ?Build
public static function get_latest(?string $platform) : ?Build
{
$db = getDatabase();

$query = mysqli_query($db, "SELECT * FROM `builds`
WHERE `broken` IS NULL OR `broken` != 1
ORDER BY `merge_datetime` DESC LIMIT 1;");
if (is_null($platform))
{
$query = mysqli_query($db, "SELECT * FROM `builds`
WHERE `broken` IS NULL OR `broken` != 1
ORDER BY `merge_datetime` DESC LIMIT 1;");
}
else
{
$s_platform = mysqli_real_escape_string($db, $platform);

$query = mysqli_query($db, "SELECT * FROM `builds`
WHERE `filename_{$s_platform}` IS NOT NULL
ORDER BY `merge_datetime` DESC LIMIT 1;");
}

if (is_bool($query))
return null;
Expand Down

0 comments on commit 2e7ba40

Please sign in to comment.