Skip to content

Commit

Permalink
Return default views if database is invalid
Browse files Browse the repository at this point in the history
This affects very few people, and better a quick fix for now.
  • Loading branch information
arp242 committed Feb 16, 2022
1 parent c4e25f0 commit c029df8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,21 @@ func (ss *UserSettings) Scan(v interface{}) error {
}
}

// This exists as a work-around because a migration set this column wrong >_<
//
// https://github.com/arp242/goatcounter/issues/569#issuecomment-1042013488
func (w *Widgets) UnmarshalJSON(d []byte) error {
type alias Widgets
ww := alias(*w)
err := json.Unmarshal(d, &ww)
*w = Widgets(ww)

if err != nil {
*w = defaultWidgets(context.Background())
}
return nil
}

func (ss *SiteSettings) Defaults(ctx context.Context) {
if ss.Campaigns == nil {
ss.Campaigns = []string{"utm_campaign", "utm_source", "ref"}
Expand Down

0 comments on commit c029df8

Please sign in to comment.