Documentation
¶
Index ¶
- Constants
- Variables
- func GetOutdatedObservations() []string
- func GetSynonymID(taxonID string) (string, error)
- func Migrations()
- func SaveObservation(observation [][]gbif.LatestObservation, conn *sql.Conn, ctx context.Context)
- func UpdateLastFetchStatus(taxonID string) bool
- type Counts
- type Payload
- type TableRow
Constants ¶
const PageLimit = uint64(100)
Variables ¶
var Config *config
var DB *sql.DB
Functions ¶
func GetOutdatedObservations ¶
func GetOutdatedObservations() []string
Helper function to get outdated observations at random We only want to fetch a few at a time to not overload the GBIF API This function is used by the cron job
func GetSynonymID ¶
func Migrations ¶
func Migrations()
Helper function to run migration files. Its pretty simple and the migration will always run from the beginning. The migrations must be placed in "./migrations" and have the file extension ".sql".
func SaveObservation ¶
SaveObservation saves the latest observation for each taxon It first clears the old observations for each taxon before inserting the new ones to improve performance each insert contains alls new observations for this taxa at once
func UpdateLastFetchStatus ¶
UpdateLastFetchStatus updates the last fetch status for a taxon this function should be called before updating the observations for a taxon The LastFetch column is used to determine if a taxon should be fetched at random by the GetOutdatedObservations function
Types ¶
type TableRow ¶
type TableRow struct { TaxonID string ScientificName sql.NullString CountryCode sql.NullString CountryCodeClean string CountryFlag string LastFetch sql.NullTime ObservationID sql.NullString ObservationDate sql.NullTime ObservedDiff string IsSynonym bool SynonymName sql.NullString SynonymID sql.NullString TaxonKingdom string TaxonPhylum string TaxonClass string TaxonOrder string TaxonFamily string Taxa string }