Fix history and collection bug

This commit is contained in:
Timothy Warren 2020-04-23 20:03:55 -04:00
parent e2e23a290f
commit 62be0beae6
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']; $data = $entry['relationships'][$this->type][$id]['attributes'];
$title = $this->linkTitle($data); $title = $this->linkTitle($data);
$imgUrl = "images/{$this->type}/{$id}.webp"; $imgUrl = "images/{$this->type}/{$id}.webp";
$item = max($entry['attributes']['changedData']['progress']); $item = array_pop($entry['attributes']['changedData']['progress']);
return HistoryItem::from([ return HistoryItem::from([
'action' => "{$this->progressAction} {$item}", 'action' => "{$this->progressAction} {$item}",

View File

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