Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update txt metadata #82

Merged
merged 1 commit into from
Mar 27, 2023
Merged

update txt metadata #82

merged 1 commit into from
Mar 27, 2023

Conversation

andre-urbani
Copy link
Contributor

What

Update txt download for BYO
Trello - https://trello.com/c/JkyoYKdQ/6077-update-txt-download-for-byo

How to review

Confirm changes match the requested changes in Trello ticket

Who can review

Anyone

Copy link

@nshumoogum nshumoogum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as all comments are improvements and will leave it for the team or Andre to decide if they would like to do it

var b bytes.Buffer
var titleDims []string
dt := time.Now()
issuedDate := dt.Format("01-02-2006")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not make sense for this to include the time down to the minute?

var b bytes.Buffer
func NewMetadata(m *dataset.Metadata, isCustom bool, filterOutputID, downloadServiceURL string) []byte {
if isCustom {
var b bytes.Buffer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be worth splitting custom dataset metadata and non custom metadata separated into two separate functions? That way easier to test logic


"github.com/ONSdigital/dp-api-clients-go/v2/dataset"
)

func NewMetadata(m *dataset.Metadata) []byte {
var b bytes.Buffer
func NewMetadata(m *dataset.Metadata, isCustom bool, filterOutputID, downloadServiceURL string) []byte {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function could do with some unit tests

if len(contacts) > 0 {
b.WriteString(fmt.Sprintf("Contact: %s, %s, %s\n", contacts[0].Name, contacts[0].Email, contacts[0].Telephone))
for _, d := range m.Version.Dimensions {
titleDims = append(titleDims, d.Label)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add a separator between each dimension label?

b.WriteString(fmt.Sprintf("Issued: %s\n", issuedDate))
b.WriteString(fmt.Sprintf("Language: %s\n", "English"))
b.WriteString("Distribution:\n")
for k, v := range m.Downloads {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to do the same for loop for non custom dataset? Like so:

		for k, v := range m.Downloads {
			b.WriteString(fmt.Sprintf("\tExtension: %s\n", k))
			b.WriteString(fmt.Sprintf("\tSize: %s\n", v.Size))
			b.WriteString(fmt.Sprintf("\tURL: %s\n\n", v.URL))
		}

If yes, then can move this to a separate function and can be used by both sections

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is possible as v.URL does not contain the correct url, therefore they need to be processed separately depending on the file type

}
}
if m.Version.IsBasedOn != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variables that should be the same for custom or non custom dataset could be defined outside of if/else statement; saves the number of lines in the code

@andre-urbani
Copy link
Contributor Author

I'm going to merge to develop for now as this ideally needs to be ready for "go live" tomorrow. I will work on the requested changes afterwards

@andre-urbani andre-urbani merged commit 1f04316 into develop Mar 27, 2023
@andre-urbani andre-urbani deleted the feature/update-txt-metadata branch March 27, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants