Redesign dashboard: refined-minimal layout with product thumbnails
Move the dashboard from boxed glass cards to an airy, hairline-separated layout where type and whitespace carry the page, then surface listing images as the visual anchor. - Solid surfaces (drop backdrop-filter glass, per spec); calm flat field with a single cool top-glow replacing the drifting aurora and dot-grid. - Recent results / recent alerts are now product feeds with 52px thumbnails, listing titles, and price; image_url threaded through ResultRow/AlertRow (data already stored, just unsurfaced). - ListResults gains an OnlyAlerted filter so the alerts panel reuses its decryption path instead of a raw query. - Dashboard recent results capped at 8 for a balanced snapshot.
This commit is contained in:
@@ -791,6 +791,8 @@ type ResultsQuery struct {
|
||||
// Exception: yahoo-auctions-jp is auction-only — NULL ends_at there means
|
||||
// the actor's ending_date didn't parse, and those rows are also dropped.
|
||||
ExcludeEnded bool
|
||||
// OnlyAlerted restricts to rows that triggered a deal alert.
|
||||
OnlyAlerted bool
|
||||
}
|
||||
|
||||
func (s *Store) ListResults(ctx context.Context, q ResultsQuery) ([]models.Result, error) {
|
||||
@@ -817,6 +819,9 @@ func (s *Store) ListResults(ctx context.Context, q ResultsQuery) ([]models.Resul
|
||||
conds = append(conds, `((ends_at IS NULL AND source != 'yahoo-auctions-jp') OR ends_at > ?)`)
|
||||
args = append(args, time.Now().UTC())
|
||||
}
|
||||
if q.OnlyAlerted {
|
||||
conds = append(conds, `alerted = 1`)
|
||||
}
|
||||
where := ""
|
||||
if len(conds) > 0 {
|
||||
where = `WHERE ` + strings.Join(conds, ` AND `)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"veola/internal/db"
|
||||
"veola/templates"
|
||||
@@ -36,7 +34,7 @@ func (a *App) dashboardData(r *http.Request) (templates.DashboardData, error) {
|
||||
if err != nil {
|
||||
return templates.DashboardData{}, err
|
||||
}
|
||||
results, err := a.Store.ListResults(r.Context(), db.ResultsQuery{Limit: 20, ExcludeEnded: true})
|
||||
results, err := a.Store.ListResults(r.Context(), db.ResultsQuery{Limit: 8, ExcludeEnded: true})
|
||||
if err != nil {
|
||||
return templates.DashboardData{}, err
|
||||
}
|
||||
@@ -55,6 +53,7 @@ func (a *App) dashboardData(r *http.Request) (templates.DashboardData, error) {
|
||||
Currency: r.Currency,
|
||||
Source: r.Source,
|
||||
URL: r.URL,
|
||||
ImageURL: r.ImageURL,
|
||||
FoundAt: r.FoundAt,
|
||||
Alerted: r.Alerted,
|
||||
})
|
||||
@@ -80,36 +79,20 @@ func (a *App) dashboardData(r *http.Request) (templates.DashboardData, error) {
|
||||
}
|
||||
|
||||
func alertsRecent(a *App, r *http.Request, itemNames map[int64]string) ([]templates.AlertRow, error) {
|
||||
rows, err := a.Store.DB.QueryContext(r.Context(), `
|
||||
SELECT item_id, price, currency, found_at FROM results
|
||||
WHERE alerted = 1 ORDER BY found_at DESC LIMIT 5
|
||||
`)
|
||||
results, err := a.Store.ListResults(r.Context(), db.ResultsQuery{OnlyAlerted: true, Limit: 5})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []templates.AlertRow
|
||||
for rows.Next() {
|
||||
var (
|
||||
itemID int64
|
||||
price sql.NullFloat64
|
||||
currency string
|
||||
foundAt time.Time
|
||||
)
|
||||
if err := rows.Scan(&itemID, &price, ¤cy, &foundAt); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var p *float64
|
||||
if price.Valid {
|
||||
v := price.Float64
|
||||
p = &v
|
||||
}
|
||||
out := make([]templates.AlertRow, 0, len(results))
|
||||
for _, res := range results {
|
||||
out = append(out, templates.AlertRow{
|
||||
ItemName: itemNames[itemID],
|
||||
Price: p,
|
||||
Currency: currency,
|
||||
FoundAt: foundAt,
|
||||
ItemName: itemNames[res.ItemID],
|
||||
Title: res.Title,
|
||||
Price: res.Price,
|
||||
Currency: res.Currency,
|
||||
ImageURL: res.ImageURL,
|
||||
FoundAt: res.FoundAt,
|
||||
})
|
||||
}
|
||||
return out, rows.Err()
|
||||
return out, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user