mirror of
https://github.com/zeropingheroes/lancache-autofill
synced 2024-11-25 09:00:18 +00:00
Adding popularity for queued apps (#20)
This commit is contained in:
parent
5d6bebb3fe
commit
04fcfed124
4 changed files with 9 additions and 3 deletions
|
@ -53,6 +53,7 @@ class InitialiseDatabase extends Command
|
|||
$table->integer('app_id');
|
||||
$table->string('status');
|
||||
$table->string('platform');
|
||||
$table->integer('popularity')->nullable()->default(1);
|
||||
$table->string('message')->nullable();
|
||||
});
|
||||
|
||||
|
|
|
@ -81,11 +81,13 @@ class QueueUsersRecentApps extends Command
|
|||
// Queue each platform separately
|
||||
foreach ($platforms as $platform) {
|
||||
|
||||
$alreadyQueued = SteamQueueItem::where('app_id', $app->appId)
|
||||
$existingQueueItem = SteamQueueItem::where('app_id', $app->appId)
|
||||
->where('platform', $platform)
|
||||
->first();
|
||||
|
||||
if ($alreadyQueued) {
|
||||
if ($existingQueueItem) {
|
||||
$existingQueueItem->popularity++;
|
||||
$existingQueueItem->save();
|
||||
$this->warn('Steam app "' . $app->name . '" on platform "' . ucfirst($platform) . '" already in download queue');
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ class ShowQueue extends Command
|
|||
}
|
||||
|
||||
$steamQueueItems = SteamQueueItem::where('status', $status)
|
||||
->orderBy('popularity', 'desc')
|
||||
->orderBy('message')
|
||||
->get();
|
||||
|
||||
|
@ -90,7 +91,7 @@ class ShowQueue extends Command
|
|||
$this->{$messageStyle}(ucfirst($status) . ':');
|
||||
|
||||
$table = new Table($this->output);
|
||||
$table->setHeaders(['Name', 'Platform', 'App ID', 'Message']);
|
||||
$table->setHeaders(['Name', 'Platform', 'Popularity', 'App ID', 'Message']);
|
||||
|
||||
foreach ($steamQueueItems as $steamQueueItem) {
|
||||
if (isset($steamQueueItem->app->name)) {
|
||||
|
@ -101,6 +102,7 @@ class ShowQueue extends Command
|
|||
$table->addRow([
|
||||
$appName,
|
||||
ucfirst($steamQueueItem->platform),
|
||||
$steamQueueItem->popularity,
|
||||
$steamQueueItem->app_id,
|
||||
$steamQueueItem->message,
|
||||
]);
|
||||
|
|
|
@ -123,6 +123,7 @@ class StartDownloading extends Command
|
|||
private function nextApp()
|
||||
{
|
||||
return SteamQueueItem::where('status', 'queued')
|
||||
->orderBy('popularity', 'desc')
|
||||
->first();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue