Skip to content

Commit

Permalink
added support to analysis date parameter on versioned queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirko Petrelli committed Aug 21, 2024
1 parent 4129667 commit 3de046f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Artesian/Artesian.SDK.Tests/VersionedTimeSerieQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2651,6 +2651,15 @@ public void Ver_RelativePeriodExtractionWindowChange()
.WithVerb(HttpMethod.Get)
.Times(1);

var test4 = partialQuery
.ForAnalysisDate(new LocalDate(2018, 07, 19))
.ExecuteAsync().Result;

httpTest.ShouldHaveCalledPath($"{_cfg.BaseAddress}query/v1.0/vts/MUV/Day/P5D")
.WithQueryParam("ad", "2018-07-19")
.WithVerb(HttpMethod.Get)
.Times(1);

}
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public IEnumerable<VersionedQueryParamaters> Partition(IEnumerable<VersionedQuer
queryParamater.VersionSelectionType,
queryParamater.VersionLimit,
queryParamater.FillerKindType,
queryParamater.FillerConfig
queryParamater.FillerConfig,
queryParamater.AnalysisDate
)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public VersionedQueryParamaters()
/// <param name="versionLimit"></param>
/// <param name="fillerK"></param>
/// <param name="fillerConfig"></param>
/// <param name="analysisDate"></param>
public VersionedQueryParamaters(
IEnumerable<int> ids,
ExtractionRangeSelectionConfig extractionRangeSelectionConfig,
Expand All @@ -47,7 +48,8 @@ public VersionedQueryParamaters(
VersionSelectionType? versionSelectionType,
LocalDateTime? versionLimit,
FillerKindType fillerK,
FillerConfig fillerConfig
FillerConfig fillerConfig,
LocalDate? analysisDate
)
: base(ids, extractionRangeSelectionConfig, extractionRangeType, timezone, filterId, fillerK, fillerConfig)
{
Expand All @@ -56,6 +58,7 @@ FillerConfig fillerConfig
this.Granularity = granularity;
this.TransformId = transformId;
this.VersionLimit = versionLimit;
this.AnalysisDate = analysisDate;
this.FillerConfig = fillerConfig;
}

Expand All @@ -79,5 +82,9 @@ FillerConfig fillerConfig
/// Version Limit
/// </summary>
public LocalDateTime? VersionLimit { get; set; }
/// <summary>
/// The analysis date from which apply the relative interval (default Today)
/// </summary>
public LocalDate? AnalysisDate { get; set; }
}
}
16 changes: 16 additions & 0 deletions Artesian/Artesian.SDK/Service/Query/VersionedQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ public VersionedQuery ForVersion(LocalDateTime version)
return this;
}
/// <summary>
/// Set a specific analysis date from wich apply the relative interval/period
/// </summary>
/// <returns>VersionedQuery</returns>
public VersionedQuery ForAnalysisDate(LocalDate analysisDate)
{
_queryParamaters.AnalysisDate = analysisDate;

return this;
}
/// <summary>
/// Set the Filler strategy to Null
/// </summary>
/// <returns>VersionedQuery</returns>
Expand Down Expand Up @@ -415,6 +425,11 @@ protected override void _validateQuery()
}
}

if (
( _queryParamaters.ExtractionRangeSelectionConfig.DateStart != null || _queryParamaters.ExtractionRangeSelectionConfig.DateEnd != null )

Check warning on line 429 in Artesian/Artesian.SDK/Service/Query/VersionedQuery.cs

View workflow job for this annotation

GitHub Actions / Build

The result of the expression is always 'true' since a value of type 'LocalDate' is never equal to 'null' of type 'LocalDate?'

Check warning on line 429 in Artesian/Artesian.SDK/Service/Query/VersionedQuery.cs

View workflow job for this annotation

GitHub Actions / Build

The result of the expression is always 'true' since a value of type 'LocalDate' is never equal to 'null' of type 'LocalDate?'
&& _queryParamaters.AnalysisDate != null
)
throw new ArtesianSdkClientException("Analysis should be related to a Period. Provide a period or remove analysis date.");
}

private string _buildVersionRoute(VersionedQueryParamaters queryParamaters)
Expand Down Expand Up @@ -492,6 +507,7 @@ private List<string> _buildRequest()
.SetQueryParam("fillerK", qp.FillerKindType)
.SetQueryParam("fillerDV", qp.FillerConfig.FillerTimeSeriesDV)
.SetQueryParam("fillerP", qp.FillerConfig.FillerPeriod)
.SetQueryParam("ad", qp.AnalysisDate)
.ToString())
.ToList();

Expand Down

0 comments on commit 3de046f

Please sign in to comment.