Skip to content

Commit

Permalink
Filter out assets / slow down cdn purge
Browse files Browse the repository at this point in the history
  • Loading branch information
Tam committed Oct 6, 2023
1 parent efb22b6 commit d38bfb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/jobs/RevalidateAssetJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public function execute($queue): void

if (empty($doKey)) return;

sleep(5);

$client = Craft::createGuzzleClient();
$assets = Asset::find()->id($this->assetIds)->all();

Expand All @@ -36,6 +34,7 @@ public function execute($queue): void
->get('https://api.digitalocean.com/v2/cdn/endpoints?per_page=200', ['headers' => $headers])
->getBody()
->getContents();
sleep(1);

$allSpaces = json_decode($response)->endpoints;
$spaceFiles = [];
Expand Down Expand Up @@ -71,6 +70,7 @@ public function execute($queue): void
]);

$queue->setProgress(++$i / $total * 100);
sleep(1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/Revalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ private function pushRelatedElements(Element $element, array $exclude = null): a
])
->andWhere(['not in', 'sourceId', $exclude ?? []])
->andWhere(['not in', 'targetId', $exclude ?? []])
->andWhere(['not in', 'elements.type', ['craft\\elements\\Asset']])
->andWhere([
'revisionId' => null,
'draftId' => null,
])
->andWhere(['!=', 'elements.type', 'Asset'])
->groupBy('elements.type')
->pairs();

Expand Down

0 comments on commit d38bfb5

Please sign in to comment.