Skip to content

Commit

Permalink
Rename request_id in Report.ReportingMetric to create_metric_request_id.
Browse files Browse the repository at this point in the history
  • Loading branch information
riemanli committed Jun 1, 2023
1 parent 7a64c29 commit 9b484f2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ fun InternalReport.ReportingMetric.toCreateMetricRequest(
metricSpec = source.details.metricSpec.toMetricSpec()
filters += source.details.filtersList
}
requestId = source.requestId
requestId = source.createMetricRequestId
}
}

Expand Down
17 changes: 12 additions & 5 deletions src/main/proto/wfa/measurement/internal/reporting/v2/report.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@ message Report {
google.protobuf.Timestamp create_time = 3;

message ReportingMetric {
// Will be filled by the internal reports service. For now, generating a new
// UUID. In the future when metric reuse is done. Two cases--(1) When there
// is no metric can be found based on the metric config from 3-6, generate a
// new UUID. (2) When a corresponding metric is found, fill its request ID.
string request_id = 1;
// Request ID for the CreateMetric method.
//
// The request ID will be filled by the internal reports service. For now,
// it generates a new UUID directly.
// In the future when metric reuse is done, two cases--(1) When there is no
// metric can be found based on the metric config, generate a new UUID. (2)
// When a corresponding metric is found, fill its request ID and the
// external metric ID.
string create_metric_request_id = 1;

// External ID for the metric.
//
// Will be filled by the internal reports service. Use the request ID above
// to find the metric.
fixed64 external_metric_id = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ CREATE TABLE SetExpressions (
ReportingSetId bigint NOT NULL,
SetExpressionId bigint NOT NULL,

-- org.wfanet.measurement.internal.reporting.SetExpression.Operation
-- wfa.measurement.internal.reporting.SetExpression.Operation
-- protobuf enum encoded as an integer.
Operation integer NOT NULL,

Expand Down Expand Up @@ -227,7 +227,7 @@ CREATE TABLE Metrics (
TimeIntervalStart TIMESTAMP WITH TIME ZONE NOT NULL,
TimeIntervalEndExclusive TIMESTAMP WITH TIME ZONE NOT NULL,

-- org.wfanet.measurement.internal.reporting.MetricSpec.MetricType
-- wfa.measurement.internal.reporting.MetricSpec.MetricType
-- protobuf oneof encoded as an integer.
MetricType integer NOT NULL,

Expand All @@ -251,7 +251,7 @@ CREATE TABLE Metrics (
-- Serialized byte string of a proto3 protobuf with details about the
-- metric which do not need to be indexed by the database.
--
-- See org.wfanet.measurement.internal.reporting.Metric.Details protobuf
-- See wfa.measurement.internal.reporting.Metric.Details protobuf
-- message.
MetricDetails bytea NOT NULL,

Expand All @@ -277,14 +277,14 @@ CREATE TABLE Measurements (
TimeIntervalStart TIMESTAMP WITH TIME ZONE NOT NULL,
TimeIntervalEndExclusive TIMESTAMP WITH TIME ZONE NOT NULL,

-- org.wfanet.measurement.internal.reporting.Report.Measurement.State
-- wfa.measurement.internal.reporting.Report.Measurement.State
-- protobuf enum encoded as an integer.
State integer NOT NULL,

-- Serialized byte string of a proto3 protobuf with details about the
-- measurement which do not need to be indexed by the database.
--
-- See org.wfanet.measurement.internal.reporting.Measurement.Details protobuf
-- See wfa.measurement.internal.reporting.Measurement.Details protobuf
-- message.
MeasurementDetails bytea NOT NULL,

Expand Down Expand Up @@ -359,7 +359,7 @@ CREATE TABLE ReportTimeIntervals (
ON DELETE CASCADE
);

-- changeset riemanli:create-metric-calculations-table dbms:postgresql
-- changeset riemanli:create-metric-calculation-specs-table dbms:postgresql
CREATE TABLE MetricCalculationSpecs (
MeasurementConsumerId bigint NOT NULL,
ReportId bigint NOT NULL,
Expand All @@ -369,7 +369,7 @@ CREATE TABLE MetricCalculationSpecs (
-- Serialized byte string of a proto3 protobuf with details about the
-- metric calculation which do not need to be indexed by the database.
--
-- See org.wfanet.measurement.internal.reporting.Report.MetricCalculationSpec.Details
-- See wfa.measurement.internal.reporting.Report.MetricCalculationSpec.Details
-- protobuf message.
MetricCalculationSpecDetails bytea NOT NULL,

Expand All @@ -386,24 +386,24 @@ CREATE TABLE MetricCalculationSpecs (
ON DELETE CASCADE
);

-- changeset riemanli:create-metric-calculation-metrics-table dbms:postgresql
CREATE TABLE MetricCalculationSpecMetrics (
-- changeset riemanli:create-metric-calculation-spec-reporting-metrics-table dbms:postgresql
CREATE TABLE MetricCalculationSpecReportingMetrics (
MeasurementConsumerId bigint NOT NULL,
ReportId bigint NOT NULL,
MetricCalculationSpecId bigint NOT NULL,
MetricId bigint,
CreateMetricRequestId uuid NOT NULL,
MetricId bigint,

-- Serialized byte string of a proto3 protobuf with details about the
-- Report.CreateMetricRequest which do not need to be indexed by the database.
-- Report.ReportingMetric which do not need to be indexed by the database.
--
-- See org.wfanet.measurement.internal.reporting.Report.CreateMetricRequest.Details
-- See wfa.measurement.internal.reporting.Report.ReportingMetric.Details
-- protobuf message.
CreateMetricRequestDetails bytea NOT NULL,
ReportingMetricDetails bytea NOT NULL,

-- Human-readable copy of the CreateMetricRequestDetails column solely for
-- Human-readable copy of the ReportingMetricDetails column solely for
-- debugging purposes.
CreateMetricRequestDetailsJson text NOT NULL,
ReportingMetricDetailsJson text NOT NULL,

PRIMARY KEY(MeasurementConsumerId, ReportId, MetricCalculationSpecId, CreateMetricRequestId),
FOREIGN KEY(MeasurementConsumerId, ReportId, MetricCalculationSpecId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ class ReportsServiceTest {
var requestId = 0
reportingSetToCreateMetricRequestMap.map { (reportingSet, createMetricRequest) ->
val updatedReportingCreateMetricRequests =
listOf(createMetricRequest.copy { this.requestId = requestId.toString() })
listOf(createMetricRequest.copy { this.createMetricRequestId = requestId.toString() })
requestId++
reportingMetricEntries.putAll(
buildInternalReportingMetricEntryWithOneMetricCalculationSpec(
Expand All @@ -736,7 +736,7 @@ class ReportsServiceTest {
val updatedReportingCreateMetricRequests =
listOf(
createMetricRequest.copy {
this.requestId = requestId.toString()
this.createMetricRequestId = requestId.toString()
externalMetricId = EXTERNAL_METRIC_ID_BASE + requestId
}
)
Expand Down Expand Up @@ -910,7 +910,7 @@ class ReportsServiceTest {
internalMetricCalculationSpec.copy {
val updatedReportingMetrics =
reportingMetrics.map { reportingMetric ->
reportingMetric.copy { this.requestId = requestId.toString() }
reportingMetric.copy { this.createMetricRequestId = requestId.toString() }
}
this.reportingMetrics.clear()
this.reportingMetrics += updatedReportingMetrics
Expand All @@ -934,7 +934,7 @@ class ReportsServiceTest {
val updatedReportingMetrics =
reportingMetrics.map { reportingMetric ->
reportingMetric.copy {
this.requestId = requestId.toString()
this.createMetricRequestId = requestId.toString()
externalMetricId = EXTERNAL_METRIC_ID_BASE + requestId
}
}
Expand Down Expand Up @@ -1111,7 +1111,7 @@ class ReportsServiceTest {

val updatedReportingCreateMetricRequests =
reportingCreateMetricRequests.mapIndexed { requestId, request ->
request.copy { this.requestId = requestId.toString() }
request.copy { this.createMetricRequestId = requestId.toString() }
}

reportingMetricEntries.putAll(
Expand All @@ -1130,7 +1130,7 @@ class ReportsServiceTest {
val updatedReportingCreateMetricRequests =
reportingCreateMetricRequests.mapIndexed { requestId, request ->
request.copy {
this.requestId = requestId.toString()
this.createMetricRequestId = requestId.toString()
externalMetricId = EXTERNAL_METRIC_ID_BASE + requestId
}
}
Expand Down Expand Up @@ -1985,7 +1985,7 @@ class ReportsServiceTest {

val reportingCreateMetricRequests =
reportingMetrics.mapIndexed { requestId, request ->
request.copy { this.requestId = requestId.toString() }
request.copy { this.createMetricRequestId = requestId.toString() }
}

reportingMetricEntries.putAll(
Expand All @@ -2003,7 +2003,7 @@ class ReportsServiceTest {
val reportingCreateMetricRequests =
reportingMetrics.mapIndexed { requestId, request ->
request.copy {
this.requestId = requestId.toString()
this.createMetricRequestId = requestId.toString()
externalMetricId = EXTERNAL_METRIC_ID_BASE + requestId
}
}
Expand Down

0 comments on commit 9b484f2

Please sign in to comment.