Skip to content

Commit

Permalink
fix revision tracking (#41)
Browse files Browse the repository at this point in the history
* fix: ListServiceInterface::setName() to distinguish the commands

* fix: restore use of getRevisionTime()
  • Loading branch information
chuckadams authored Dec 9, 2024
1 parent c1d9fe9 commit afcc757
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Commands/Sync/Download/AbstractDownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/Commands/Sync/Meta/AbstractMetaFetchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/Services/List/AbstractListService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string|int, string[]> */
public function getItems(): array
{
Expand All @@ -37,9 +41,7 @@ public function getItems(): array
/** @return array<string|int, 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
Expand Down
2 changes: 2 additions & 0 deletions src/Services/List/ListServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

interface ListServiceInterface
{
public function setName(string $name): void;

/** @return array<string, string[]> */
public function getItems(): array;

Expand Down

0 comments on commit afcc757

Please sign in to comment.