Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/log/usagelogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type StatVarLog struct {
StatVarDCID string `json:"stat_var_dcid"`
// List of all facets that provided results for the given statVar.
Facets []*FacetLog `json:"facets"`
// The number of entities included in this statVar's results.
NumSeries int `json:"num_series"`
}

// Full log with all information for the current query.
Expand Down Expand Up @@ -123,6 +125,8 @@ func MakeStatVarLogs(observationResponse *pbv2.ObservationResponse) ([]*StatVarL
if _, ok := statVarsByDcid[variable]; !ok {
statVarsByDcid[variable] = &StatVarLog{
StatVarDCID: variable,
// capturing the number of entities for this statVar
NumSeries: len(varObs.ByEntity),
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/server/handler_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestObservationInternal(t *testing.T) {
Dcids: []string{"country/USA"},
},
},
shared.QueryTypeExistence,
shared.QueryTypeExistenceByEntity,
&pbv2.ObservationResponse{
ByVariable: map[string]*pbv2.VariableObservation{
"Count_Person": {},
Expand Down
4 changes: 2 additions & 2 deletions internal/server/v2/observation/observation.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ func ObservationCore(
// Have both entity.dcids and variable.dcids. Check existence cache.
res, err := Existence(
ctx, store, cachedata, variable.GetDcids(), entity.GetDcids())
return res, shared.QueryTypeExistence, err
return res, shared.QueryTypeExistenceByVar, err
}
// TODO: Support appending entities from entity.expression
// Only have entity.dcids, fetch variables for each entity.
res, err := Variable(ctx, store, entity.GetDcids())

return res, shared.QueryTypeExistence, err
return res, shared.QueryTypeExistenceByEntity, err
}
}
return &pbv2.ObservationResponse{}, "", nil
Expand Down
6 changes: 4 additions & 2 deletions internal/server/v2/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ const (
QueryTypeValue QueryType = "value"
// Fetches information about a given facet.
QueryTypeFacet QueryType = "facet"
// Checks if a given statVar has information for a given entity.
QueryTypeExistence QueryType = "existence"
// Checks if a given statVar has information for a given set of entities AND variables.
QueryTypeExistenceByVar QueryType = "existence-var"
// Checks if a given statVar has ANY statVars for a given set of entities
QueryTypeExistenceByEntity QueryType = "existence-entity"
// Calculates a value from other fetches.
QueryTypeDerived QueryType = "derived"
)
Expand Down