Fix dashboard failing to load episodes after RSS import
Build and Deploy / build-and-deploy (push) Successful in 52s

The root cause was that modernc.org/sqlite stores time.Time as strings
but cannot scan strings back into time.Time, causing ListEpisodes to
fail. Changed PublishedAt and CreatedAt in store structs from time.Time
to string, with format/parse handled at the application level.

Also fixed a secondary issue where the published_at format stored during
import had a duplicated timezone offset.
This commit is contained in:
2026-07-12 16:17:51 -04:00
parent b075433e6e
commit 9011a00475
5 changed files with 28 additions and 14 deletions
+5 -6
View File
@@ -2,7 +2,6 @@ package store
import (
"database/sql"
"time"
_ "modernc.org/sqlite"
)
@@ -15,7 +14,7 @@ type User struct {
PodcastSlug string
PodcastImage string
PodcastAuthor string
CreatedAt time.Time
CreatedAt string
}
type Episode struct {
@@ -25,8 +24,8 @@ type Episode struct {
Description string
AudioPath string
ImagePath string
PublishedAt time.Time
CreatedAt time.Time
PublishedAt string
CreatedAt string
}
type Store struct {
@@ -173,7 +172,7 @@ func (s *Store) GetEpisode(id int64) (*Episode, error) {
return e, nil
}
func (s *Store) CreateEpisode(userID int64, title, description, audioPath, imagePath string, publishedAt time.Time) (int64, error) {
func (s *Store) CreateEpisode(userID int64, title, description, audioPath, imagePath, publishedAt string) (int64, error) {
res, err := s.db.Exec("INSERT INTO episodes (user_id, title, description, audio_path, image_path, published_at) VALUES (?, ?, ?, ?, ?, ?)",
userID, title, description, audioPath, imagePath, publishedAt)
if err != nil {
@@ -182,7 +181,7 @@ func (s *Store) CreateEpisode(userID int64, title, description, audioPath, image
return res.LastInsertId()
}
func (s *Store) UpdateEpisode(id int64, title, description, audioPath, imagePath string, publishedAt time.Time) error {
func (s *Store) UpdateEpisode(id int64, title, description, audioPath, imagePath, publishedAt string) error {
_, err := s.db.Exec("UPDATE episodes SET title=?, description=?, audio_path=?, image_path=?, published_at=? WHERE id=?",
title, description, audioPath, imagePath, publishedAt, id)
return err