Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/models: move db.PunchCard into models

Signed-off-by: oppiliappan <me@oppi.li>

+23 -18
+7 -16
appview/db/punchcard.go
··· 5 5 "fmt" 6 6 "strings" 7 7 "time" 8 + 9 + "tangled.org/core/appview/models" 8 10 ) 9 11 10 - type Punch struct { 11 - Did string 12 - Date time.Time 13 - Count int 14 - } 15 - 16 12 // this adds to the existing count 17 - func AddPunch(e Execer, punch Punch) error { 13 + func AddPunch(e Execer, punch models.Punch) error { 18 14 _, err := e.Exec(` 19 15 insert into punchcard (did, date, count) 20 16 values (?, ?, ?) ··· 20 24 return err 21 25 } 22 26 23 - type Punchcard struct { 24 - Total int 25 - Punches []Punch 26 - } 27 - 28 - func MakePunchcard(e Execer, filters ...filter) (*Punchcard, error) { 29 - punchcard := &Punchcard{} 27 + func MakePunchcard(e Execer, filters ...filter) (*models.Punchcard, error) { 28 + punchcard := &models.Punchcard{} 30 29 now := time.Now() 31 30 startOfYear := time.Date(now.Year(), 1, 1, 0, 0, 0, 0, time.UTC) 32 31 endOfYear := time.Date(now.Year(), 12, 31, 0, 0, 0, 0, time.UTC) 33 32 for d := startOfYear; d.Before(endOfYear) || d.Equal(endOfYear); d = d.AddDate(0, 0, 1) { 34 - punchcard.Punches = append(punchcard.Punches, Punch{ 33 + punchcard.Punches = append(punchcard.Punches, models.Punch{ 35 34 Date: d, 36 35 Count: 0, 37 36 }) ··· 59 68 defer rows.Close() 60 69 61 70 for rows.Next() { 62 - var punch Punch 71 + var punch models.Punch 63 72 var date string 64 73 var count sql.NullInt64 65 74 if err := rows.Scan(&date, &count); err != nil {
+14
appview/models/punchcard.go
··· 1 + package models 2 + 3 + import "time" 4 + 5 + type Punch struct { 6 + Did string 7 + Date time.Time 8 + Count int 9 + } 10 + 11 + type Punchcard struct { 12 + Total int 13 + Punches []Punch 14 + }
+1 -1
appview/pages/pages.go
··· 412 412 UserDid string 413 413 UserHandle string 414 414 FollowStatus models.FollowStatus 415 - Punchcard *db.Punchcard 415 + Punchcard *models.Punchcard 416 416 Profile *models.Profile 417 417 Stats ProfileStats 418 418 Active string
+1 -1
appview/state/knotstream.go
··· 125 125 } 126 126 } 127 127 128 - punch := db.Punch{ 128 + punch := models.Punch{ 129 129 Did: record.CommitterDid, 130 130 Date: time.Now(), 131 131 Count: count,