database

package
v0.0.0-...-93f8c6f Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package database implements tools and structures to search and access the series in the BDSICE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BDSICEDatabase

type BDSICEDatabase struct {
	Series       map[string]string `json:"Series"` // code: title
	LastUpdate   time.Time         `json:"LastUpdate"`
	DatabasePath string            `json:"Path"`
	Codes        []string          `json:"Codes"`
}

func BuildDatabase

func BuildDatabase(seriesToBuild []*series.BDSICESerie) (*BDSICEDatabase, error)

builds a db.json file from a BDSICEDatabase object from an array of pointers of series.BDSICESerie objects Intented to be called from download.DownloadFullDatabase() or download.Update() at some point after having downloaded or updated the database of .json files

func LoadDatabase

func LoadDatabase(configuration *config.BDSICEConfig) (*BDSICEDatabase, error)

loads a database from database path specified in configuration and returns a reference to a database object

func (*BDSICEDatabase) AddSerie

func (db *BDSICEDatabase) AddSerie(serie *series.BDSICESerie) error

Adds a BDSICEDatabaseSerie object to a BDSICEDatabase from a BDSICESerie Basically, it takes SerieCode and Title fields of BDSICESerie and appends them to the array of BDSICEDatabaseSerie objects

func (*BDSICEDatabase) GetCodes

func (db *BDSICEDatabase) GetCodes() []string

returns a string slice containing a list of all the codes in the database

func (*BDSICEDatabase) Match

func (db *BDSICEDatabase) Match(terms ...string) map[string]string

returns the series that contain all of the terms either in the title or in the serie code Match() does not normalize the search terms and the calling function should be responsible of performing any normalisation of diacritics and others that might me deemed necessary. Normalisations at this levels would reduce performance.

func (*BDSICEDatabase) Search

func (db *BDSICEDatabase) Search(terms ...string) (map[string]string, error)

returns the series that contain all the terms either in the title or the serie code, and excludes all the series that contain the terms prefixed by "-" either in the title or the serie code.

Jump to

Keyboard shortcuts

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