db

package
v0.0.0-...-b7fb801 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

type Handle struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

Handle Struct

func NewDBHandle

func NewDBHandle(dbname, dbuser, dbpass, dbhost string, verbose bool) *Handle

NewDBHandle creates a new DBHandle

dbpath: the path to the database to use.
verbose: when true database accesses are logged to stdout

func NewMemoryDBHandle

func NewMemoryDBHandle(verbose bool, loadFixtures bool) *Handle

NewMemoryDBHandle creates a new in memory database. Only used for testing. The name of the database is a random string so multiple tests can run in parallel with their own database. This will setup the database with the all the tables as well.

func (*Handle) AddGroup

func (d *Handle) AddGroup(groupname string) (*types.Group, error)

AddGroup adds a new group to the database

func (*Handle) CreatePart

func (d *Handle) CreatePart(p *types.Part) error

CreatePart func

func (*Handle) DisableGroup

func (d *Handle) DisableGroup(groupname string) error

DisableGroup sets the Active attribute to false.

func (*Handle) FindBinaryByHash

func (d *Handle) FindBinaryByHash(hash string) (*types.Binary, error)

FindBinaryByHash does what it says.

func (*Handle) FindBinaryByName

func (d *Handle) FindBinaryByName(name string) (*types.Binary, error)

FindBinaryByName does what it says.

func (*Handle) FindGroupByName

func (d *Handle) FindGroupByName(name string) (*types.Group, error)

FindGroupByName does what it says

func (*Handle) FindPartByHash

func (d *Handle) FindPartByHash(hash string) (*types.Part, error)

FindPartByHash does what it says.

func (*Handle) FindReleaseByHash

func (d *Handle) FindReleaseByHash(h string) (*types.Release, error)

FindReleaseByHash returns

func (*Handle) GetActiveGroups

func (d *Handle) GetActiveGroups() ([]types.Group, error)

GetActiveGroups returns all groups marked active in the db

func (*Handle) GetAllGroups

func (d *Handle) GetAllGroups() ([]types.Group, error)

GetAllGroups returns all groups

func (*Handle) GetCategories

func (d *Handle) GetCategories() ([]*types.DBCategory, error)

GetCategories returns a sorted list of parent categories with their cubcategories populated.

func (*Handle) MakeBinaries

func (d *Handle) MakeBinaries() error

MakeBinaries makes binaries using the nzedb approach

func (*Handle) MakeReleases

func (d *Handle) MakeReleases() error

MakeReleases searchs for complete binaries and create releases from them deleting the binaries in the process.

func (*Handle) SavePartsAndMissedMessages

func (d *Handle) SavePartsAndMissedMessages(parts map[string]*types.Part, missed []types.MissedMessage) error

SavePartsAndMissedMessages saves a list of parts and missing message ids from an Overview call to the news server.

func (*Handle) SearchReleases

func (d *Handle) SearchReleases(query string, offset, limit int, categories []types.Category) ([]types.Release, error)

SearchReleases does what it says. query is matched against the name of the Releases limit limits the number of returned releases to no more than that categories restricts the searched releases to be in those categories

func (*Handle) SearchReleasesByName

func (d *Handle) SearchReleasesByName(name string) ([]types.Release, error)

type NameCleaner

type NameCleaner struct {
	Regexes []*types.Regex
}

NameCleaner rewrites a given string based on it's regexes and a set of fallback rules.

func NewNameCleaner

func NewNameCleaner(regexes []*types.Regex) *NameCleaner

NewNameCleaner returns a new NameCleaner. It will call Compile() on all given regexes.

func (*NameCleaner) Clean

func (n *NameCleaner) Clean(name, groupname string) string

Clean will return a rewritten name.

type RegexCleaner

type RegexCleaner struct {
	Regexes []*types.Regex
}

RegexCleaner cleans strings based on it's regexes

func NewRegexCleaner

func NewRegexCleaner(regexes []*types.Regex) (*RegexCleaner, error)

NewRegexCleaner returns a new RegexCleaner and compiles all the given Regexes

func (*RegexCleaner) Clean

func (r *RegexCleaner) Clean(name, groupname string) string

Clean tries to rewrite the given name using it's regexes that match the given group.

type ReleaseCleaner

type ReleaseCleaner struct {
	RegexCleaner *RegexCleaner
}

ReleaseCleaner rewrites release names based on regexes and hard coded rules.

func NewReleaseCleaner

func NewReleaseCleaner(regexes []*types.Regex) (*ReleaseCleaner, error)

NewReleaseCleaner returns a new ReleaseCleaner

func (*ReleaseCleaner) Clean

func (r *ReleaseCleaner) Clean(name, poster, groupname string, size int64) string

Clean rewrites the release name based on regexes and hard coded rules.

Jump to

Keyboard shortcuts

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