internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const PageLimit = uint64(100)

Variables

View Source
var Config *config
View Source
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 GetSynonymID(taxonID string) (string, error)

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

func SaveObservation(observation [][]gbif.LatestObservation, conn *sql.Conn, ctx context.Context)

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

func UpdateLastFetchStatus(taxonID string) bool

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 Counts

type Counts struct {
	TaxaCount        int
	ObservationCount int
}

func GetCounts

func GetCounts(payload Payload) Counts

type Payload

type Payload struct {
	ORDER_BY      *string `query:"order_by"`
	ORDER_DIR     *string `query:"order_dir"`
	SEARCH        *string `query:"search"`
	COUNTRY       *string `query:"country"`
	RANK          *string `query:"rank"`
	TAXA          *string `query:"taxa"`
	PAGE          *string `query:"page"`
	HIDE_SYNONYMS *bool   `query:"hide_synonyms"`
}

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
}

func GetTableData

func GetTableData(payload Payload) []TableRow

Jump to

Keyboard shortcuts

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