services

package
v0.0.0-...-d3e7db7 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminServices

type AdminServices struct {
	User       User
	AdminStore *gorm.DB
}

func NewAdminServices

func NewAdminServices(u User, aStore *gorm.DB) AdminServices

func (*AdminServices) CreateAdmin

func (as *AdminServices) CreateAdmin(u User) error

func (*AdminServices) LoginAsAdmin

func (as *AdminServices) LoginAsAdmin(email, password string) (User, error)

type CrawledUrl

type CrawledUrl struct {
	ID              string         `gorm:"primaryKey;type:uuid;default:uuid_generate_v4()" json:"id"`
	Url             string         `gorm:"unique;not null" json:"url"`
	Success         bool           `gorm:"default:null" json:"success"`
	CrawlDuration   time.Duration  `json:"crawlDuration"`
	ResponseCode    int            `gorm:"type:smallint" json:"responseCode"`
	PageTitle       string         `json:"pageTitle"`
	PageDescription string         `json:"pageDescription"`
	Headings        string         `json:"headings"`
	LastTested      *time.Time     `json:"lastTested"` // Use pointer so this value can be nil
	Indexed         bool           `json:"indexed" gorm:"default:false"`
	CreatedAt       time.Time      `gorm:"datetime:timestamp;default:CURRENT_TIMESTAMP" json:"createdAt"`
	UpdatedAt       time.Time      `gorm:"datetime:timestamp" json:"updatedAt"`
	DeletedAt       gorm.DeletedAt `gorm:"index"`
}

type SearchIndex

type SearchIndex struct {
	ID        string `gorm:"primaryKey;type:uuid;default:uuid_generate_v4()"`
	Value     string
	Urls      []CrawledUrl   `gorm:"many2many:token_urls;"`
	CreatedAt time.Time      `gorm:"datetime:timestamp;default:CURRENT_TIMESTAMP"`
	UpdatedAt time.Time      `gorm:"datetime:timestamp"`
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func (*SearchIndex) TableName

func (si *SearchIndex) TableName() string

Gorm override table name (↓ SEE NOTE BELOW ↓)

type SearchIndexServices

type SearchIndexServices struct {
	Index      SearchIndex
	IndexStore *gorm.DB
}

func NewSearchIndexServices

func NewSearchIndexServices(
	i SearchIndex, iStore *gorm.DB,
) SearchIndexServices

func (*SearchIndexServices) Save

func (sis *SearchIndexServices) Save(
	i map[string][]string, crUrls []CrawledUrl,
) error

func (*SearchIndexServices) SearchFullText

func (sis *SearchIndexServices) SearchFullText(v string) ([]CrawledUrl, error)

type SearchSettings

type SearchSettings struct {
	ID        uint      `gorm:"primaryKey" json:"id"`
	SearchOn  bool      `json:"searchOn"`
	AddNew    bool      `json:"addNew"`
	Amount    uint      `json:"amount"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type SearchSettingsServices

type SearchSettingsServices struct {
	SearchSettings      SearchSettings
	SearchSettingsStore *gorm.DB
}

func NewSearchSettingsServices

func NewSearchSettingsServices(
	ss SearchSettings, sstore *gorm.DB,
) SearchSettingsServices

func (*SearchSettingsServices) Get

func (*SearchSettingsServices) Upadate

func (sss *SearchSettingsServices) Upadate(
	amount uint, searchOn, addNew bool,
) error

type UrlServices

type UrlServices struct {
	Url      CrawledUrl
	UrlStore *gorm.DB
}

func NewUrlServices

func NewUrlServices(u CrawledUrl, uStore *gorm.DB) UrlServices

func (*UrlServices) GetNextCrawlUrls

func (u *UrlServices) GetNextCrawlUrls(limit uint) ([]CrawledUrl, error)

func (*UrlServices) GetNotIndexed

func (u *UrlServices) GetNotIndexed() ([]CrawledUrl, error)

func (*UrlServices) Save

func (u *UrlServices) Save(input *CrawledUrl) error

func (*UrlServices) SetIndexedTrue

func (u *UrlServices) SetIndexedTrue(urls []CrawledUrl) error

func (*UrlServices) UpdateUrl

func (u *UrlServices) UpdateUrl(input CrawledUrl) error

type User

type User struct {
	ID        string    `gorm:"primaryKey;type:uuid;default:uuid_generate_v4()" json:"id"`
	Email     string    `gorm:"unique" json:"email"`
	Password  string    `json:"-"`
	IsAdmin   bool      `gorm:"default:false" json:"isAdmin"`
	CreatedAt time.Time `gorm:"datetime:timestamp;default:CURRENT_TIMESTAMP" json:"createdAt"`
	UpdatedAt time.Time `gorm:"datetime:timestamp" json:"updatedAt"`
}

Jump to

Keyboard shortcuts

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