Fix history and collection bug
All checks were successful
timw4mail/HummingBirdAnimeClient/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2020-04-23 20:03:55 -04:00
parent a97a31ea41
commit ae276a536f
2 changed files with 16 additions and 1 deletions

View File

@ -162,7 +162,7 @@ abstract class HistoryTransformer {
$data = $entry['relationships'][$this->type][$id]['attributes'];
$title = $this->linkTitle($data);
$imgUrl = "images/{$this->type}/{$id}.webp";
$item = max($entry['attributes']['changedData']['progress']);
$item = array_pop($entry['attributes']['changedData']['progress']);
return HistoryItem::from([
'action' => "{$this->progressAction} {$item}",

View File

@ -134,6 +134,8 @@ final class AnimeCollection extends Collection {
$id = $data['id'];
$anime = (object)$this->animeModel->getAnimeById($id);
$this->db->beginTransaction();
$this->db->set([
'hummingbird_id' => $id,
'slug' => $anime->slug,
@ -150,6 +152,8 @@ final class AnimeCollection extends Collection {
$this->updateMediaLink($id, $data['media_id']);
$this->updateGenres($id);
$this->db->commit();
}
/**
@ -193,6 +197,8 @@ final class AnimeCollection extends Collection {
$media = $data['media_id'];
unset($data['hummingbird_id'], $data['media_id']);
$this->db->beginTransaction();
// If updating from the 'add' page, there
// might be no data to actually update in
// the anime_set table
@ -206,6 +212,8 @@ final class AnimeCollection extends Collection {
// Update media and genres
$this->updateMediaLink($id, $media);
$this->updateGenres($id);
$this->db->commit();
}
/**
@ -264,11 +272,18 @@ final class AnimeCollection extends Collection {
return;
}
$this->db->beginTransaction();
$this->db->where('hummingbird_id', $data['hummingbird_id'])
->delete('genre_anime_set_link');
$this->db->where('hummingbird_id', $data['hummingbird_id'])
->delete('anime_set_media_link');
$this->db->where('hummingbird_id', $data['hummingbird_id'])
->delete('anime_set');
$this->db->commit();
}
/**