mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 05:32:18 +00:00
0.0.20
- Return related data on artist/album/track endpoints - Scrobble table now links to tracks
This commit is contained in:
parent
99f9e7cfb3
commit
7c3b98a828
8 changed files with 33 additions and 19 deletions
|
@ -29,12 +29,17 @@ type ScrobbleResponseMeta struct {
|
|||
}
|
||||
|
||||
type ScrobbleResponseItem struct {
|
||||
UUID string `json:"uuid"`
|
||||
Timestamp time.Time `json:"time"`
|
||||
Artist string `json:"artist"`
|
||||
Album string `json:"album"`
|
||||
Track string `json:"track"`
|
||||
Source string `json:"source"`
|
||||
UUID string `json:"uuid"`
|
||||
Timestamp time.Time `json:"time"`
|
||||
Artist string `json:"artist"`
|
||||
Album string `json:"album"`
|
||||
Track ScrobbleTrackItem `json:"track"`
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
type ScrobbleTrackItem struct {
|
||||
UUID string `json:"uuid"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// insertScrobble - This will return if it exists or create it based on MBID > Name
|
||||
|
@ -62,7 +67,7 @@ func getScrobblesForUser(userUuid string, limit int, page int) (ScrobbleResponse
|
|||
}
|
||||
|
||||
rows, err := db.Query(
|
||||
"SELECT BIN_TO_UUID(`scrobbles`.`uuid`, true), `scrobbles`.`created_at`, GROUP_CONCAT(`artists`.`name` separator ','), `albums`.`name`, `tracks`.`name`, `scrobbles`.`source` FROM `scrobbles` "+
|
||||
"SELECT BIN_TO_UUID(`scrobbles`.`uuid`, true), `scrobbles`.`created_at`, GROUP_CONCAT(`artists`.`name` separator ','), `albums`.`name`, BIN_TO_UUID(`tracks`.`uuid`, true), `tracks`.`name`, `scrobbles`.`source` FROM `scrobbles` "+
|
||||
"JOIN tracks ON scrobbles.track = tracks.uuid "+
|
||||
"JOIN track_artist ON track_artist.track = tracks.uuid "+
|
||||
"JOIN track_album ON track_album.track = tracks.uuid "+
|
||||
|
@ -82,7 +87,7 @@ func getScrobblesForUser(userUuid string, limit int, page int) (ScrobbleResponse
|
|||
|
||||
for rows.Next() {
|
||||
item := ScrobbleResponseItem{}
|
||||
err := rows.Scan(&item.UUID, &item.Timestamp, &item.Artist, &item.Album, &item.Track, &item.Source)
|
||||
err := rows.Scan(&item.UUID, &item.Timestamp, &item.Artist, &item.Album, &item.Track.UUID, &item.Track.Name, &item.Source)
|
||||
if err != nil {
|
||||
log.Printf("Failed to fetch scrobbles: %+v", err)
|
||||
return scrobbleReq, errors.New("Failed to fetch scrobbles")
|
||||
|
|
|
@ -556,7 +556,7 @@ func getServerInfo(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
info := ServerInfo{
|
||||
Version: "0.0.19",
|
||||
Version: "0.0.20",
|
||||
RegistrationEnabled: cachedRegistrationEnabled,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue