🔖 Ic-merge is working now
This commit is contained in:
parent
8a3da4c5fe
commit
03fa525a00
5 changed files with 58 additions and 33 deletions
|
|
@ -139,11 +139,11 @@ func (m *Merger) getGameDetails(ctx context.Context, g *Game) error {
|
|||
return m.db.GetContext(ctx, g, `SELECT name, version FROM games ORDER BY id ASC LIMIT 1`)
|
||||
}
|
||||
|
||||
func (m *Merger) getGameCreated(ctx context.Context, date *uint64) error {
|
||||
func (m *Merger) getGameCreated(ctx context.Context, date *int64) error {
|
||||
return m.db.GetContext(ctx, date, `SELECT MIN(created) FROM games`)
|
||||
}
|
||||
|
||||
func (m *Merger) getGameUpdated(ctx context.Context, date *uint64) error {
|
||||
func (m *Merger) getGameUpdated(ctx context.Context, date *int64) error {
|
||||
return m.db.GetContext(ctx, date, `SELECT MAX(updated) FROM games`)
|
||||
}
|
||||
|
||||
|
|
@ -221,30 +221,6 @@ func (m *Merger) Merge(ctx context.Context) (g Game, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
type GameItem struct {
|
||||
Game string `db:"game"`
|
||||
GameID int64 `db:"game_id"`
|
||||
Text string `db:"name"`
|
||||
Emoji string
|
||||
Id int64 `db:"orig_id"`
|
||||
}
|
||||
|
||||
func (m *Merger) GameItems(ctx context.Context) (gits []GameItem, err error) {
|
||||
err = m.db.SelectContext(ctx, &gits, `
|
||||
SELECT
|
||||
g.name AS game,
|
||||
g.id AS game_id,
|
||||
it.name,
|
||||
it.emoji,
|
||||
it.id - 1 AS orig_id
|
||||
FROM games_items gi
|
||||
JOIN items it ON gi.item_id = it.id
|
||||
JOIN games g ON gi.game_id = g.id
|
||||
ORDER BY gi.id ASC
|
||||
`)
|
||||
return
|
||||
}
|
||||
|
||||
func (m *Merger) insertGames(ctx context.Context) (mp map[int64]Game, err error) {
|
||||
mp = make(map[int64]Game, len(m.games))
|
||||
var res sql.Result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue