Adding popularity for queued apps (#20)

This commit is contained in:
ilumos 2018-02-03 15:24:09 +00:00
parent 5d6bebb3fe
commit 04fcfed124
4 changed files with 9 additions and 3 deletions

View file

@ -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();
});

View file

@ -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;
}

View file

@ -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,
]);

View file

@ -123,6 +123,7 @@ class StartDownloading extends Command
private function nextApp()
{
return SteamQueueItem::where('status', 'queued')
->orderBy('popularity', 'desc')
->first();
}