return more child counts and format sql
This commit is contained in:
@@ -56,7 +56,7 @@ func (c *Controller) ServeHome(r *http.Request) *Response {
|
||||
// ** begin playlists box
|
||||
user := r.Context().Value(CtxUser).(*db.User)
|
||||
c.DB.
|
||||
Where("user_id = ?", user.ID).
|
||||
Where("user_id=?", user.ID).
|
||||
Limit(20).
|
||||
Find(&data.Playlists)
|
||||
//
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"senan.xyz/g/gonic/db"
|
||||
)
|
||||
|
||||
@@ -18,9 +19,9 @@ func playlistParseLine(c *Controller, path string) (int, error) {
|
||||
var track db.Track
|
||||
query := c.DB.Raw(`
|
||||
SELECT tracks.id FROM TRACKS
|
||||
JOIN albums ON tracks.album_id = albums.id
|
||||
WHERE (? || '/' || albums.left_path || albums.right_path || '/' || tracks.filename) = ?
|
||||
`, c.MusicPath, path)
|
||||
JOIN albums ON tracks.album_id=albums.id
|
||||
WHERE (? || '/' || albums.left_path || albums.right_path || '/' || tracks.filename)=?`,
|
||||
c.MusicPath, path)
|
||||
err := query.First(&track).Error
|
||||
switch {
|
||||
case gorm.IsRecordNotFoundError(err):
|
||||
|
||||
Reference in New Issue
Block a user