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

[GitHubReleaseDate] - published_at field #8543

Merged
merged 5 commits into from
Oct 20, 2022

Conversation

PaulaBarszcz
Copy link
Collaborator

@PaulaBarszcz PaulaBarszcz commented Oct 17, 2022

closes #6309

For the GitHub Release Date badge by default we still use the created_at field.
Now, if the user gives the display_date=published_at query param, that field from the API response would be used.

https://api.github.com/repos/microsoft/vscode/releases/latest
3

http://localhost:8080/github/release-date/microsoft/vscode

http://localhost:8080/github/release-date/microsoft/vscode?display_date=published_at

Screenshot_3

Screenshot_2

a

@shields-ci
Copy link

shields-ci commented Oct 17, 2022

Messages
📖 ✨ Thanks for your contribution to Shields, @PaulaBarszcz!

Generated by 🚫 dangerJS against 57753ff

@PaulaBarszcz PaulaBarszcz marked this pull request as ready for review October 17, 2022 19:38
Comment on lines 95 to 108
if (Array.isArray(body)) {
if (queryParams.display_date === 'published_at') {
return this.constructor.render({ date: body[0].published_at })
}

return this.constructor.render({ date: body[0].created_at })
}

if (queryParams.display_date === 'published_at') {
return this.constructor.render({ date: body.published_at })
}

return this.constructor.render({ date: body.created_at })
}
Copy link
Member

Choose a reason for hiding this comment

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

In javascript you can address an object property defined by a variable using square brackets, so you should be able to reduce all this to just

if (Array.isArray(body)) {
  return this.constructor.render({ date: body[0][queryParams.display_date] })
}
return this.constructor.render({ date: body[queryParams.display_date] })

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Neat, thanks. Updated.

@chris48s chris48s merged commit a251357 into badges:master Oct 20, 2022
@chris48s chris48s added the service-badge New or updated service badge label Oct 20, 2022
@PaulaBarszcz PaulaBarszcz deleted the github-release-date-published-at branch November 1, 2022 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

github/release-date displaying incorrect date
3 participants