Skip to content

Time Series Profile Controllers #856

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

Merged

Conversation

zack-rma
Copy link
Collaborator

Implementation of Time Series Profile Definition, Parser, and Instance controllers

@zack-rma
Copy link
Collaborator Author

Current TimeSeriesProfileInstanceDao Catalog implementation does not return parameter list for the TimeSeriesProfiles

@zack-rma zack-rma marked this pull request as ready for review September 4, 2024 15:43
@zack-rma
Copy link
Collaborator Author

zack-rma commented Sep 12, 2024

After discussion with the team, a new data structure for the TSP Instances has been developed that should allow for paging implementation and improved consistency across endpoints that deal with time series data (gate changes, turbines, etc). Here's JSON of that new structure. @MikeNeilson Please take a look and let me know your thoughts.

{
  "time-series-profile": {
    "location-id": {
      "office-id": "SWT",
      "name": "SWAN"
    },
    "description": "Description",
    "parameter-list": [
      "Temp-Water",
      "Depth"
    ],
    "key-parameter": "Depth",
    "reference-ts-id": {
      "office-id": "SWT",
      "name": "SWAN.Depth.Inst.0.0.DSS-Obs"
    }
  },
  "parameter-columns": [
    {
      "parameter": "Temp",
      "ordinal": 1,
      "units": "F"
    },
    {
      "parameter": "Depth",
      "ordinal": 2,
      "units": "m"
    }
  ],
  "data-columns": [
    {
      "name": "value",
      "ordinal": 1,
      "datatype": "java.lang.Double"
    },
    {
      "name": "quality",
      "ordinal": 2,
      "datatype": "java.lang.Integer"
    }
  ],
  "time-series": [
    {
      "1612869582120": [
        [86.5, 0],
        [98.6, 0]
      ],
      "1612869682120": [
        [86.999, 0],
        [98.6, 0]
      ],
      "1612870682120": [
        [],
        [98.6, 0]
      ]
    }
  ],
  "location-time-zone": "PST",
  "version": "DSS-Obs",
  "version-date": 1594786000000,
  "first-date": 1594296000000,
  "last-date": 1752062400000,
  "page-first-date": 1594296000000,
  "page-last-date": 1752062400000,
  "page": 1,
  "page-size": 50,
  "cursor": "cursorData"
}

@MikeNeilson
Copy link
Contributor

Looks reasonable to me. Might be good to provide a total field in addition to the page and page-size, would let applications be able to properly render a progress bar.

@rma-bryson
Copy link
Collaborator

rma-bryson commented Sep 12, 2024

"parameter-list": [ "Temp-Water", "Depth" ], "key-parameter": "Depth",

Thoughts on changing this to something like:

"dependent-parameters": [ "Temp-Water", "Dissolved Oxygen" ], "independent-parameter": "Depth",

Unless key-parameter means something other than specifying the independent variable

@MikeNeilson
Copy link
Contributor

I believe it does. One of the parameters is used as basically a reference point for other operations.

@zack-rma zack-rma marked this pull request as draft September 18, 2024 15:38
@zack-rma zack-rma marked this pull request as ready for review September 18, 2024 22:33
@zack-rma zack-rma requested a review from adamkorynta October 24, 2024 17:57
adamkorynta
adamkorynta previously approved these changes Oct 24, 2024
@zack-rma zack-rma requested a review from MikeNeilson October 24, 2024 20:18
adamkorynta
adamkorynta previously approved these changes Oct 25, 2024
Copy link
Contributor

@MikeNeilson MikeNeilson left a comment

Choose a reason for hiding this comment

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

A few comments. The test imply the areas I'm asking already do what's asked for VERSION_DATE, but it wasn't super obvious when looking through the controllers themselves.

.getOrDefault(true);
boolean previous = ctx.queryParamAsClass(PREVIOUS, boolean.class).getOrDefault(false);
boolean next = ctx.queryParamAsClass(NEXT, boolean.class).getOrDefault(false);
Instant versionDate = ctx.queryParamAsClass(VERSION_DATE, String.class).getOrDefault(null) == null
? null : Instant.ofEpochMilli(Long.parseLong(ctx.queryParamAsClass(VERSION_DATE, String.class)
.getOrDefault(null)));
? null : Instant.parse(ctx.queryParamAsClass(VERSION_DATE, String.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this take the ISO8601 formats?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to take in ISO 8601 format

@@ -62,14 +68,14 @@ public TimeSeriesProfileInstanceCreateController(MetricRegistry metrics) {
@OpenApiParam(name = OVERRIDE_PROTECTION, type = Boolean.class, description = "Override protection"
+ " for the time series profile instance. Default is false"),
@OpenApiParam(name = VERSION_DATE, type = Long.class, description = "The version date of the"
Copy link
Contributor

Choose a reason for hiding this comment

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

The Time Series controller allows the ISO8601 formats, shouldn't we do that here as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated documentation and added tests, now supports ISO 8601 entry

+ " time series profile instance. Default is UTC"),
@OpenApiParam(name = TIMEZONE, description = "Specifies "
+ "the time zone of the values of the begin and end fields. If this field is not specified, "
+ "the default time zone of UTC shall be used."),
@OpenApiParam(name = VERSION_DATE, type = Instant.class, description = "The version date of the"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as others. regarding version 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.

Updated to support ISO8601

.getOrDefault(Instant.now().toEpochMilli()));
Instant firstDate = Instant.ofEpochMilli(ctx.queryParamAsClass(DATE, Long.class)
.getOrDefault(Instant.now().toEpochMilli()));
Instant versionDate = requiredInstant(ctx, VERSION_DATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

VersionDate is Long in the OpenAPI annotation, but can be string here.

NOTE: I'm pretty sure this line is correct and this code should be used in the other controllers that process a version date as it centralizes the flexibility.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed annotation to Instant. Allows for string entry as a long or ISO 8601 format.

SelectHavingStep<Record1<Integer>> count = dsl.select(countDistinct(VIEW_TSV2.DATE_TIME))
.from(VIEW_TSV2)
.where(finalWhereCondition);
total = Objects.requireNonNull(count.fetchOne()).value1();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an odd use of requireNonNull, why aren't we throwing a more specific exception, or none at all if this condition is okay.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed usage, replaced with NullPointerException error handling

builder.withPageLastDate(timeList.stream().max(Instant::compareTo).orElse(null));
builder.withVersionDate(versionDate);
return builder
.build();
Copy link
Contributor

Choose a reason for hiding this comment

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

No a huge deal but this doesn't need to be on a new line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to same line

@zack-rma zack-rma requested a review from MikeNeilson November 13, 2024 17:07
Copy link
Contributor

@MikeNeilson MikeNeilson left a comment

Choose a reason for hiding this comment

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

This seems reasonable to me. That said I've been away not reading code for a week so I'm gonna let someone else do the final approval.

Nothing major jumped out. The parameter look reasonable and the tests seemed only as difficult to follow as the data set requires.

@adamkorynta adamkorynta merged commit 5d10b94 into USACE:develop Nov 21, 2024
4 of 5 checks passed
@zack-rma zack-rma deleted the feature/TimeSeriesProfileController branch February 21, 2025 17:33
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.

5 participants