data

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DateFormat = "2006-01-02"

Variables

View Source
var (
	// Categories represent the list of all search categories
	Categories = []Category{Publication, Data, Other}

	// Publication - search information on publication category
	Publication = Category{
		LocaliseKeyName: "Publication",
		ContentTypes:    []ContentType{Bulletin, Article, Compendium},
	}

	// Data - search information on data category
	Data = Category{
		LocaliseKeyName: "Data",
		ContentTypes:    []ContentType{TimeSeries, Datasets, UserRequestedData},
	}

	// Other - search information on other categories
	Other = Category{
		LocaliseKeyName: "Other",
		ContentTypes:    []ContentType{Methodology, CorporateInformation, ProductPage},
	}

	// Bulletin - Search information specific for statistical bulletins
	Bulletin = ContentType{
		LocaliseKeyName: "StatisticalBulletin",
		Group:           "bulletin",
		Types:           []string{"bulletin"},
		ShowInWebUI:     true,
	}

	// Article - Search information specific for articles
	Article = ContentType{
		LocaliseKeyName: "Article",
		Group:           "article",
		Types:           []string{"article", "article_download"},
		ShowInWebUI:     true,
	}

	// Compendium - Search information specific for compendium
	Compendium = ContentType{
		LocaliseKeyName: "Compendium",
		Group:           "compendia",
		Types:           []string{"compendium_landing_page"},
		ShowInWebUI:     true,
	}

	// TimeSeries - Search information specific for time series
	TimeSeries = ContentType{
		LocaliseKeyName: "TimeSeries",
		Group:           "time_series",
		Types:           []string{"timeseries"},
		ShowInWebUI:     true,
	}

	// Datasets - Search information specific for datasets
	Datasets = ContentType{
		LocaliseKeyName: "Datasets",
		Group:           "datasets",
		Types:           []string{"dataset_landing_page", "timeseries_dataset"},
		ShowInWebUI:     true,
	}

	DatasetLandingPage = ContentType{
		LocaliseKeyName: "Datasets",
		Group:           "dataset_landing_page",
		Types:           []string{"dataset_landing_page"},
		ShowInWebUI:     true,
	}

	// UserRequestedData - Search information specific for user requested data
	UserRequestedData = ContentType{
		LocaliseKeyName: "UserRequestedData",
		Group:           "user_requested_data",
		Types:           []string{"static_adhoc"},
		ShowInWebUI:     true,
	}

	// Methodology - Search information specific for methodologies
	Methodology = ContentType{
		LocaliseKeyName: "Methodology",
		Group:           "methodology",
		Types:           []string{"static_methodology", "static_methodology_download", "static_qmi"},
		ShowInWebUI:     true,
	}

	// CorporateInformation - Search information specific for corporate information
	CorporateInformation = ContentType{
		LocaliseKeyName: "CorporateInformation",
		Group:           "corporate_information",
		Types:           []string{"static_foi", "static_page", "static_landing_page", "static_article"},
		ShowInWebUI:     true,
	}

	// ProductPage - Search information specific for product pages
	ProductPage = ContentType{
		LocaliseKeyName: "ProductPage",
		Group:           "product_page",
		Types:           []string{"product_page"},
		ShowInWebUI:     false,
	}
)
View Source
var (
	// SortOptions represent the list of all search sort options
	SortOptions        = []Sort{Relevance, ReleaseDate, Title}
	DatasetSortOptions = []Sort{ReleaseDate, Title}

	// Relevance - informing on sorting based on relevance
	Relevance = Sort{
		Query:           "relevance",
		LocaliseKeyName: "Relevance",
	}

	// ReleaseDate - informing on sorting based on release date
	ReleaseDate = Sort{
		Query:           "release_date",
		LocaliseKeyName: "ReleaseDate",
	}

	// Title - informing on sorting based on title
	Title = Sort{
		Query:           "title",
		LocaliseKeyName: "Title",
	}
)
View Source
var LimitOptions = []int{
	10,
	25,
	50,
}

LimitOptions contains all available limit parameter values

Functions

func GetDataAggregationQuery added in v0.47.0

func GetDataAggregationQuery(validatedQueryParams SearchURLParams, template string) url.Values

GetDataAggregationQuery gets the query that needs to be passed to the search-api to get data aggregation results

func GetFirstAndLastPages added in v0.18.0

func GetFirstAndLastPages(req http.Request, validatedQueryParams SearchURLParams, totalPages int) []model.PageToDisplay

GetFirstAndLastPages gets the first and last pages

func GetGroupLocaliseKey added in v0.18.0

func GetGroupLocaliseKey(resultType string) string

GetGroupLocaliseKey gets the localise key of the group type of the search result to be displayed

func GetPagesToDisplay added in v0.5.0

func GetPagesToDisplay(cfg *config.Config, req http.Request, validatedQueryParams SearchURLParams, totalPages int) []model.PageToDisplay

GetPagesToDisplay gets all the pages available for the search results

func GetSearchAPIQuery added in v0.5.0

func GetSearchAPIQuery(validatedQueryParams SearchURLParams, censusTopicCache *cache.Topic) url.Values

GetSearchAPIQuery gets the query that needs to be passed to the search-api to get search results

func GetTotalPages added in v0.5.0

func GetTotalPages(cfg *config.Config, limit, count int) int

GetTotalPages gets the total pages of the search results

Types

type Category

type Category struct {
	LocaliseKeyName string        `json:"localise_key"`
	Count           int           `json:"count"`
	ContentTypes    []ContentType `json:"content_types"`
}

Category represents all the search categories in search page

func GetCategories added in v0.5.0

func GetCategories() []Category

GetCategories returns all the categories and its content types where all the count is set to zero

type ContentType

type ContentType struct {
	LocaliseKeyName string   `json:"localise_key"`
	Count           int      `json:"count"`
	Group           string   `json:"group"`
	Types           []string `json:"types"`
	ShowInWebUI     bool     `json:"show_in_web_ui"`
}

ContentType represents the type of the search results and the number of results for each type

type Date added in v0.47.0

type Date struct {
	// contains filtered or unexported fields
}

func DateFromTime added in v0.47.0

func DateFromTime(t time.Time) Date

DateFromTime extracts a date from a time object

func GetDates added in v0.47.0

func GetDates(ctx context.Context, params url.Values) (startDate, endDate Date, err error)

GetDates finds the date from and date to parameters

func MustParseDate added in v0.47.0

func MustParseDate(dateAsString string) Date

MustParseDate checks if the date format is correct and parsable

func ParseDate added in v0.47.0

func ParseDate(dateAsString string) (Date, error)

ParseDate parses the date into the default DateFormat

func (Date) DayString added in v0.47.0

func (d Date) DayString() string

func (Date) MonthString added in v0.47.0

func (d Date) MonthString() string

func (Date) String added in v0.47.0

func (d Date) String() string

func (Date) YearString added in v0.47.0

func (d Date) YearString() string

type Dimensions added in v0.41.0

type Dimensions struct {
	LocaliseKeyName string `json:"localise_key"`
	Count           int    `json:"count"`
	Type            string `json:"string"`
	Query           string `json:"query"`
	ShowInWebUI     bool   `json:"show_in_web_ui"`
}

func GetDimensions added in v0.41.0

func GetDimensions(countResp *searchModels.SearchResponse) (dimensions []Dimensions)

type Filter added in v0.5.0

type Filter struct {
	Query           []string `json:"query,omitempty"`
	LocaliseKeyName []string `json:"localise_key,omitempty"`
}

Filter represents information of filters selected by user

type PopulationTypes added in v0.41.0

type PopulationTypes struct {
	LocaliseKeyName string `json:"localise_key"`
	Count           int    `json:"count"`
	Type            string `json:"string"`
	Query           string `json:"query"`
	ShowInWebUI     bool   `json:"show_in_web_ui"`
}

func GetPopulationTypes added in v0.41.0

func GetPopulationTypes(countResp *searchModels.SearchResponse) (populationTypes []PopulationTypes)

type SearchURLParams added in v0.5.0

type SearchURLParams struct {
	Query                string
	PopulationTypeFilter string
	DimensionsFilter     string
	Filter               Filter
	AfterDate            Date
	BeforeDate           Date
	TopicFilter          string
	LatestRelease        bool
	Sort                 Sort
	Limit                int
	CurrentPage          int
	Offset               int
	NLPWeightingEnabled  bool
}

SearchURLParams is a struct which contains all information of search url parameters and values

func ReviewDataAggregationQuery added in v0.47.0

func ReviewDataAggregationQuery(ctx context.Context, cfg *config.Config, urlQuery url.Values, censusTopicCache *cache.Topic) (SearchURLParams, error)

ReviewQuery ensures that all search parameter values given by the user are reviewed

func ReviewDataAggregationQueryWithParams added in v0.53.0

func ReviewDataAggregationQueryWithParams(ctx context.Context, cfg *config.Config, urlQuery url.Values, censusTopicCache *cache.Topic) (SearchURLParams, error)

ReviewDataAggregationQueryWithParams ensures that all search parameter values given by the user are reviewed

func ReviewDatasetQuery added in v0.41.0

func ReviewDatasetQuery(ctx context.Context, cfg *config.Config, urlQuery url.Values, censusTopicCache *cache.Topic) (SearchURLParams, error)

ReviewQuery ensures that all search parameter values given by the user are reviewed

func ReviewQuery added in v0.5.0

func ReviewQuery(ctx context.Context, cfg *config.Config, urlQuery url.Values, censusTopicCache *cache.Topic) (SearchURLParams, error)

ReviewQuery ensures that all search parameter values given by the user are reviewed

type Sort added in v0.5.0

type Sort struct {
	Query           string `json:"query"`
	LocaliseKeyName string `json:"localise_key"`
}

Sort represents information of a particular sort option

type Subtopic added in v0.34.0

type Subtopic struct {
	Count           int    `json:"count"`
	LocaliseKeyName string `json:"localise_key"`
	Query           string `json:"query"`
	ShowInWebUI     bool   `json:"show_in_web_ui"`
}

Subtopic represents a subtopic filter on the search page

type Topic added in v0.24.0

type Topic struct {
	Count              int        `json:"count"`
	DistinctItemsCount int        `json:"distinct_items_count"`
	LocaliseKeyName    string     `json:"localise_key"`
	Query              string     `json:"query"`
	ShowInWebUI        bool       `json:"show_in_web_ui"`
	Subtopics          []Subtopic `json:"subtopics"`
}

Topic represents a topic filter on the search page

func GetTopics added in v0.34.0

func GetTopics(censusTopicCache *cache.Topic, countResp *searchModels.SearchResponse) []Topic

GetTopicCategories returns the topic filters to be displayed on the search page. Please note that only census topic filter is being returned

Jump to

Keyboard shortcuts

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