mirror of
https://github.com/ThisTine/Snip.git
synced 2026-08-18 23:18:47 +07:00
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package domain
|
|
|
|
import "time"
|
|
|
|
// Mode is how a short code was produced.
|
|
type Mode string
|
|
|
|
const (
|
|
ModeRandom Mode = "random"
|
|
ModeMemorable Mode = "memorable"
|
|
ModeCustom Mode = "custom"
|
|
)
|
|
|
|
// DayCount is a single day's click total.
|
|
type DayCount struct {
|
|
Date string `json:"date"`
|
|
Count int64 `json:"count"`
|
|
}
|
|
|
|
// Link is the aggregate root: a short code pointing at a destination.
|
|
type Link struct {
|
|
ID string
|
|
Code string
|
|
LongURL string
|
|
Mode Mode
|
|
HasPin bool
|
|
PinHash string // bcrypt hash; never serialized out of the system
|
|
OwnerID string // empty for anonymous links
|
|
CreatedAt time.Time
|
|
TotalClicks int64
|
|
Last7Days []DayCount
|
|
}
|
|
|
|
// OwnerStats are the dashboard aggregate tiles, computed in the DB so the
|
|
// client never has to fetch every link to total them up.
|
|
type OwnerStats struct {
|
|
TotalLinks int `json:"totalLinks"`
|
|
TotalClicks int64 `json:"totalClicks"`
|
|
WeekClicks int64 `json:"weekClicks"`
|
|
}
|
|
|
|
// User is an authenticated account, keyed by (provider, subject).
|
|
type User struct {
|
|
ID string
|
|
Email string
|
|
Name string
|
|
Provider string
|
|
Subject string
|
|
}
|