refactor: extract scanContinueWatchingEntry helper
This commit is contained in:
@@ -48,22 +48,8 @@ LIMIT ?`, userID, needle, pattern, pattern, pattern, pattern, limit)
|
|||||||
|
|
||||||
items := make([]GetContinueWatchingEntriesRow, 0, int(limit))
|
items := make([]GetContinueWatchingEntriesRow, 0, int(limit))
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var item GetContinueWatchingEntriesRow
|
item, err := scanContinueWatchingEntry(rows)
|
||||||
if err := rows.Scan(
|
if err != nil {
|
||||||
&item.ID,
|
|
||||||
&item.UserID,
|
|
||||||
&item.AnimeID,
|
|
||||||
&item.CurrentEpisode,
|
|
||||||
&item.CurrentTimeSeconds,
|
|
||||||
&item.DurationSeconds,
|
|
||||||
&item.CreatedAt,
|
|
||||||
&item.UpdatedAt,
|
|
||||||
&item.TitleOriginal,
|
|
||||||
&item.TitleEnglish,
|
|
||||||
&item.TitleJapanese,
|
|
||||||
&item.ImageUrl,
|
|
||||||
&item.AnimeDurationSeconds,
|
|
||||||
); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
items = append(items, item)
|
items = append(items, item)
|
||||||
@@ -75,6 +61,26 @@ LIMIT ?`, userID, needle, pattern, pattern, pattern, pattern, limit)
|
|||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func scanContinueWatchingEntry(rows scanner) (GetContinueWatchingEntriesRow, error) {
|
||||||
|
var item GetContinueWatchingEntriesRow
|
||||||
|
err := rows.Scan(
|
||||||
|
&item.ID,
|
||||||
|
&item.UserID,
|
||||||
|
&item.AnimeID,
|
||||||
|
&item.CurrentEpisode,
|
||||||
|
&item.CurrentTimeSeconds,
|
||||||
|
&item.DurationSeconds,
|
||||||
|
&item.CreatedAt,
|
||||||
|
&item.UpdatedAt,
|
||||||
|
&item.TitleOriginal,
|
||||||
|
&item.TitleEnglish,
|
||||||
|
&item.TitleJapanese,
|
||||||
|
&item.ImageUrl,
|
||||||
|
&item.AnimeDurationSeconds,
|
||||||
|
)
|
||||||
|
return item, err
|
||||||
|
}
|
||||||
|
|
||||||
func (q *Queries) GetCommandPaletteWatchlist(ctx context.Context, userID string, query string, limit int64) ([]GetUserWatchListRow, error) {
|
func (q *Queries) GetCommandPaletteWatchlist(ctx context.Context, userID string, query string, limit int64) ([]GetUserWatchListRow, error) {
|
||||||
if userID == "" {
|
if userID == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@@ -158,3 +164,7 @@ func commandPalettePattern(query string) (string, string) {
|
|||||||
needle := strings.ToLower(strings.TrimSpace(query))
|
needle := strings.ToLower(strings.TrimSpace(query))
|
||||||
return needle, "%" + needle + "%"
|
return needle, "%" + needle + "%"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type scanner interface {
|
||||||
|
Scan(dest ...interface{}) error
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user