Skip to content

Commit

Permalink
Map provisional date to release response
Browse files Browse the repository at this point in the history
  • Loading branch information
lindenmckenzie committed May 15, 2024
1 parent e252b17 commit b9a3647
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
44 changes: 23 additions & 21 deletions transformer/releasetransformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,18 @@ type ESReleaseResponseHit struct {
}

type ESReleaseSourceDocument struct {
URI string `json:"uri"`
Title string `json:"title"`
Summary string `json:"summary"`
ReleaseDate string `json:"release_date,omitempty"`
Published bool `json:"published"`
Cancelled bool `json:"cancelled"`
Finalised bool `json:"finalised"`
Survey string `json:"survey"`
Keywords []string `json:"keywords,omitempty"`
Language string `json:"language,omitempty"`
DateChanges []dateChange `json:"date_changes,omitempty"`
URI string `json:"uri"`
Title string `json:"title"`
Summary string `json:"summary"`
ReleaseDate string `json:"release_date,omitempty"`
Published bool `json:"published"`
Cancelled bool `json:"cancelled"`
Finalised bool `json:"finalised"`
Survey string `json:"survey"`
Keywords []string `json:"keywords,omitempty"`
Language string `json:"language,omitempty"`
DateChanges []dateChange `json:"date_changes,omitempty"`
ProvisionalDate string `json:"provisional_date,omitempty"`
}

type dateChange struct {
Expand Down Expand Up @@ -211,16 +212,17 @@ func buildRelease(hit ESReleaseResponseHit, highlighter *strings.Replacer) Relea
r := Release{
URI: hit.Source.URI,
Description: ReleaseDescription{
Title: sd.Title,
Summary: sd.Summary,
ReleaseDate: sd.ReleaseDate,
Published: sd.Published,
Cancelled: sd.Cancelled,
Finalised: sd.Finalised,
Postponed: isPostponed(sd),
Census: isCensus(sd),
Keywords: sd.Keywords,
Language: sd.Language,
Title: sd.Title,
Summary: sd.Summary,
ReleaseDate: sd.ReleaseDate,
Published: sd.Published,
Cancelled: sd.Cancelled,
Finalised: sd.Finalised,
Postponed: isPostponed(sd),
Census: isCensus(sd),
Keywords: sd.Keywords,
Language: sd.Language,
ProvisionalDate: sd.ProvisionalDate,
},
}

Expand Down
3 changes: 2 additions & 1 deletion transformer/testdata/search_release_es_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"topics":null,
"finalised":true,
"cancelled":false,
"published":false
"published":false,
"provisional_date": "August to September"
},
"highlight":{
"summary":[
Expand Down
2 changes: 2 additions & 0 deletions transformer/testdata/search_release_expected_highlighted.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"census":false,
"national_statistic":false,
"latest_release":false,
"provisional_date": "August to September",
"contact":{
"name":"Sarah Caul",
"telephone":"+44 (0)1633 456490",
Expand All @@ -47,6 +48,7 @@
"national_statistic":true,
"next_release":"22 November 2018",
"latest_release":false,
"provisional_date": "2018-08-23",
"contact":{
"name":"Yanitsa Petkova ",
"telephone":"+44 (0)1633 651599 ",
Expand Down
1 change: 1 addition & 0 deletions transformer/testdata/search_release_expected_plain.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"postponed":true,
"national_statistic":false,
"latest_release":false,
"provisional_date": "August to September",
"contact":{
"name":"Sarah Caul",
"telephone":"+44 (0)1633 456490",
Expand Down

0 comments on commit b9a3647

Please sign in to comment.