Documentation
¶
Index ¶
- Constants
- Variables
- func CapitalizeFirstLetter(input string) string
- func GetDataAggregationQuery(validatedQueryParams SearchURLParams, template string) url.Values
- func GetFirstAndLastPages(req http.Request, validatedQueryParams SearchURLParams, totalPages int) []model.PageToDisplay
- func GetGroupLocaliseKey(resultType string) string
- func GetPagesToDisplay(cfg *config.Config, req http.Request, validatedQueryParams SearchURLParams, ...) []model.PageToDisplay
- func GetSearchAPIQuery(validatedQueryParams SearchURLParams, censusTopicCache *cache.Topic) url.Values
- func GetTotalPages(cfg *config.Config, limit, count int) int
- type Category
- type ContentType
- type Date
- func DateFromTime(t time.Time) Date
- func GetEndDate(params url.Values) (endDate Date, validationErrs []core.ErrorItem)
- func GetStartDate(params url.Values) (startDate Date, validationErrs []core.ErrorItem)
- func MustParseDate(dateAsString string) Date
- func MustSetFieldsetErrID(id string) (d Date)
- func ParseDate(dateAsString string) (Date, error)
- func ValidateDateRange(from, to Date) (end Date, err error)
- type Dimensions
- type Filter
- type PopulationTypes
- type SearchURLParams
- func ReviewDataAggregationQueryWithParams(ctx context.Context, cfg *config.Config, urlQuery url.Values) (sp SearchURLParams, validationErrs []core.ErrorItem)
- func ReviewDatasetQuery(ctx context.Context, cfg *config.Config, urlQuery url.Values, ...) (SearchURLParams, error)
- func ReviewQuery(ctx context.Context, cfg *config.Config, urlQuery url.Values, ...) (SearchURLParams, error)
- type Sort
- type Subtopic
- type Topic
Constants ¶
const ( Limit = "limit" Page = "page" Offset = "offset" SortName = "sort" DayBefore = "before-day" DayAfter = "after-day" Before = "before" MonthBefore = Before + "-month" After = "after" MonthAfter = After + "-month" YearBefore = "before-year" YearAfter = "after-year" Keywords = "keywords" Query = "query" DateFrom = "fromDate" DateFromErr = DateFrom + "-error" DateTo = "toDate" DateToErr = DateTo + "-error" Type = "release-type" Census = "census" Highlight = "highlight" PaginationErr = "pagination-error" ContentTypeFilterErr = "filter-error" TopicFilterErr = "topic-error" PopulationTypeFilterErr = "population-error" DimensionsFilterErr = "dimensions-error" QueryStringErr = "query-string-error" )
const DateFormat = "2006-01-02"
Variables ¶
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, } )
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", } )
var LimitOptions = []int{
10,
25,
50,
}
LimitOptions contains all available limit parameter values
Functions ¶
func CapitalizeFirstLetter ¶ added in v0.55.0
CapitalizeFirstLetter is a helper function that transforms the first letter of a string to uppercase
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
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
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
DateFromTime extracts a date from a time object
func GetEndDate ¶ added in v0.55.0
func GetStartDate ¶ added in v0.55.0
GetStartDate returns the validated date from parameters
func MustParseDate ¶ added in v0.47.0
MustParseDate checks if the date format is correct and parsable
func MustSetFieldsetErrID ¶ added in v0.55.0
func ValidateDateRange ¶ added in v0.55.0
ValidateDateRange returns an error and 'to' date if the 'from' date is after than the 'to' date
func (Date) GetFieldsetErrID ¶ added in v0.55.0
func (Date) HasDayValidationErr ¶ added in v0.55.0
func (Date) HasMonthValidationErr ¶ added in v0.55.0
func (Date) HasYearValidationErr ¶ added in v0.55.0
func (Date) MonthString ¶ added in v0.47.0
func (Date) YearString ¶ added in v0.47.0
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 ReviewDataAggregationQueryWithParams ¶ added in v0.53.0
func ReviewDataAggregationQueryWithParams(ctx context.Context, cfg *config.Config, urlQuery url.Values) (sp SearchURLParams, validationErrs []core.ErrorItem)
ReviewDataAggregationQueryWithParams ensures that all search parameter values given by the user are reviewed
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