Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/#19 #50

Merged
merged 20 commits into from
Oct 23, 2022
Merged

Issue/#19 #50

merged 20 commits into from
Oct 23, 2022

Conversation

tkc66-buzz
Copy link
Contributor

@tkc66-buzz tkc66-buzz commented Oct 15, 2022

ref: #19

@tkc66-buzz tkc66-buzz self-assigned this Oct 15, 2022
@tkc66-buzz tkc66-buzz marked this pull request as ready for review October 15, 2022 15:44
pkg/model/talk.go Outdated Show resolved Hide resolved
pkg/infrastructure/db/redis.go Outdated Show resolved Hide resolved
pkg/infrastructure/db/redis.go Outdated Show resolved Hide resolved
pkg/dkwatcher/dkwatcher.go Outdated Show resolved Hide resolved
pkg/model/talk.go Outdated Show resolved Hide resolved
pkg/dkwatcher/dkwatcher.go Outdated Show resolved Hide resolved
Comment on lines 108 to 134
nextTalk, err := track.Talks.GetNextTalk()
if err != nil {
logger.Info("nextTalk is none")
continue
}
if !track.Talks.IsStartNextTalkSoon(howManyMinutesUntilNotify) {
logger.Info("nextTalk is not start soon. trackNo:%s", track.Id)
continue
}
val, err := redisClient.GetNextTalkNotification(ctx, int(nextTalk.Id))
if err != nil {
logger.Error(xerrors.Errorf("message: %w", err), "db.GetNextTalkNotification() was failed")
return err
}
if val != "" {
logger.Info("nextTalkNotification already sent . trackNo:%s", track.Id)
continue
}
currentTalk, err := track.Talks.GetCurrentTalk()
if err != nil {
logger.Info("currentTalk is none")
currentTalk = &model.Talk{}
}
if err := mw.SetTrack(track); err != nil {
logger.Error(xerrors.Errorf("message: %w", err), "mw.SetTrack was failed")
continue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dreamkast から取得してきたデータはまず mw に保存して、それから dkwatcher -> notifier に通知するかを判断するべきです。(でないと obswatcher が古いタイムテーブルを見続ける可能性があるため)

そのため、mw.SetTrack() を 108 行目に移動してもらえますか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます。確かに先にmwに保存するべきですね。
f7dd3c1

Comment on lines 117 to 125
val, err := redisClient.GetNextTalkNotification(ctx, int(nextTalk.Id))
if err != nil {
logger.Error(xerrors.Errorf("message: %w", err), "db.GetNextTalkNotification() was failed")
return err
}
if val != "" {
logger.Info("nextTalkNotification already sent . trackNo:%s", track.Id)
continue
}
Copy link
Member

@ShotaKitazawa ShotaKitazawa Oct 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nits なので直さなくて問題ないです)

  • ここで取り出す val は early return するかどうかの判断以外に利用しないので、以下のようにスコープを閉じてしまう書き方をするほうが自分は好きです (val をここ以外で利用しないことが明確になるため)
		if val, err := redisClient.GetNextTalkNotification(ctx, int(nextTalk.Id)); err != nil {
			logger.Error(xerrors.Errorf("message: %w", err), "db.GetNextTalkNotification() was failed")
			return err
		} else if val != "" {
			logger.Info("nextTalkNotification already sent . trackNo:%s", track.Id)
			continue
		}

@ShotaKitazawa
Copy link
Member

PR 出しました、確認お願いします #55

@tkc66-buzz
Copy link
Contributor Author

PR 出しました、確認お願いします #55

ありがとうございます、mergeさせていただきました

@ShotaKitazawa ShotaKitazawa merged commit a74df16 into main Oct 23, 2022
@ShotaKitazawa ShotaKitazawa deleted the issue/#19 branch October 23, 2022 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants