jikan-rest icon indicating copy to clipboard operation
jikan-rest copied to clipboard

Removing deleted resources

Open irfan-dahir opened this issue 2 years ago • 4 comments

Jikan needs to be able to keep track of pending entries and make sure they're not viewable in search.

Additionally, entries may be removed by MAL which end up giving a 404 where-as they still show up in search and as a resource.

References: https://discord.com/channels/460491088004907029/475889826852503554/994158995264786532 https://discord.com/channels/460491088004907029/989255412358451240/990855325043261440

irfan-dahir avatar Jul 06 '22 08:07 irfan-dahir

We might want to have versioning on the Ids we are downloading at the time of running the anime:indexer manga:indexer, and the next time it runs, take a diff, and remove the elements from the db which has been removed from the id cache.

pushrbx avatar Jul 06 '22 11:07 pushrbx

@pushrbx That's a very solid idea. I think that may be the best approach 👍

irfan-dahir avatar Jul 06 '22 18:07 irfan-dahir

I imagine it like this:

private function fetchMalIds() : array
{
  // ...
  $existingStuff = Storage::get('indexer/anime_mal_id.json');
  if ($existingStuff) {
    $a = json_decode($existingStuff, true);
    $b = json_decode(
            file_get_contents('https://raw.githubusercontent.com/seanbreckenridge/mal-id-cache/master/cache/anime_cache.json'),
            true
        );
    $b = $b['sfw'] + $b['nsfw'];
    $diff = array_diff($a, $b);
    remove_diff_from_db($diff);
  }
  // ...
}

pushrbx avatar Jul 06 '22 23:07 pushrbx

That's a suitable approach. I think it would be best to implement this as a separate artisan command for this and add it to the scheduler as a daily task.

e.g php artisan indexer:anime-remove-deleted, php artisan indexer:manga-remove-deleted

irfan-dahir avatar Jul 07 '22 14:07 irfan-dahir