diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 388e81a8..98986002 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ stages: - bundle variables: - VERSION: 0.0.19 + VERSION: 0.0.20 build-go: image: golang:1.16.2 diff --git a/docs/changelog.md b/docs/changelog.md index b8bf03dd..19f67cc1 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,7 @@ +# 0.0.20 +- Return related data on artist/album/track endpoints +- Scrobble table now links to tracks + # 0.0.19 - Tidy init/goscrobble.service - Add routers for Artist/Album/Track endpoints + basic pages diff --git a/internal/goscrobble/scrobble.go b/internal/goscrobble/scrobble.go index 433bd0b3..d5934449 100644 --- a/internal/goscrobble/scrobble.go +++ b/internal/goscrobble/scrobble.go @@ -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") diff --git a/internal/goscrobble/server.go b/internal/goscrobble/server.go index a4729fd5..c06e9237 100644 --- a/internal/goscrobble/server.go +++ b/internal/goscrobble/server.go @@ -556,7 +556,7 @@ func getServerInfo(w http.ResponseWriter, r *http.Request) { } info := ServerInfo{ - Version: "0.0.19", + Version: "0.0.20", RegistrationEnabled: cachedRegistrationEnabled, } diff --git a/web/src/Components/ScrobbleTable.js b/web/src/Components/ScrobbleTable.js index 2c18c0c8..5fcc495f 100644 --- a/web/src/Components/ScrobbleTable.js +++ b/web/src/Components/ScrobbleTable.js @@ -1,4 +1,5 @@ import React from "react"; +import { Link } from 'react-router-dom'; const ScrobbleTable = (props) => { return ( @@ -19,11 +20,17 @@ const ScrobbleTable = (props) => { props.data.map(function (element) { let localTime = new Date(element.time); return - {localTime.toLocaleString()} - {element.track} - {element.artist} - {element.album} - {element.source} + {localTime.toLocaleString()} + + {element.track.name} + + + {element.artist} + {element.album} + {element.source} ; }) } diff --git a/web/src/Pages/Profile.js b/web/src/Pages/Profile.js index c2af7400..425c5343 100644 --- a/web/src/Pages/Profile.js +++ b/web/src/Pages/Profile.js @@ -24,7 +24,6 @@ const Profile = (route) => { getProfile(username) .then(data => { setProfile(data); - console.log(data) setLoading(false); }) }, [username]) diff --git a/web/src/Pages/Reset.js b/web/src/Pages/Reset.js index 53a7ab72..90243e31 100644 --- a/web/src/Pages/Reset.js +++ b/web/src/Pages/Reset.js @@ -35,7 +35,6 @@ const Reset = (route) => { validateResetPassword(reqToken) .then(data => { setReset(data); - console.log(data) setLoading(false); }) }, [reqToken]) diff --git a/web/src/Pages/Track.js b/web/src/Pages/Track.js index 1e46b613..3ea9be02 100644 --- a/web/src/Pages/Track.js +++ b/web/src/Pages/Track.js @@ -44,7 +44,7 @@ const Track = (route) => { } let length = "0"; - if (track.length !== '') { + if (track.length && track.length !== '') { length = new Date(track.length * 1000).toISOString().substr(11, 8) } @@ -57,7 +57,7 @@ const Track = (route) => {
MusicBrainzId: {track.mbid}
SpotifyID: {track.spotify_id}
- Track Length: {length} + Track Length: {length && length}
);