diff --git a/api/api.go b/api/api.go index 2365db424fa357e8865a693c5003ed3d324475a0..e312ff7d9e4c99e7abfb3e164d04fb9e5043881c 100644 --- a/api/api.go +++ b/api/api.go @@ -148,7 +148,8 @@ func CreateHandler(db, searchDB *sql.DB, house *housekeeper.House, dlc *download debug.PrintStack() }() h.f(ctx) - log.Printf("[R] %-10s %-4s %s\n", + log.Printf("[R] %s %-10s %-4s %s\n", + r.Header.Get("CF-Connecting-IP"), time.Since(start).String(), r.Method, r.URL.Path, diff --git a/dbmirror/dbmirror.go b/dbmirror/dbmirror.go index 4537a65f1148bd41062a2ed7b456ad9d197a77ed..52536c20f969f814cdc3ebfe92d5edc37477213a 100644 --- a/dbmirror/dbmirror.go +++ b/dbmirror/dbmirror.go @@ -100,7 +100,7 @@ func updateSet(c *osuapi.Client, db *sql.DB, set models.Set) error { } if len(bms) == 0 { // set has been deleted from osu!, so we do the same thing - return models.DeleteSet(db, set.ID) + return nil } // create the new set based on the information we can obtain from the diff --git a/models/beatmap.go b/models/beatmap.go index bc2a4ed71f4e3c83c29a87bef54c6dcc7f1e6ad2..78a8a791508549c4abade13d3fad5f42de520e45 100644 --- a/models/beatmap.go +++ b/models/beatmap.go @@ -47,9 +47,9 @@ type BeatmapChimu struct { } const beatmapFields = ` -id, parent_set_id, diff_name, file_md5, mode, bpm, -ar, od, cs, hp, total_length, hit_length, -playcount, passcount, max_combo, difficulty_rating` +beatmaps.id, beatmaps.parent_set_id, beatmaps.diff_name, beatmaps.file_md5, beatmaps.mode, beatmaps.bpm, +beatmaps.ar, beatmaps.od, beatmaps.cs, beatmaps.hp, beatmaps.total_length, beatmaps.hit_length, +beatmaps.playcount, beatmaps.passcount, beatmaps.max_combo, beatmaps.difficulty_rating` func readBeatmapsFromRows(rows *sql.Rows, capacity int) ([]Beatmap, error) { var err error @@ -75,17 +75,19 @@ func readBeatmapsFromRowsChimu(rows *sql.Rows, capacity int) ([]BeatmapChimu, er bms_chimu := make([]BeatmapChimu, 0, capacity) for rows.Next() { var bcm BeatmapChimu + var artist, title, creator string + err = rows.Scan( &bcm.ID, &bcm.ParentSetId, &bcm.DiffName, &bcm.FileMD5, &bcm.Mode, &bcm.BPM, &bcm.AR, &bcm.OD, &bcm.CS, &bcm.HP, &bcm.TotalLength, &bcm.HitLength, - &bcm.Playcount, &bcm.Passcount, &bcm.MaxCombo, &bcm.DifficultyRating, + &bcm.Playcount, &bcm.Passcount, &bcm.MaxCombo, &bcm.DifficultyRating, &artist, &title, &creator, ) if err != nil { return nil, err } - bcm.OsuFile = fmt.Sprintf("%d.osu", bcm.ID) + bcm.OsuFile = fmt.Sprintf("%s - %s (%s) [%s].osu", artist, title, creator, bcm.DiffName) bcm.DownloadPath = fmt.Sprintf("/d/%d", bcm.ParentSetId) bms_chimu = append(bms_chimu, bcm) } @@ -153,7 +155,7 @@ func FetchBeatmapsChimu(db *sql.DB, ids ...int) ([]BeatmapChimu, error) { return nil, nil } - q := `SELECT ` + beatmapFields + ` FROM beatmaps WHERE id IN (` + inClause(len(ids)) + `)` + q := `SELECT ` + beatmapFields + `, sets.artist, sets.title, sets.creator FROM beatmaps RIGHT JOIN sets ON sets.id = beatmaps.parent_set_id FROM beatmaps WHERE id IN (` + inClause(len(ids)) + `)` rows, err := db.Query(q, sIntToSInterface(ids)...) if err != nil { diff --git a/models/set_search.go b/models/set_search.go index 57b9f08fa5101871678ed3f50963c748737c1797..85d0b0e1c4e13fef852a770105681a93f81a7ad6 100644 --- a/models/set_search.go +++ b/models/set_search.go @@ -425,9 +425,9 @@ func SearchSetsChimu(db, searchDB *sql.DB, opts SearchOptions) ([]SetChimu, erro return nil, err } - b.OsuFile = fmt.Sprintf("%d.osu", b.ID) b.DownloadPath = fmt.Sprintf("/d/%d", b.ParentSetId) parentSet, ok := setMap[b.ParentSetId] + b.OsuFile = fmt.Sprintf("%s - %s (%s) [%s].osu", sets[parentSet].Artist, sets[parentSet].Title, sets[parentSet].Creator, b.DiffName) if !ok { continue }