Documentation
¶
Index ¶
- Variables
- func GetPagesToDisplay(cfg *config.Config, validatedQueryParams SearchURLParams, totalPages int) []model.PageToDisplay
- func GetSearchAPIQuery(validatedQueryParams SearchURLParams) url.Values
- func GetTotalPages(cfg *config.Config, limit, count int) int
- type Category
- type ContentType
- type Filter
- type SearchURLParams
- type Sort
Constants ¶
This section is empty.
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}, } // Bulletin - Search information specific for statistical bulletins Bulletin = ContentType{ LocaliseKeyName: "StatisticalBulletin", Type: "bulletin", SubTypes: []string{"bulletin"}, } // Article - Search information specific for articles Article = ContentType{ LocaliseKeyName: "Article", Type: "article", SubTypes: []string{"article", "article_download"}, } // Compendium - Search information specific for compendium Compendium = ContentType{ LocaliseKeyName: "Compendium", Type: "compendia", SubTypes: []string{"compendium_landing_page"}, } // TimeSeries - Search information specific for time series TimeSeries = ContentType{ LocaliseKeyName: "TimeSeries", Type: "time_series", SubTypes: []string{"timeseries"}, } // Datasets - Search information specific for datasets Datasets = ContentType{ LocaliseKeyName: "Datasets", Type: "datasets", SubTypes: []string{"dataset_landing_page", "reference_tables"}, } // UserRequestedData - Search information specific for user requested data UserRequestedData = ContentType{ LocaliseKeyName: "UserRequestedData", Type: "user_requested_data", SubTypes: []string{"static_adhoc"}, } // Methodology - Search information specific for methodologies Methodology = ContentType{ LocaliseKeyName: "Methodology", Type: "methodology", SubTypes: []string{"static_methodology", "static_methodology_download", "static_qmi"}, } // CorporateInformation - Search information specific for corporate information CorporateInformation = ContentType{ LocaliseKeyName: "CorporateInformation", Type: "corporate_information", SubTypes: []string{"static_foi", "static_page", "static_landing_page", "static_article"}, } )
var ( // SortOptions represent the list of all search sort options SortOptions = []Sort{Relevance, 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 GetPagesToDisplay ¶ added in v0.5.0
func GetPagesToDisplay(cfg *config.Config, 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) 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"` Type string `json:"type"` SubTypes []string `json:"sub_types"` }
ContentType represents the type of the search results and the number of results for each type
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 SearchURLParams ¶ added in v0.5.0
type SearchURLParams struct { Query string Filter Filter Sort Sort Limit int CurrentPage int Offset int }
SearchURLParams is a struct which contains all information of search url parameters and values
func ReviewQuery ¶ added in v0.5.0
func ReviewQuery(ctx context.Context, cfg *config.Config, urlQuery url.Values) (SearchURLParams, error)
ReviewQuery ensures that all search parameter values given by the user are reviewed