Skip to content

Commit

Permalink
Merge pull request #20 from CyberAgentHack/fix-viewing-history
Browse files Browse the repository at this point in the history
fix viewing history
  • Loading branch information
MasatoraAtarashi authored Feb 9, 2024
2 parents d191e02 + 7c5840a commit 4a6405d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ func (a *App) runWithContext(ctx context.Context) (err error) {

// usecase
database := &repository.Database{
Episode: database.NewEpisode(mysql),
Series: database.NewSeries(mysql),
Season: database.NewSeason(mysql),
Genre: database.NewGenre(mysql),
Episode: database.NewEpisode(mysql),
Series: database.NewSeries(mysql),
Season: database.NewSeason(mysql),
Genre: database.NewGenre(mysql),
ViewingHistory: database.NewViewingHistory(mysql),
}
uc := usecase.NewUsecase(database, redis)

Expand Down
4 changes: 3 additions & 1 deletion pkg/repository/database/viewing_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package database
import (
"context"
"database/sql"
"errors"

"github.com/CyberAgentHack/server-performance-tuning-2023/pkg/entity"
"github.com/CyberAgentHack/server-performance-tuning-2023/pkg/errcode"
Expand Down Expand Up @@ -38,7 +39,8 @@ func (e *ViewingHistory) Get(ctx context.Context, id string, userID string) (*en
&viewingHistory.Duration,
&viewingHistory.LastViewingAt,
)
if err != nil {

if err != nil && !errors.Is(err, sql.ErrNoRows) {
return nil, errcode.New(err)
}

Expand Down
1 change: 0 additions & 1 deletion pkg/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ type ListSeasonsParams struct {
}

type ViewingHistory interface {
Create(ctx context.Context, viewingHistory *entity.ViewingHistory) (*entity.ViewingHistory, error)
Get(ctx context.Context, id string, userID string) (*entity.ViewingHistory, error)
BatchGet(ctx context.Context, ids []string, userID string) (entity.ViewingHistories, error)
}
Expand Down

0 comments on commit 4a6405d

Please sign in to comment.