forked from tangled.org/core
Monorepo for Tangled — https://tangled.org

appview/models: move db.Registration into models

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

oppi.li a56c8a2a a2979381

verified
Changed files
+52 -47
appview
+4 -43
appview/db/registration.go
···
"fmt"
"strings"
"time"
-
)
-
-
// Registration represents a knot registration. Knot would've been a better
-
// name but we're stuck with this for historical reasons.
-
type Registration struct {
-
Id int64
-
Domain string
-
ByDid string
-
Created *time.Time
-
Registered *time.Time
-
NeedsUpgrade bool
-
}
-
func (r *Registration) Status() Status {
-
if r.NeedsUpgrade {
-
return NeedsUpgrade
-
} else if r.Registered != nil {
-
return Registered
-
} else {
-
return Pending
-
}
-
}
-
-
func (r *Registration) IsRegistered() bool {
-
return r.Status() == Registered
-
}
-
-
func (r *Registration) IsNeedsUpgrade() bool {
-
return r.Status() == NeedsUpgrade
-
}
-
-
func (r *Registration) IsPending() bool {
-
return r.Status() == Pending
-
}
-
-
type Status uint32
-
-
const (
-
Registered Status = iota
-
Pending
-
NeedsUpgrade
+
"tangled.org/core/appview/models"
)
-
func GetRegistrations(e Execer, filters ...filter) ([]Registration, error) {
-
var registrations []Registration
+
func GetRegistrations(e Execer, filters ...filter) ([]models.Registration, error) {
+
var registrations []models.Registration
var conditions []string
var args []any
···
var createdAt string
var registeredAt sql.Null[string]
var needsUpgrade int
-
var reg Registration
+
var reg models.Registration
err = rows.Scan(&reg.Id, &reg.Domain, &reg.ByDid, &createdAt, &registeredAt, &needsUpgrade)
if err != nil {
+44
appview/models/registration.go
···
+
package models
+
+
import "time"
+
+
// Registration represents a knot registration. Knot would've been a better
+
// name but we're stuck with this for historical reasons.
+
type Registration struct {
+
Id int64
+
Domain string
+
ByDid string
+
Created *time.Time
+
Registered *time.Time
+
NeedsUpgrade bool
+
}
+
+
func (r *Registration) Status() Status {
+
if r.NeedsUpgrade {
+
return NeedsUpgrade
+
} else if r.Registered != nil {
+
return Registered
+
} else {
+
return Pending
+
}
+
}
+
+
func (r *Registration) IsRegistered() bool {
+
return r.Status() == Registered
+
}
+
+
func (r *Registration) IsNeedsUpgrade() bool {
+
return r.Status() == NeedsUpgrade
+
}
+
+
func (r *Registration) IsPending() bool {
+
return r.Status() == Pending
+
}
+
+
type Status uint32
+
+
const (
+
Registered Status = iota
+
Pending
+
NeedsUpgrade
+
)
+4 -4
appview/pages/pages.go
···
}
type UpgradeBannerParams struct {
-
Registrations []db.Registration
+
Registrations []models.Registration
Spindles []db.Spindle
}
···
type KnotsParams struct {
LoggedInUser *oauth.User
-
Registrations []db.Registration
+
Registrations []models.Registration
}
func (p *Pages) Knots(w io.Writer, params KnotsParams) error {
···
type KnotParams struct {
LoggedInUser *oauth.User
-
Registration *db.Registration
+
Registration *models.Registration
Members []string
Repos map[string][]models.Repo
IsOwner bool
···
}
type KnotListingParams struct {
-
*db.Registration
+
*models.Registration
}
func (p *Pages) KnotListing(w io.Writer, params KnotListingParams) error {