Skip to content

Commit

Permalink
Merge branch 'release/1.64.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshSinghONS committed Jun 20, 2024
2 parents 144e731 + 5fca996 commit 36cc514
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 60 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ An HTTP service for the controlling of data and rendering templates relevant to
| DOWNLOAD_SERVICE_URL | http://localhost:23600 | The URL of [dp-download-service](https://www.github.com/ONSdigital/dp-download-service). |
| ENABLE_MULTIVARIATE | false | Enable 2021 [multivariate datasets](https://github.com/ONSdigital/dp-dataset-api/blob/5f9f4218b65aae4803809f4a876e9f72b9bf5305/models/dataset.go#L43) |
| ENABLE_NEW_NAV_BAR | false | Enable new nav bar |
| ENABLE_OFFICIAL_STATISTICS_LOGO | false | Enable new official statistics logo |
| ENABLE_PROFILER | false | Flag to enable go profiler |
| GRACEFUL_SHUTDOWN_TIMEOUT | 5s | The graceful shutdown timeout in seconds |
| HEALTHCHECK_CRITICAL_TIMEOUT | 90s | The time taken for the health changes from warning state to critical due to subsystem check failures |
Expand Down
2 changes: 0 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type Config struct {
DownloadServiceURL string `envconfig:"DOWNLOAD_SERVICE_URL"`
EnableMultivariate bool `envconfig:"ENABLE_MULTIVARIATE"`
EnableNewNavBar bool `envconfig:"ENABLE_NEW_NAV_BAR"`
EnableOfficialStatisticsLogo bool `envconfig:"ENABLE_OFFICIAL_STATISTICS_LOGO"`
EnableProfiler bool `envconfig:"ENABLE_PROFILER"`
GracefulShutdownTimeout time.Duration `envconfig:"GRACEFUL_SHUTDOWN_TIMEOUT"`
HealthCheckCriticalTimeout time.Duration `envconfig:"HEALTHCHECK_CRITICAL_TIMEOUT"`
Expand Down Expand Up @@ -62,7 +61,6 @@ func get() (*Config, error) {
DownloadServiceURL: "http://localhost:23600",
EnableMultivariate: false,
EnableNewNavBar: false,
EnableOfficialStatisticsLogo: false,
EnableProfiler: false,
GracefulShutdownTimeout: 5 * time.Second,
HealthCheckCriticalTimeout: 90 * time.Second,
Expand Down
2 changes: 1 addition & 1 deletion handlers/filter_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ func filterOutput(w http.ResponseWriter, req *http.Request, zc ZebedeeClient, dc
showAll := req.URL.Query()[queryStrKey]
basePage := rend.NewBasePageModel()
m := mapper.CreateCensusFilterOutputsPage(req, basePage, datasetModel, ver, initialVersionReleaseDate, hasOtherVersions, allVers.Items, latestVersionNumber, latestVersionURL, lang, showAll, isValidationError, hasNoAreaOptions, filterOutput, fDims, homepageContent.ServiceMessage, homepageContent.EmergencyBanner, cfg.EnableMultivariate, dimDescriptions, *sdc, pop)
m.DatasetLandingPage.OSRLogo = helpers.GetOSRLogoDetails(cfg.EnableOfficialStatisticsLogo, false, m.Language)
m.DatasetLandingPage.OSRLogo = helpers.GetOSRLogoDetails(false, m.Language)

rend.BuildPage(w, m, "census-landing")
}
Expand Down
4 changes: 2 additions & 2 deletions handlers/filterable_landing_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func filterableLanding(w http.ResponseWriter, req *http.Request, dc DatasetClien
URI: fmt.Sprintf("/datasets/%s/editions/%s/versions/%s/metadata.txt", datasetID, edition, version),
})

m.DatasetLandingPage.OSRLogo = helpers.GetOSRLogoDetails(cfg.EnableOfficialStatisticsLogo, false, m.Language)
m.DatasetLandingPage.OSRLogo = helpers.GetOSRLogoDetails(false, m.Language)

templateName := "filterable"
if datasetModel.Type == "nomis" {
Expand Down Expand Up @@ -231,7 +231,7 @@ func censusLanding(cfg config.Config, ctx context.Context, w http.ResponseWriter
showAll := req.URL.Query()[queryStrKey]
basePage := rend.NewBasePageModel()
m := mapper.CreateCensusLandingPage(req, basePage, datasetModel, version, opts, categorisationsMap, initialVersionReleaseDate, hasOtherVersions, allVersions, latestVersionNumber, latestVersionURL, lang, showAll, isValidationError, serviceMessage, emergencyBannerContent, cfg.EnableMultivariate, pop)
m.DatasetLandingPage.OSRLogo = helpers.GetOSRLogoDetails(cfg.EnableOfficialStatisticsLogo, true, m.Language)
m.DatasetLandingPage.OSRLogo = helpers.GetOSRLogoDetails(true, m.Language)

rend.BuildPage(w, m, "census-landing")
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/legacy_landing.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (lp legacyLandingPage) Build(w http.ResponseWriter, req *http.Request) {
basePage := lp.RenderClient.NewBasePageModel()
m := mapper.CreateLegacyDatasetLanding(ctx, basePage, req, dlp, bc, datasets, lp.Language, homepageContent.ServiceMessage, homepageContent.EmergencyBanner, navigationCache)

m.DatasetLandingPage.OSRLogo = helpers.GetOSRLogoDetails(lp.Config.EnableOfficialStatisticsLogo, false, m.Language)
m.DatasetLandingPage.OSRLogo = helpers.GetOSRLogoDetails(false, m.Language)

lp.RenderClient.BuildPage(w, m, "static")
}
Expand Down
27 changes: 4 additions & 23 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func ToBoolPtr(val bool) *bool {
return &val
}

// GetOSRLogoDetails returns the official statistics logo details based on the enableOfficialStatisticsLogo and language
func GetOSRLogoDetails(enableOfficialStatisticsLogo, useSvg bool, language string) osrlogo.OSRLogo {
// GetOSRLogoDetails returns the official statistics logo details based on the language
func GetOSRLogoDetails(useSvg bool, language string) osrlogo.OSRLogo {
extension := ".png"
altText := "Official Statistics logo"
title := "Accredited official statistics"
Expand All @@ -107,30 +107,11 @@ func GetOSRLogoDetails(enableOfficialStatisticsLogo, useSvg bool, language strin
extension = ".svg"
}

if enableOfficialStatisticsLogo {
return osrlogo.OSRLogo{
URL: fmt.Sprintf("https://cdn.ons.gov.uk/assets/images/ons-logo/kitemark/v2/uksa-kitemark-%s%s", language, extension),
AltText: altText,
Title: title,
About: about,
Enabled: true,
}
}

altText = "National Statistics Logo"
title = "National Statistic"
about = "Certified by the UK Statistics Authority as compliant with the Code of Practice for Official Statistics."
urlStr := "/img/national-statistics.png"

if useSvg {
urlStr = "https://cdn.ons.gov.uk/assets/images/ons-logo/kitemark/uksa-kitemark.svg"
}

return osrlogo.OSRLogo{
URL: urlStr,
URL: fmt.Sprintf("https://cdn.ons.gov.uk/assets/images/ons-logo/kitemark/v2/uksa-kitemark-%s%s", language, extension),
AltText: altText,
Title: title,
About: about,
Enabled: false,
Enabled: true,
}
}
38 changes: 8 additions & 30 deletions helpers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ func TestToBoolPtr(t *testing.T) {
}

func TestGetOSRLogoDetails(t *testing.T) {
Convey("Given enableOfficialStatisticsLogo is true and useSvg is true", t, func() {
result := GetOSRLogoDetails(true, true, "en")
Convey("Given useSvg is true", t, func() {
result := GetOSRLogoDetails(true, "en")
So(result, ShouldResemble, osrlogo.OSRLogo{
URL: "https://cdn.ons.gov.uk/assets/images/ons-logo/kitemark/v2/uksa-kitemark-en.svg",
AltText: "Official Statistics logo",
Expand All @@ -173,8 +173,8 @@ func TestGetOSRLogoDetails(t *testing.T) {
})
})

Convey("Given enableOfficialStatisticsLogo is true and useSvg is false", t, func() {
result := GetOSRLogoDetails(true, false, "en")
Convey("Given useSvg is false", t, func() {
result := GetOSRLogoDetails(false, "en")
So(result, ShouldResemble, osrlogo.OSRLogo{
URL: "https://cdn.ons.gov.uk/assets/images/ons-logo/kitemark/v2/uksa-kitemark-en.png",
AltText: "Official Statistics logo",
Expand All @@ -184,30 +184,8 @@ func TestGetOSRLogoDetails(t *testing.T) {
})
})

Convey("Given enableOfficialStatisticsLogo is false and useSvg is true", t, func() {
result := GetOSRLogoDetails(false, true, "en")
So(result, ShouldResemble, osrlogo.OSRLogo{
URL: "https://cdn.ons.gov.uk/assets/images/ons-logo/kitemark/uksa-kitemark.svg",
AltText: "National Statistics Logo",
Title: "National Statistic",
About: "Certified by the UK Statistics Authority as compliant with the Code of Practice for Official Statistics.",
Enabled: false,
})
})

Convey("Given enableOfficialStatisticsLogo is false and useSvg is false", t, func() {
result := GetOSRLogoDetails(false, false, "en")
So(result, ShouldResemble, osrlogo.OSRLogo{
URL: "/img/national-statistics.png",
AltText: "National Statistics Logo",
Title: "National Statistic",
About: "Certified by the UK Statistics Authority as compliant with the Code of Practice for Official Statistics.",
Enabled: false,
})
})

Convey("Given enableOfficialStatisticsLogo is true, useSvg is true, and language is 'cy'", t, func() {
result := GetOSRLogoDetails(true, true, "cy")
Convey("Given useSvg is true, and language is 'cy'", t, func() {
result := GetOSRLogoDetails(true, "cy")
So(result, ShouldResemble, osrlogo.OSRLogo{
URL: "https://cdn.ons.gov.uk/assets/images/ons-logo/kitemark/v2/uksa-kitemark-cy.svg",
AltText: "Official Statistics logo",
Expand All @@ -217,8 +195,8 @@ func TestGetOSRLogoDetails(t *testing.T) {
})
})

Convey("Given enableOfficialStatisticsLogo is true, useSvg is false, and language is 'cy'", t, func() {
result := GetOSRLogoDetails(true, false, "cy")
Convey("Given useSvg is false, and language is 'cy'", t, func() {
result := GetOSRLogoDetails(false, "cy")
So(result, ShouldResemble, osrlogo.OSRLogo{
URL: "https://cdn.ons.gov.uk/assets/images/ons-logo/kitemark/v2/uksa-kitemark-cy.png",
AltText: "Official Statistics logo",
Expand Down

0 comments on commit 36cc514

Please sign in to comment.