mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +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
|
- build
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
VERSION: 0.1.51
|
VERSION: 0.1.6
|
||||||
|
|
||||||
build-go:
|
build-go:
|
||||||
image: golang:1.17
|
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
|
# 0.1.51
|
||||||
- Fixed image resize to maintain aspect ratio
|
- Fixed image resize to maintain aspect ratio
|
||||||
|
|
||||||
|
@ -132,6 +132,7 @@ func getArtistByUUID(uuid string) (Artist, error) {
|
|||||||
return artist, nil
|
return artist, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getTopArtists - 0 UUID will return all
|
||||||
func getTopArtists(userUuid string, dayRange string) (TopArtists, error) {
|
func getTopArtists(userUuid string, dayRange string) (TopArtists, error) {
|
||||||
var topArtist TopArtists
|
var topArtist TopArtists
|
||||||
|
|
||||||
@ -140,17 +141,21 @@ func getTopArtists(userUuid string, dayRange string) (TopArtists, error) {
|
|||||||
dateClause = " AND DATE(created_at) > SUBDATE(CURRENT_DATE, " + dayRange + ") "
|
dateClause = " AND DATE(created_at) > SUBDATE(CURRENT_DATE, " + dayRange + ") "
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := db.Query("SELECT BIN_TO_UUID(`artists`.`uuid`, true), `artists`.`name`, IFNULL(BIN_TO_UUID(`artists`.`uuid`, true),''), count(*) "+
|
whereClause := ""
|
||||||
"FROM `scrobbles` "+
|
if userUuid != "0" {
|
||||||
"JOIN `tracks` ON `tracks`.`uuid` = `scrobbles`.`track` "+
|
whereClause = "WHERE `scrobbles`.`user` = UUID_TO_BIN('" + userUuid + "', true) "
|
||||||
"JOIN track_artist ON track_artist.track = tracks.uuid "+
|
}
|
||||||
"JOIN artists ON track_artist.artist = artists.uuid "+
|
|
||||||
"WHERE `scrobbles`.`user` = UUID_TO_BIN(?, true) "+
|
rows, err := db.Query("SELECT BIN_TO_UUID(`artists`.`uuid`, true), `artists`.`name`, IFNULL(BIN_TO_UUID(`artists`.`uuid`, true),''), count(*) " +
|
||||||
dateClause+
|
"FROM `scrobbles` " +
|
||||||
"GROUP BY `artists`.`uuid` "+
|
"JOIN `tracks` ON `tracks`.`uuid` = `scrobbles`.`track` " +
|
||||||
"ORDER BY count(*) DESC "+
|
"JOIN track_artist ON track_artist.track = tracks.uuid " +
|
||||||
"LIMIT 14;",
|
"JOIN artists ON track_artist.artist = artists.uuid " +
|
||||||
userUuid)
|
whereClause +
|
||||||
|
dateClause +
|
||||||
|
"GROUP BY `artists`.`uuid` " +
|
||||||
|
"ORDER BY count(*) DESC " +
|
||||||
|
"LIMIT 14;")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to fetch top artist: %+v", err)
|
log.Printf("Failed to fetch top artist: %+v", err)
|
||||||
return topArtist, errors.New("Failed to fetch top artist")
|
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 {
|
if len(res.Artists.Artists[0].Images) > 0 {
|
||||||
toUpdate[uuid] = res.Artists.Artists[0].Images[0].URL
|
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()
|
rows.Close()
|
||||||
|
|
||||||
@ -314,8 +315,9 @@ func (user *User) updateImageDataFromSpotify() {
|
|||||||
if len(res.Albums.Albums[0].Images) > 0 {
|
if len(res.Albums.Albums[0].Images) > 0 {
|
||||||
toUpdate[uuid] = res.Albums.Albums[0].Images[0].URL
|
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()
|
rows.Close()
|
||||||
|
|
||||||
|
@ -825,7 +825,7 @@ func getServerInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info := ServerInfo{
|
info := ServerInfo{
|
||||||
Version: "0.1.51",
|
Version: "0.1.6",
|
||||||
RegistrationEnabled: registrationEnabled,
|
RegistrationEnabled: registrationEnabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,17 +192,21 @@ func getTopTracks(userUuid string, dayRange string) (TopTracks, error) {
|
|||||||
dateClause = " AND DATE(created_at) > SUBDATE(CURRENT_DATE, " + dayRange + ") "
|
dateClause = " AND DATE(created_at) > SUBDATE(CURRENT_DATE, " + dayRange + ") "
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := db.Query("SELECT BIN_TO_UUID(`tracks`.`uuid`, true), `tracks`.`name`, IFNULL(BIN_TO_UUID(`albums`.`uuid`, true),''), count(*) "+
|
whereClause := ""
|
||||||
"FROM `scrobbles` "+
|
if userUuid != "0" {
|
||||||
"JOIN `tracks` ON `tracks`.`uuid` = `scrobbles`.`track` "+
|
whereClause = "WHERE `scrobbles`.`user` = UUID_TO_BIN('" + userUuid + "', true) "
|
||||||
"JOIN track_album ON track_album.track = tracks.uuid "+
|
}
|
||||||
"JOIN albums ON track_album.album = albums.uuid "+
|
|
||||||
"WHERE `user` = UUID_TO_BIN(?, true) "+
|
rows, err := db.Query("SELECT BIN_TO_UUID(`tracks`.`uuid`, true), `tracks`.`name`, IFNULL(BIN_TO_UUID(`albums`.`uuid`, true),''), count(*) " +
|
||||||
dateClause+
|
"FROM `scrobbles` " +
|
||||||
"GROUP BY `scrobbles`.`track` "+
|
"JOIN `tracks` ON `tracks`.`uuid` = `scrobbles`.`track` " +
|
||||||
"ORDER BY count(*) DESC "+
|
"JOIN track_album ON track_album.track = tracks.uuid " +
|
||||||
"LIMIT 14",
|
"JOIN albums ON track_album.album = albums.uuid " +
|
||||||
userUuid)
|
whereClause +
|
||||||
|
dateClause +
|
||||||
|
"GROUP BY `scrobbles`.`track` " +
|
||||||
|
"ORDER BY count(*) DESC " +
|
||||||
|
"LIMIT 14")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to fetch top tracks: %+v", err)
|
log.Printf("Failed to fetch top tracks: %+v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user