-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix(asset): calibration forecast timezone issues on datalinks #111
Conversation
## [3.43.5](v3.43.4...v3.43.5) (2024-11-14) ### Bug Fixes * **asset:** calibration forecast timezone issues on datalinks ([#111](#111)) ([f5209e8](f5209e8))
🎉 This PR is included in version 3.43.5 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
@@ -101,7 +101,8 @@ export class CalibrationForecastDataSource extends AssetDataSourceBase { | |||
return null; | |||
} | |||
|
|||
processResultsGroupedByTime(result: DataFrameDTO, timeGrouping: AssetCalibrationForecastKey) { | |||
processResultsGroupedByTime(result: DataFrameDTO, timeGrouping: AssetCalibrationForecastKey, options: DataQueryRequest) { | |||
const originalValuesMap = this.constructDataLinkValuesMap(result, options); |
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.
As the method name is constructDataLinkValuesMap
, maybe dataLinkValuesMap
would be more suitable name.
@@ -101,7 +101,8 @@ export class CalibrationForecastDataSource extends AssetDataSourceBase { | |||
return null; | |||
} | |||
|
|||
processResultsGroupedByTime(result: DataFrameDTO, timeGrouping: AssetCalibrationForecastKey) { | |||
processResultsGroupedByTime(result: DataFrameDTO, timeGrouping: AssetCalibrationForecastKey, options: DataQueryRequest) { | |||
const originalValuesMap = this.constructDataLinkValuesMap(result, options); | |||
result.fields.forEach(field => { | |||
field.name = this.createColumnNameFromDescriptor(field as FieldDTOWithDescriptor); | |||
const formatter = this.forecastDateFormatterMap.get(field.name as AssetCalibrationForecastKey); |
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.
While here, dateFormatter
might be a better name for this as well.
} | ||
}); | ||
} | ||
|
||
private constructDataLinkBaseUrl(){ | ||
private constructDataLinkValuesMap(result: DataFrameDTO, options: DataQueryRequest): Map<string, { from: number, to: number }> { | ||
const originalValuesMap = new Map<string, { from: number, to: number }>(); |
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.
dataLinkValuesMap
might be more suited here as well.
if (formatter) { | ||
let value = { from: 0, to: 0 } | ||
const formattedValues: string[] = field.values!.map(formatter); | ||
if (originalValues.length === 0) { |
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.
Using the available timeGrouping
or the current condition along with timeGrouping
might make it easier to understand. I believe length 1 is Week and the else statement has logic for both Day and Month.
} | ||
|
||
private createDataLinks(timeGrouping: AssetCalibrationForecastKey): DataLink[] { | ||
private createDataLinks(timeGrouping: AssetCalibrationForecastKey, originalValuesMap: Map<string, { from: any, to: any }>): DataLink[] { |
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.
The type I think is { from: number, to: number }
, so we can avoid any.
@@ -130,36 +172,12 @@ export class CalibrationForecastDataSource extends AssetDataSourceBase { | |||
if (!options.replaceVariables) { | |||
return url; | |||
} | |||
|
|||
const value = options.replaceVariables(`\${__data.fields.${timeGrouping}}`); |
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.
We could have something like this if we don't have a value for the map every time.
const value = options.replaceVariables(`\${__data.fields.${timeGrouping}}`);
const valueAsDate = originalValuesMap.get(value);
if (!value && !valueAsDate) {
return url;
}
return `${url}&from=${valueAsDate.from}&to=${valueAsDate.to}`;
If we do have a value every time, what about something like this?
const value = options.replaceVariables(`\${__data.fields.${timeGrouping}}`);
if (!value) {
return url;
}
const [from, to] = originalValuesMap.get(value)!;
return `${url}&from=${from}&to=${to}`;
Pull Request
🤨 Rationale
👩💻 Implementation
🧪 Testing
✅ Checklist