Skip to content

Commit

Permalink
Add 'created after' filter to ListMeasurements and StreamMeasurements (
Browse files Browse the repository at this point in the history
  • Loading branch information
roaminggypsy authored Sep 25, 2024
1 parent 89ce490 commit f9a5852
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bazel_dep(
)
bazel_dep(
name = "cross-media-measurement-api",
version = "0.66.0",
version = "0.67.0",
repo_name = "wfa_measurement_proto",
)
bazel_dep(
Expand Down
32 changes: 3 additions & 29 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class StreamMeasurements(
private const val UPDATED_AFTER = "updatedAfter"
private const val UPDATED_BEFORE = "updatedBefore"
private const val CREATED_BEFORE = "createdBefore"
private const val CREATED_AFTER = "createdAfter"
private const val STATES_PARAM = "states"
private const val DUCHY_ID_PARAM = "duchyId"

Expand Down Expand Up @@ -130,6 +131,11 @@ class StreamMeasurements(
bind(CREATED_BEFORE to filter.createdBefore.toGcloudTimestamp())
}

if (filter.hasCreatedAfter()) {
conjuncts.add("Measurements.CreateTime > @$CREATED_AFTER")
bind(CREATED_AFTER to filter.createdAfter.toGcloudTimestamp())
}

if (filter.externalDuchyId.isNotEmpty()) {
val duchyId: Long =
DuchyIds.getInternalId(filter.externalDuchyId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,10 @@ private fun ListMeasurementsRequest.toListMeasurementsPageToken(): ListMeasureme
"Arguments must be kept the same when using a page token"
}

grpcRequire(source.filter.createdAfter == this.createdAfter) {
"Arguments must be kept the same when using a page token"
}

grpcRequire(source.filter.createdBefore == this.createdBefore) {
"Arguments must be kept the same when using a page token"
}
Expand Down Expand Up @@ -810,6 +814,7 @@ private fun ListMeasurementsRequest.toListMeasurementsPageToken(): ListMeasureme
updatedBefore = source.filter.updatedBefore
updatedAfter = source.filter.updatedAfter
createdBefore = source.filter.createdBefore
createdAfter = source.filter.createdAfter
}
}
}
Expand All @@ -824,6 +829,7 @@ private fun ListMeasurementsPageToken.toStreamMeasurementsRequest(): StreamMeasu
filter = filter {
externalMeasurementConsumerId = source.externalMeasurementConsumerId
states += source.statesList.map { it.toInternalState() }.flatten()
createdAfter = source.createdAfter
createdBefore = source.createdBefore
updatedBefore = source.updatedBefore
updatedAfter = source.updatedAfter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ message ListMeasurementsPageToken {
google.protobuf.Timestamp updated_after = 5;
google.protobuf.Timestamp updated_before = 6;
google.protobuf.Timestamp created_before = 7;
google.protobuf.Timestamp created_after = 8;
}

message ListRequisitionsPageToken {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ message StreamMeasurementsRequest {
string externalDuchyId = 7;
google.protobuf.Timestamp updated_before = 8;
google.protobuf.Timestamp created_before = 9;
google.protobuf.Timestamp created_after = 11;

message After {
google.protobuf.Timestamp update_time = 1;
Expand Down
Loading

0 comments on commit f9a5852

Please sign in to comment.