mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-21 16:11:56 +00:00
0.1.6
- Allow UUID of 0 in artists/{uuid}/top to return site-wide stats - Set images as failed if cannot find in spotify to prevent oversearching
This commit is contained in:
parent
9bfb9358df
commit
ea1451ab76
@ -2,7 +2,7 @@ stages:
|
||||
- build
|
||||
|
||||
variables:
|
||||
VERSION: 0.1.51
|
||||
VERSION: 0.1.6
|
||||
|
||||
build-go:
|
||||
image: golang:1.17
|
||||
|
@ -1,3 +1,7 @@
|
||||
# 0.1.6
|
||||
- Allow UUID of 0 in artists/{uuid}/top to return site-wide stats
|
||||
- Set images as failed if cannot find in spotify to prevent oversearching
|
||||
|
||||
# 0.1.51
|
||||
- Fixed image resize to maintain aspect ratio
|
||||
|
||||
|
@ -132,6 +132,7 @@ func getArtistByUUID(uuid string) (Artist, error) {
|
||||
return artist, nil
|
||||
}
|
||||
|
||||
// getTopArtists - 0 UUID will return all
|
||||
func getTopArtists(userUuid string, dayRange string) (TopArtists, error) {
|
||||
var topArtist TopArtists
|
||||
|
||||
@ -140,17 +141,21 @@ func getTopArtists(userUuid string, dayRange string) (TopArtists, error) {
|
||||
dateClause = " AND DATE(created_at) > SUBDATE(CURRENT_DATE, " + dayRange + ") "
|
||||
}
|
||||
|
||||
whereClause := ""
|
||||
if userUuid != "0" {
|
||||
whereClause = "WHERE `scrobbles`.`user` = UUID_TO_BIN('" + userUuid + "', true) "
|
||||
}
|
||||
|
||||
rows, err := db.Query("SELECT BIN_TO_UUID(`artists`.`uuid`, true), `artists`.`name`, IFNULL(BIN_TO_UUID(`artists`.`uuid`, true),''), count(*) " +
|
||||
"FROM `scrobbles` " +
|
||||
"JOIN `tracks` ON `tracks`.`uuid` = `scrobbles`.`track` " +
|
||||
"JOIN track_artist ON track_artist.track = tracks.uuid " +
|
||||
"JOIN artists ON track_artist.artist = artists.uuid " +
|
||||
"WHERE `scrobbles`.`user` = UUID_TO_BIN(?, true) "+
|
||||
whereClause +
|
||||
dateClause +
|
||||
"GROUP BY `artists`.`uuid` " +
|
||||
"ORDER BY count(*) DESC " +
|
||||
"LIMIT 14;",
|
||||
userUuid)
|
||||
"LIMIT 14;")
|
||||
if err != nil {
|
||||
log.Printf("Failed to fetch top artist: %+v", err)
|
||||
return topArtist, errors.New("Failed to fetch top artist")
|
||||
|
@ -270,8 +270,9 @@ func (user *User) updateImageDataFromSpotify() {
|
||||
if len(res.Artists.Artists[0].Images) > 0 {
|
||||
toUpdate[uuid] = res.Artists.Artists[0].Images[0].URL
|
||||
}
|
||||
} else {
|
||||
_, _ = db.Exec("UPDATE `artists` SET `img` = 'none' WHERE `uuid` = UUID_TO_BIN(?,true)", uuid)
|
||||
}
|
||||
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
@ -314,8 +315,9 @@ func (user *User) updateImageDataFromSpotify() {
|
||||
if len(res.Albums.Albums[0].Images) > 0 {
|
||||
toUpdate[uuid] = res.Albums.Albums[0].Images[0].URL
|
||||
}
|
||||
} else {
|
||||
_, _ = db.Exec("UPDATE `albums` SET `img` = 'none' WHERE `uuid` = UUID_TO_BIN(?,true)", uuid)
|
||||
}
|
||||
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
|
@ -825,7 +825,7 @@ func getServerInfo(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
info := ServerInfo{
|
||||
Version: "0.1.51",
|
||||
Version: "0.1.6",
|
||||
RegistrationEnabled: registrationEnabled,
|
||||
}
|
||||
|
||||
|
@ -192,17 +192,21 @@ func getTopTracks(userUuid string, dayRange string) (TopTracks, error) {
|
||||
dateClause = " AND DATE(created_at) > SUBDATE(CURRENT_DATE, " + dayRange + ") "
|
||||
}
|
||||
|
||||
whereClause := ""
|
||||
if userUuid != "0" {
|
||||
whereClause = "WHERE `scrobbles`.`user` = UUID_TO_BIN('" + userUuid + "', true) "
|
||||
}
|
||||
|
||||
rows, err := db.Query("SELECT BIN_TO_UUID(`tracks`.`uuid`, true), `tracks`.`name`, IFNULL(BIN_TO_UUID(`albums`.`uuid`, true),''), count(*) " +
|
||||
"FROM `scrobbles` " +
|
||||
"JOIN `tracks` ON `tracks`.`uuid` = `scrobbles`.`track` " +
|
||||
"JOIN track_album ON track_album.track = tracks.uuid " +
|
||||
"JOIN albums ON track_album.album = albums.uuid " +
|
||||
"WHERE `user` = UUID_TO_BIN(?, true) "+
|
||||
whereClause +
|
||||
dateClause +
|
||||
"GROUP BY `scrobbles`.`track` " +
|
||||
"ORDER BY count(*) DESC " +
|
||||
"LIMIT 14",
|
||||
userUuid)
|
||||
"LIMIT 14")
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Failed to fetch top tracks: %+v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user