demographics

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAgeBrackets = []float64{12, 16, 18, 25, 35, 45, 55, 65, 75, 85}

DefaultAgeBrackets specifies the default age brackets for the demographics by age

Functions

This section is empty.

Types

type Bracket added in v1.4.0

type Bracket struct {
	Low  float64
	High float64
}

Bracket indicates a range of ages by which demographics data is grouped

func (Bracket) String added in v1.4.0

func (bracket Bracket) String() string

String returns a string representation of a Bracket

type DataFile added in v1.5.0

type DataFile struct {
	TempDirectory string
	URL           string
	Metrics       metrics.APIClientMetrics
	// contains filtered or unexported fields
}

DataFile represents a demographics data file

func (*DataFile) Download added in v1.5.0

func (datafile *DataFile) Download() (err error)

Download downloads a demographics data file to disk

func (*DataFile) Remove added in v1.5.0

func (datafile *DataFile) Remove()

Remove deletes the downloaded demographics data file from disk

type Demographics added in v1.5.0

type Demographics interface {
	// GetAgeGroupFigures returns the demographics grouped by age groups specified in AgeBrackets
	GetAgeGroupFigures() (figures map[string]int)
	// GetRegionFigures returns the demographics grouped by region
	GetRegionFigures() (figures map[string]int)
	// Stats returns statistics on the cache
	Stats() (stats map[string]int)
	// AutoRefresh periodically updates the cache
	AutoRefresh(ctx context.Context, interval time.Duration)
}

Demographics interface giving access to available data

type Store added in v1.5.0

type Store struct {
	AgeBrackets   []float64                // age brackets to group the data in. Defaults to DefaultAgeBrackets
	TempDirectory string                   // directory to use for temporary files. Uses system-specified tempdir if left blank
	URL           string                   // used to retrieve the data. Used for unit testing
	Metrics       metrics.APIClientMetrics // metrics to report API performance
	// contains filtered or unexported fields
}

Store holds the demographics data

func (*Store) AutoRefresh added in v1.8.1

func (store *Store) AutoRefresh(ctx context.Context, interval time.Duration)

AutoRefresh periodically updates the cache

func (*Store) GetAgeBrackets added in v1.5.0

func (store *Store) GetAgeBrackets() (brackets []Bracket)

GetAgeBrackets returns all age brackets found in the demographics data

func (*Store) GetAgeGroupFigures added in v1.5.0

func (store *Store) GetAgeGroupFigures() (figures map[string]int)

GetAgeGroupFigures returns the demographics grouped by age groups specified in AgeBrackets

func (*Store) GetByAge added in v1.5.0

func (store *Store) GetByAge(bracket Bracket) (count int, ok bool)

GetByAge returns the total population in the specified age brackets

func (*Store) GetByRegion added in v1.5.0

func (store *Store) GetByRegion(region string) (count int, ok bool)

GetByRegion returns the total population for the specified region

func (*Store) GetRegionFigures added in v1.5.0

func (store *Store) GetRegionFigures() (figures map[string]int)

GetRegionFigures returns the demographics grouped by region

func (*Store) GetRegions added in v1.5.0

func (store *Store) GetRegions() (regions []string)

GetRegions returns all regions found in the demographics data

func (*Store) Stats added in v1.8.1

func (store *Store) Stats() (stats map[string]int)

Stats reports statistics on the case

func (*Store) Update added in v1.8.1

func (store *Store) Update()

Update refreshes the demographics cache

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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