Skip to content

Commit bcd2890

Browse files
authored
fix: write episode progress timeline (#756)
1 parent f2bc55b commit bcd2890

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

ctrl/update_episode_progress.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ func (ctl Ctrl) UpdateEpisodesCollection(
9090
return err
9191
}
9292

93-
err = ctl.timeline.ChangeEpisodeStatus(ctx, u, s, e)
93+
if t == 0 {
94+
return nil
95+
}
96+
97+
err = ctl.timeline.ChangeEpisodeStatus(ctx, u, s, e, t)
9498

9599
return errgo.Wrap(err, "timeline.ChangeEpisodeStatus")
96100
}
@@ -125,7 +129,11 @@ func (ctl Ctrl) UpdateEpisodeCollection(
125129
return err
126130
}
127131

128-
err = ctl.timeline.ChangeEpisodeStatus(ctx, u, s, e)
132+
if t == 0 {
133+
return nil
134+
}
135+
136+
err = ctl.timeline.ChangeEpisodeStatus(ctx, u, s, e, t)
129137

130138
return errgo.Wrap(err, "timeline.ChangeEpisodeStatus")
131139
}

internal/mocks/TimeLineService.go

+11-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/pkg/test/web.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ func MockTimeLineSrv(m timeline.Service) fx.Option {
288288

289289
mocker.EXPECT().ChangeSubjectCollection(mock.Anything, mock.Anything,
290290
mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
291-
mocker.EXPECT().ChangeEpisodeStatus(mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
291+
mocker.EXPECT().
292+
ChangeEpisodeStatus(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
292293
mocker.EXPECT().ChangeSubjectProgress(mock.Anything, mock.Anything, mock.Anything,
293294
mock.Anything, mock.Anything).Return(nil)
294295

internal/timeline/domain.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type Service interface {
3939
u auth.Auth,
4040
sbj model.Subject,
4141
episode episode.Episode,
42+
t collection.EpisodeCollection,
4243
) error
4344

4445
ChangeSubjectProgress(

internal/timeline/kafka.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func (m kafkaClient) ChangeEpisodeStatus(
104104
u auth.Auth,
105105
sbj model.Subject,
106106
episode episode.Episode,
107+
t collection.EpisodeCollection,
107108
) error {
108109
ctx, canal := context.WithTimeout(ctx, defaultTimeout)
109110
defer canal()
@@ -121,7 +122,7 @@ func (m kafkaClient) ChangeEpisodeStatus(
121122
},
122123
Episode: tlEpisode{
123124
ID: episode.ID,
124-
Status: int(episode.Sort),
125+
Status: t,
125126
},
126127
CreatedAt: time.Now().Unix(),
127128
Source: timelineSourceAPI,

internal/timeline/type.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type timelineValue struct {
2626
}
2727

2828
type tlEpisode struct {
29-
ID model.EpisodeID `json:"id"`
30-
Status int `json:"status"`
29+
ID model.EpisodeID `json:"id"`
30+
Status collection.EpisodeCollection `json:"status"`
3131
}
3232

3333
type tlSubjectCollect struct {

0 commit comments

Comments
 (0)