Skip to content

Commit

Permalink
fill in created_at/updated_at for media (#30)
Browse files Browse the repository at this point in the history
media.created_at/imported_at is all current timestamp for sofa import in prod
  • Loading branch information
davidharting authored Dec 21, 2024
1 parent 00b67b4 commit 6a7f6f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/Actions/SofaImport/SofaRowHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ private function handleMedia(): int

$isNew = $this->media->wasRecentlyCreated;

// created_at and updated_at were not fillable before I ran this the first time.
// So update that so that media timestamps reflect when I added them to lists rather than current time
if (! $isNew) {
$this->media->update([
'updated_at' => $this->row->dateAdded,
'created_at' => $this->row->dateAdded,
]);
}

// TODO: Add a note if the item already exists (i.e., was imported from goodreads without a note)
if (! $isNew && ! is_null($this->row->notes)) {
$this->media->note = $this->row->notes;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Media extends Model
{
use HasFactory;

protected $fillable = ['year', 'title', 'note', 'media_type_id', 'creator_id'];
protected $fillable = ['year', 'title', 'note', 'media_type_id', 'creator_id', 'created_at', 'updated_at'];

// TODO: Add enum and cast for MediaType

Expand Down

0 comments on commit 6a7f6f4

Please sign in to comment.