From afcc7574d2a37ee43600a9a003cf36d38cf08034 Mon Sep 17 00:00:00 2001 From: Chuck Adams Date: Sun, 8 Dec 2024 20:13:28 -0700 Subject: [PATCH] fix revision tracking (#41) * fix: ListServiceInterface::setName() to distinguish the commands * fix: restore use of getRevisionTime() --- src/Commands/Sync/Download/AbstractDownloadCommand.php | 1 + src/Commands/Sync/Meta/AbstractMetaFetchCommand.php | 1 + src/Services/List/AbstractListService.php | 10 ++++++---- src/Services/List/ListServiceInterface.php | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Commands/Sync/Download/AbstractDownloadCommand.php b/src/Commands/Sync/Download/AbstractDownloadCommand.php index 8782252..b2f301c 100644 --- a/src/Commands/Sync/Download/AbstractDownloadCommand.php +++ b/src/Commands/Sync/Download/AbstractDownloadCommand.php @@ -38,6 +38,7 @@ protected function configure(): void ->addOption($category, null, InputOption::VALUE_OPTIONAL, "List of $category to request") ->addOption('force', null, InputOption::VALUE_NONE, 'Force download even if file exists') ->addOption('download-all', null, InputOption::VALUE_NONE, "Download all $category"); + $this->listService->setName($this->getName()); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Commands/Sync/Meta/AbstractMetaFetchCommand.php b/src/Commands/Sync/Meta/AbstractMetaFetchCommand.php index 8f02247..84cf222 100644 --- a/src/Commands/Sync/Meta/AbstractMetaFetchCommand.php +++ b/src/Commands/Sync/Meta/AbstractMetaFetchCommand.php @@ -60,6 +60,7 @@ protected function configure(): void InputOption::VALUE_REQUIRED, "List of $category (separated by commas) to explicitly update" ); + $this->listService->setName($this->getName()); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Services/List/AbstractListService.php b/src/Services/List/AbstractListService.php index f105a24..5e3e29b 100644 --- a/src/Services/List/AbstractListService.php +++ b/src/Services/List/AbstractListService.php @@ -21,12 +21,16 @@ public function __construct( protected ResourceType $type, protected string $origin = 'wp_org', ) { - $this->name = "list-{$type->plural()}@$origin"; $this->loadLatestRevisions(); } //region Public API + public function setName(string $name): void + { + $this->name = $name; + } + /** @return array */ public function getItems(): array { @@ -37,9 +41,7 @@ public function getItems(): array /** @return array */ public function getUpdatedItems(): array { - // HACK: return everything until meta and download versions of ListService get different names - return $this->meta->getOpenVersions(-1); // FIXME: make getRevisionTime() work again - // return $this->meta->getOpenVersions($this->getRevisionTime()); + return $this->meta->getOpenVersions($this->getRevisionTime()); } public function preserveRevision(): string diff --git a/src/Services/List/ListServiceInterface.php b/src/Services/List/ListServiceInterface.php index 9901aac..15f6d2a 100644 --- a/src/Services/List/ListServiceInterface.php +++ b/src/Services/List/ListServiceInterface.php @@ -6,6 +6,8 @@ interface ListServiceInterface { + public function setName(string $name): void; + /** @return array */ public function getItems(): array;