Merge pull request #97 from ArabCoders/dev

Added sort option for db:list
This commit is contained in:
Abdulmohsen
2022-05-05 23:38:34 +03:00
committed by GitHub
4 changed files with 10 additions and 12 deletions

View File

@@ -45,6 +45,7 @@ final class ListCommand extends Command
->addOption('season', null, InputOption::VALUE_REQUIRED, 'Select season number')
->addOption('episode', null, InputOption::VALUE_REQUIRED, 'Select episode number')
->addOption('id', null, InputOption::VALUE_REQUIRED, 'Select db record number')
->addOption('sort', null, InputOption::VALUE_REQUIRED, 'sort order by [id, updated]', 'updated')
->setDescription('List Database entries.');
foreach (array_keys(Guid::SUPPORTED) as $guid) {
@@ -138,7 +139,8 @@ final class ListCommand extends Command
$sql .= 'WHERE ' . implode(' AND ', $where);
}
$sql .= " ORDER BY updated DESC LIMIT :limit";
$sort = $input->getOption('sort') === 'id' ? 'id' : 'updated';
$sql .= " ORDER BY {$sort} DESC LIMIT :limit";
$stmt = $this->pdo->prepare($sql);
$stmt->execute($params);

View File

@@ -147,7 +147,7 @@ final class StateEntity implements StateInterface
$season = ag($this->meta, 'season', null);
$episode = ag($this->meta, 'episode', null);
return !(null === $season || null === $episode || empty($parents));
return !(null === $season || null === $episode || 0 === $episode || empty($parents));
}
public function getRelativeGuids(): array
@@ -156,7 +156,7 @@ final class StateEntity implements StateInterface
$season = ag($this->meta, 'season', null);
$episode = ag($this->meta, 'episode', null);
if (null === $season || null === $episode || count($parents) < 1) {
if (null === $season || null === $episode || 0 === $episode || empty($parents)) {
return [];
}

View File

@@ -582,6 +582,7 @@ class JellyfinServer implements ServerInterface
'enableUserData' => 'false',
'enableImages' => 'false',
'Fields' => 'ProviderIds,DateCreated,OriginalTitle',
'ExcludeLocationTypes' => 'Virtual',
]
)
);
@@ -648,7 +649,8 @@ class JellyfinServer implements ServerInterface
'enableUserData' => 'true',
'enableImages' => 'false',
'includeItemTypes' => 'Movie,Episode',
'Fields' => 'ProviderIds,DateCreated,OriginalTitle,SeasonUserData,DateLastSaved',
'Fields' => 'ProviderIds,DateCreated,OriginalTitle,SeasonUserData,DateLastSaved,PremiereDate,ProductionYear',
'ExcludeLocationTypes' => 'Virtual',
]
)
);
@@ -1554,10 +1556,7 @@ class JellyfinServer implements ServerInterface
$message .= ' Most likely unmatched item.';
}
$this->logger->info($message, [
'guids' => empty($guids) ? 'None' : $guids,
'rGuids' => $entity->hasRelativeGuid() ? $entity->getRelativeGuids() : 'None',
]);
$this->logger->info($message, ['guids' => empty($guids) ? 'None' : $guids]);
Data::increment($this->name, $type . '_ignored_no_supported_guid');

View File

@@ -1625,10 +1625,7 @@ class PlexServer implements ServerInterface
$message .= ' Most likely unmatched item.';
}
$this->logger->info($message, [
'guids' => empty($item->Guid) ? 'None' : $item->Guid,
'rGuids' => $entity->hasRelativeGuid() ? $entity->getRelativeGuids() : 'None',
]);
$this->logger->info($message, ['guids' => empty($item->Guid) ? 'None' : $item->Guid]);
Data::increment($this->name, $type . '_ignored_no_supported_guid');
return;