models

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ReleaseDataType = "release"
)

Variables

View Source
var CantabularTypes = map[string]struct{}{
	"cantabular_flexible_table":     {},
	"cantabular_multivariate_table": {},
}

CantabularTypes are dataset types corresponding to Cantabular datasets

View Source
var PopulationTypes = map[string]string{
	"atc-ts-demmig-hh-ct-oa":     "All households",
	"atc-ts-demmig-str-ct-oa":    "All non-UK born short-term residents",
	"atc-ts-demmig-ur-ct-oa":     "All usual residents",
	"atc-ts-demmig-ur-pd-oa":     "All usual residents",
	"atc-ts-ed-ftetta-ct-oa":     "All schoolchildren and full-time students aged 5 years and over at their term-time address",
	"atc-ts-eilr-ur-ct-ltla":     "All usual residents aged 3 years and over",
	"atc-ts-eilr-ur-ct-msoa":     "All usual residents",
	"atc-ts-hduc-ur-asp-ltla":    "All usual residents",
	"atc-ts-hous-ur-ct-oa":       "All usual residents",
	"atc-ts-hous-urce-ct-msoa":   "All usual residents in communal establishments",
	"atc-ts-lmttw-ur-ct-oa":      "All usual residents",
	"atc-ts-sogi-ur16o-ct-ltla":  "All usual residents aged 16 years and over",
	"atc-ts-sogi-ur16o-ct-msoa":  "All usual residents aged 16 years and over",
	"atc-ts-vets-vetsur-ct-msoa": "All usual residents who have previously served in the UK armed forces",
	"HH":                         "All Households",
	"UR_HH":                      "All usual residents in households",
	"UR":                         "All usual residents",
}

PopulationTypes is a mapping between dataset is_based_ok @ID values and population type labels Note: this can be also obtained by calling population-api: GET /population-types

Functions

func GetURI added in v0.24.0

func GetURI(metadata *dataset.Metadata) string

GetURI obtains the URI from the provided metadata struct

func RectifyKeywords added in v0.5.0

func RectifyKeywords(keywords []string, keywordsLimit int) []string

RectifyKeywords sanitises a slice of keywords, splitting any that contain commas into seperate keywords and trimming any whitespace. It also optionally takes a limit which truncates the keywords to the desired amount. This value can be -1 for no truncation.

func ValidateTopics added in v0.11.0

func ValidateTopics(topics []string) []string

Types

type ContentPublished

type ContentPublished struct {
	URI          string `avro:"uri"`
	DataType     string `avro:"data_type"`
	CollectionID string `avro:"collection_id"`
	JobID        string `avro:"job_id"`
	SearchIndex  string `avro:"search_index"`
	TraceID      string `avro:"trace_id"`
}

ContentPublished provides an avro structure for a Content Published event

type Description

type Description struct {
	Cancelled       bool     `json:"cancelled,omitempty"`
	CDID            string   `json:"cdid"`
	DatasetID       string   `json:"datasetId"`
	Edition         string   `json:"edition"`
	Finalised       bool     `json:"finalised,omitempty"`
	Keywords        []string `json:"keywords,omitempty"`
	MetaDescription string   `json:"metaDescription"`
	ProvisionalDate string   `json:"provisionalDate,omitempty"`
	CanonicalTopic  string   `json:"canonicalTopic,omitempty"`
	Published       bool     `json:"published,omitempty"`
	ReleaseDate     string   `json:"releaseDate"`
	Summary         string   `json:"summary"`
	Title           string   `json:"title"`
	Topics          []string `json:"secondaryTopics,omitempty"`
	Language        string   `json:"language,omitempty"`
	Survey          string   `json:"survey,omitempty"`
}

type Dimension added in v0.24.0

type Dimension struct {
	Key      string `avro:"key"`
	AggKey   string `avro:"agg_key"`
	Name     string `avro:"name"`
	Label    string `avro:"label"`
	RawLabel string `avro:"raw_label"`
}

Dimension represents the required information for each dataset dimension: name (unique ID) and label and an aggregation key which combines name and label

func MapDimensions added in v0.25.0

func MapDimensions(ctx context.Context, dimensions []dataset.VersionDimension) []Dimension

MapDimensions returns a slice of dimensions corresponding to the provided slice of dataset versionDimensions. The new dimensions are keyed by human friendly label. If multiple dimensions have the same key, they will be collapsed into 1 single dimension. Collapsed dimensions keep all the original names and labels as csv values, as this information is very valuable to know what was combined, if necessary.

type PopulationType added in v0.24.0

type PopulationType struct {
	Key    string `avro:"key"`
	AggKey string `avro:"agg_key"`
	Name   string `avro:"name"`
	Label  string `avro:"label"`
}

PopulationType represents the population type name (unique ID) and label and an aggregation key which combines name and label

func MapPopulationType added in v0.25.0

func MapPopulationType(ctx context.Context, basedOnID string) PopulationType

MapPopulationType a PopulationType that contains a The new dimensions are keyed by human friendly label. If multiple dimensions have the same key, they will be collapsed into 1 single dimension. Collapsed dimensions keep all the original names and labels as csv values, as this information is very valuable to know what was combined, if necessary.

type ReleaseDateChange added in v0.14.0

type ReleaseDateChange struct {
	ChangeNotice string `json:"changeNotice"`
	Date         string `json:"previousDate"`
}

ReleaseDateChange represent a date change of a release

type ReleaseDateDetails added in v0.14.0

type ReleaseDateDetails struct {
	ChangeNotice string `avro:"change_notice"`
	Date         string `avro:"previous_date"`
}

ReleaseDateChange represent a date change of a release

type SearchDataImport

type SearchDataImport struct {
	UID             string               `avro:"uid"`
	URI             string               `avro:"uri"`
	Edition         string               `avro:"edition"`
	DataType        string               `avro:"data_type"`
	JobID           string               `avro:"job_id"`
	SearchIndex     string               `avro:"search_index"`
	CDID            string               `avro:"cdid"`
	DatasetID       string               `avro:"dataset_id"`
	Keywords        []string             `avro:"keywords"`
	MetaDescription string               `avro:"meta_description"`
	ReleaseDate     string               `avro:"release_date"`
	Summary         string               `avro:"summary"`
	Title           string               `avro:"title"`
	Topics          []string             `avro:"topics"`
	TraceID         string               `avro:"trace_id"`
	DateChanges     []ReleaseDateDetails `avro:"date_changes"`
	Cancelled       bool                 `avro:"cancelled"`
	Finalised       bool                 `avro:"finalised"`
	ProvisionalDate string               `avro:"provisional_date"`
	CanonicalTopic  string               `avro:"canonical_topic"`
	Published       bool                 `avro:"published"`
	Language        string               `avro:"language"`
	Survey          string               `avro:"survey"`
	PopulationType  PopulationType       `avro:"population_type"`
	Dimensions      []Dimension          `avro:"dimensions"`
}

SearchDataImport provides event data for a search data import

func MapZebedeeDataToSearchDataImport added in v0.5.0

func MapZebedeeDataToSearchDataImport(zebedeeData ZebedeeData, keywordsLimit int) SearchDataImport

MapZebedeeDataToSearchDataImport Performs default mapping of zebedee data to a SearchDataImport struct. It also optionally takes a limit which truncates the keywords to the desired amount. This value can be -1 for no truncation.

func (*SearchDataImport) MapDatasetMetadataValues added in v0.24.0

func (s *SearchDataImport) MapDatasetMetadataValues(ctx context.Context, metadata *dataset.Metadata) error

func (*SearchDataImport) PopulateCantabularFields added in v0.24.0

func (s *SearchDataImport) PopulateCantabularFields(ctx context.Context, metadata *dataset.Metadata)

PopulateCantabularFields checks if the provided dataset metadata corresponds to a Cantabular Data type, if it does, it populates the dimensions array of SearchDataImport with the dimension names, labels and processed labels, and assigns the population type corresponding to the 'IsBasedOn' id value.

type ZebedeeData

type ZebedeeData struct {
	UID         string              `json:"uid"`
	URI         string              `json:"uri"`
	DataType    string              `json:"type"`
	Description Description         `json:"description"`
	DateChanges []ReleaseDateChange `json:"dateChanges,omitempty"`
}

ZebedeeData provides model for zebedee publisheddata response

Jump to

Keyboard shortcuts

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