-
Notifications
You must be signed in to change notification settings - Fork 5
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
EES-5593 Public API wildcard data set versioning #5577
EES-5593 Public API wildcard data set versioning #5577
Conversation
…dataSetVersion parameters endpoints support.
|
||
namespace GovUk.Education.ExploreEducationStatistics.Common.Utils; | ||
|
||
public record DataSetVersionRecord(int? Major, int? Minor, int? Patch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataSetVersionNumber
would probably be a better name for this?
Suffixing names with 'record' is also a bit funky and would absolutely avoid naming things like this unless there were no better options.
The test class would need to be updated as well
return successful; | ||
} | ||
|
||
static bool TryParseWildCard(string versionString, [NotNullWhen(true)] ref DataSetVersionRecord? version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should be private?
- Typo - 'Wildcard' not 'WildCard'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, and apologies, you left the typo comment before but it's crept in again with my refactor
public static bool TryParse(string versionString, out DataSetVersionRecord? version) | ||
{ | ||
version = null; | ||
if (versionString.Contains("*")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use '*'
char here to save allocating a string
if (versionString.Contains("*")) | ||
return TryParseWildCard(versionString, ref version); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda nitpicky, but we're going against the grain for most of the project's code style by not having if
statements with braces.
The main issue is that it highlights as warnings in Rider (green squiggles):
In general, we consider most of the default formatting in Rider as the project's style. If you're not against using different tooling, there'll be fewer issues if you switch to Rider instead of VS.
Regardless of tooling, to avoid potentially causing friction later on with people updating the code to match the expected style, would suggest adding in the line breaks.
Same with the successful case below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to incorporate this with my IDE
if (parts.Length > 3) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to earlier comment - could add braces.
Same below as well for next conditional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
public static async Task<Either<ActionResult, DataSetVersion>> FindByVersion( | ||
this IQueryable<DataSetVersion> queryable, | ||
Guid dataSetId, | ||
string version, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
if (!VersionUtils.TryParse(version, out var semVersion)) | ||
{ | ||
if (!DataSetVersionRecord.TryParse(version, out var parsedVersion)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to other comments - would suggest keeping conditional braces in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Nick. I'll make it a habit of doing this (+ see if my IDE can help me).
This PR (originally #5559) adds datasets wildcard versioning support to the following API endpoints:
For example:
dataSetVersion=2.*
should return the latest minor version in the v2 seriesdataSetVersion=2.1
should return v2.1dataSetVersion=2.0
should return v2.0dataSetVersion=2
should return v2.0Huge thanks to @leeoades for your support on this.