tribally report logic
This commit is contained in:
@@ -16,7 +16,7 @@ type (
|
||||
NhTriballyUserModel interface {
|
||||
nhTriballyUserModel
|
||||
withSession(session sqlx.Session) NhTriballyUserModel
|
||||
FindUpdateTriballyUsers(ctx context.Context, t time.Time, count int) ([]*TriballyUserChapter, error)
|
||||
FindUpdateTriballyUsers(ctx context.Context, start, end time.Time, count int) ([]*TriballyUserChapter, error)
|
||||
}
|
||||
|
||||
customNhTriballyUserModel struct {
|
||||
@@ -32,10 +32,10 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (m *customNhTriballyUserModel) FindUpdateTriballyUsers(ctx context.Context, t time.Time, count int) ([]*TriballyUserChapter, error) {
|
||||
query := fmt.Sprintf("SELECT t.uid, t.chapter, MAX(g.chapter) as max_chapter, g.updated_at FROM nh_tribally_user t JOIN nh_game_report g ON t.uid = g.uid WHERE g.updated_at >= ? GROUP BY uid LIMIT ?")
|
||||
func (m *customNhTriballyUserModel) FindUpdateTriballyUsers(ctx context.Context, start, end time.Time, count int) ([]*TriballyUserChapter, error) {
|
||||
query := fmt.Sprintf("SELECT t.uid, t.chapter, MAX(g.chapter) as max_chapter, g.updated_at FROM nh_tribally_user t JOIN nh_game_report g ON t.uid = g.uid WHERE g.updated_at >= ? AND g.updated_at < ? AND g.chapter > t.chapter GROUP BY uid LIMIT ?")
|
||||
var result []*TriballyUserChapter
|
||||
err := m.conn.QueryRowsCtx(ctx, &result, query, t, count)
|
||||
err := m.conn.QueryRowsCtx(ctx, &result, query, start, end, count)
|
||||
if err != nil && !errors.Is(err, sqlx.ErrNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user