Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix revision tracking #41

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading