models

package
v0.0.0-...-fcc4a6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2022 License: ISC Imports: 2 Imported by: 0

Documentation

Overview

Package models defines all the database models for the application

Index

Constants

View Source
const (
	// TokenUserActivation is a constant used to identify tokens used for user activation
	TokenUserActivation string = "user_activation"
	// TokenPasswordReset is a constant used to identify tokens used for password resets
	TokenPasswordReset string = "password_reset"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Domain

type Domain struct {
	gorm.Model
	Host         string `gorm:"index:idx_domains_host;size:256;type:varchar(256)"`
	RegisteredAt *time.Time
	ExpiresAt    *time.Time
	Nameservers  []Nameserver `gorm:"many2many:domain_nameservers;"`
	Releases     []Release    `gorm:"many2many:domain_releases;"`
	Parses       []Parse
}

type Fetch

type Fetch struct {
	gorm.Model
	ActiveDomains      int
	ReleasingDomains   int
	ActiveSEDomains    int
	ActiveNUDomains    int
	ReleasingSEDomains int
	ReleasingNUDomains int
}

type Migration

type Migration struct {
	gorm.Model
	Key string `gorm:"type:text"`
}

type Nameserver

type Nameserver struct {
	gorm.Model
	Host                 string   `gorm:"uniqueIndex,size:512"`
	Domains              []Domain `gorm:"many2many:domain_nameservers;"`
	NameserverAggregates []NameserverAggregate
}

type NameserverAggregate

type NameserverAggregate struct {
	Count        int
	NameserverID int `gorm:"primarykey"`
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type Parse

type Parse struct {
	gorm.Model
	ContentHash           string  `gorm:"type:text"`
	ScreenshotHash        string  `gorm:"type:text"`
	BlurredScreenshotHash string  `gorm:"type:text"` // There is a lot of porn and other weird stuff out there, so I have opted to blur the screenshots. It is enough to give an idea of what the site was in the past.
	Size                  float64 // in Mb
	LoadTime              float64 // in Seconds
	Error                 *string
	Requested             time.Time
	Events                []ParseEvent
	DomainID              uint
	Domain                Domain
}

type ParseEvent

type ParseEvent struct {
	gorm.Model
	ParseID uint
	Parse   Parse
	URL     string
	Type    string
	Time    time.Time
}

type Release

type Release struct {
	gorm.Model
	ReleasedAt *time.Time `gorm:"uniqueIndex"`
	Domains    []Domain   `gorm:"many2many:domain_releases;"`
}

type Session

type Session struct {
	gorm.Model
	Identifier string
	UserID     uint
	ExpiresAt  time.Time
}

Session holds information about user sessions and when they expire

func (Session) HasExpired

func (s Session) HasExpired() bool

HasExpired is a helper function that checks if the current time is after the session expire datetime

type Sitemap

type Sitemap struct {
	gorm.Model
	Identifier string `gorm:"uniqueIndex;size:128"`
	Content    string `gorm:"type:longtext"`
}

type Token

type Token struct {
	gorm.Model
	Value     string
	Type      string
	ModelID   int
	ModelType string
	ExpiresAt time.Time
}

Token holds tokens typically used for user activation and password resets

func (Token) HasExpired

func (t Token) HasExpired() bool

HasExpired is a helper function that checks if the current time is after the token expiration time

type User

type User struct {
	gorm.Model
	Email       string
	Password    string
	ActivatedAt *time.Time
	Tokens      []Token `gorm:"polymorphic:Model;"`
	Sessions    []Session
}

User holds information relating to users that use the application

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL