mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.0.28
- Fix mobile view on user pages - Fix favicon issue - Return Artist UUID with scrobble list
This commit is contained in:
parent
f4bdf3f730
commit
489527c8f9
11 changed files with 58 additions and 46 deletions
|
@ -31,7 +31,7 @@ type ScrobbleResponseMeta struct {
|
|||
type ScrobbleResponseItem struct {
|
||||
UUID string `json:"uuid"`
|
||||
Timestamp time.Time `json:"time"`
|
||||
Artist string `json:"artist"`
|
||||
Artist ScrobbleTrackItem `json:"artist"`
|
||||
Album string `json:"album"`
|
||||
Track ScrobbleTrackItem `json:"track"`
|
||||
Source string `json:"source"`
|
||||
|
@ -67,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`, BIN_TO_UUID(`tracks`.`uuid`, true), `tracks`.`name`, `scrobbles`.`source` FROM `scrobbles` "+
|
||||
"SELECT BIN_TO_UUID(`scrobbles`.`uuid`, true), `scrobbles`.`created_at`, BIN_TO_UUID(`artists`.`uuid`, true), `artists`.`name`, `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 "+
|
||||
|
@ -87,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.UUID, &item.Track.Name, &item.Source)
|
||||
err := rows.Scan(&item.UUID, &item.Timestamp, &item.Artist.UUID, &item.Artist.Name, &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")
|
||||
|
|
|
@ -733,7 +733,7 @@ func getServerInfo(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
info := ServerInfo{
|
||||
Version: "0.0.27",
|
||||
Version: "0.0.28",
|
||||
RegistrationEnabled: cachedRegistrationEnabled,
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package goscrobble
|
|||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
@ -165,10 +166,15 @@ func (track *Track) updateTrack(col string, val string, tx *sql.Tx) error {
|
|||
|
||||
func getTrackByUUID(uuid string) (Track, error) {
|
||||
var track Track
|
||||
err := db.QueryRow("SELECT BIN_TO_UUID(`uuid`, true), `name`, IFNULL(`desc`,''), IFNULL(`img`,''), `length`, `mbid`, `spotify_id` FROM `tracks` WHERE `uuid` = UUID_TO_BIN(?, true)",
|
||||
err := db.QueryRow("SELECT BIN_TO_UUID(`tracks`.`uuid`, true), `tracks`.`name`, IFNULL(`albums`.`desc`,''), IFNULL(`albums`.`img`,''), `tracks`.`length`, `tracks`.`mbid`, `tracks`.`spotify_id` "+
|
||||
"FROM `tracks` "+
|
||||
"LEFT JOIN track_album ON track_album.track = tracks.uuid "+
|
||||
"LEFT JOIN albums ON track_album.album = albums.uuid "+
|
||||
"WHERE `tracks`.`uuid` = UUID_TO_BIN(?, true)",
|
||||
uuid).Scan(&track.UUID, &track.Name, &track.Desc, &track.Img, &track.Length, &track.MusicBrainzID, &track.SpotifyID)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return track, errors.New("Invalid UUID")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue