mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-03-31 17:15:38 +00:00
implement torrent statuses management #28
This commit is contained in:
parent
3cbc6ea90f
commit
989f2f3311
64 changed files with 1051 additions and 282 deletions
|
|
@ -192,7 +192,8 @@ class TorrentService
|
|||
int $added,
|
||||
array $locales,
|
||||
bool $sensitive,
|
||||
bool $approved
|
||||
bool $approved,
|
||||
bool $status
|
||||
): ?Torrent
|
||||
{
|
||||
$torrent = $this->addTorrent(
|
||||
|
|
@ -204,7 +205,8 @@ class TorrentService
|
|||
),
|
||||
$locales,
|
||||
$sensitive,
|
||||
$approved
|
||||
$approved,
|
||||
$status
|
||||
);
|
||||
|
||||
$filesystem = new Filesystem();
|
||||
|
|
@ -249,7 +251,8 @@ class TorrentService
|
|||
array $keywords,
|
||||
array $locales,
|
||||
bool $sensitive,
|
||||
bool $approved
|
||||
bool $approved,
|
||||
bool $status
|
||||
): ?Torrent
|
||||
{
|
||||
$torrent = new Torrent();
|
||||
|
|
@ -261,6 +264,7 @@ class TorrentService
|
|||
$torrent->setLocales($locales);
|
||||
$torrent->setSensitive($sensitive);
|
||||
$torrent->setApproved($approved);
|
||||
$torrent->setStatus($status);
|
||||
|
||||
$this->entityManagerInterface->persist($torrent);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
|
@ -292,6 +296,30 @@ class TorrentService
|
|||
return $torrent;
|
||||
}
|
||||
|
||||
public function toggleTorrentStatus(
|
||||
int $torrentId
|
||||
): ?Torrent
|
||||
{
|
||||
$torrent = $this->getTorrent($torrentId);
|
||||
|
||||
$torrent->setStatus(
|
||||
!$torrent->isStatus() // toggle current value
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($torrent);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
$this->updateTorrentLocales(
|
||||
$torrent->getId()
|
||||
);
|
||||
|
||||
$this->updateTorrentSensitive(
|
||||
$torrent->getId()
|
||||
);
|
||||
|
||||
return $torrent;
|
||||
}
|
||||
|
||||
public function getTorrentScrapeQueue(): ?Torrent
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
|
|
@ -305,40 +333,48 @@ class TorrentService
|
|||
}
|
||||
|
||||
public function findTorrents(
|
||||
int $userId,
|
||||
array $keywords,
|
||||
array $locales,
|
||||
?bool $sensitive,
|
||||
?bool $approved,
|
||||
int $limit,
|
||||
int $offset
|
||||
?bool $status,
|
||||
int $limit,
|
||||
int $offset
|
||||
) : array
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
->getRepository(Torrent::class)
|
||||
->findTorrents(
|
||||
$userId,
|
||||
$keywords,
|
||||
$locales,
|
||||
$sensitive,
|
||||
$approved,
|
||||
$status,
|
||||
$limit,
|
||||
$offset
|
||||
);
|
||||
}
|
||||
|
||||
public function findTorrentsTotal(
|
||||
int $userId,
|
||||
array $keywords,
|
||||
array $locales,
|
||||
?bool $sensitive,
|
||||
?bool $approved
|
||||
?bool $approved,
|
||||
?bool $status
|
||||
) : int
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
->getRepository(Torrent::class)
|
||||
->findTorrentsTotal(
|
||||
$userId,
|
||||
$keywords,
|
||||
$locales,
|
||||
$sensitive,
|
||||
$approved
|
||||
$approved,
|
||||
$status
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue