Skip to content

Commit

Permalink
vingo: more serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Jun 22, 2024
1 parent ec0b38d commit 98c1bf4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vingo/database/scans.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package database
import "time"

type Scan struct {
ScanTime time.Time
Card string
ScanTime time.Time `json:"scan_time"`
Card string `json:"card"`
}

type Present struct {
Expand All @@ -14,9 +14,9 @@ type Present struct {
}

type LeaderboardItem struct {
Position int
Username string
TotalDays int
Position int `json:"position"`
Username string `json:"username"`
TotalDays int `json:"total_days"`
}

var (
Expand Down Expand Up @@ -57,7 +57,7 @@ func GetPresenceHistory(user_id int) ([]Present, error) {
WITH date_series AS (
SELECT generate_series(CURRENT_DATE AT TIME ZONE 'Europe/Brussels' - INTERVAL '6 days', CURRENT_DATE AT TIME ZONE 'Europe/Brussels', '1 day')::date AS date
)
SELECT
SELECT
ds.date,
CASE WHEN scans.scan_date IS NOT NULL THEN TRUE ELSE FALSE END AS present,
CASE WHEN days.date IS NOT NULL THEN TRUE ELSE FALSE END AS streak_day
Expand Down

0 comments on commit 98c1bf4

Please sign in to comment.