-
Notifications
You must be signed in to change notification settings - Fork 5
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 returning nulls from /data/views/query if no data in BigQuery #177
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -40,8 +40,8 @@ | |||||||||
|
||||||||||
// metric data | ||||||||||
|
||||||||||
ViewCount int64 `json:"viewCount"` | ||||||||||
PlaytimeMins float64 `json:"playtimeMins"` | ||||||||||
ViewCount data.Nullable[int64] `json:"viewCount,omitempty"` | ||||||||||
PlaytimeMins data.Nullable[float64] `json:"playtimeMins,omitempty"` | ||||||||||
TtffMs data.Nullable[float64] `json:"ttffMs,omitempty"` | ||||||||||
RebufferRatio data.Nullable[float64] `json:"rebufferRatio,omitempty"` | ||||||||||
ErrorRate data.Nullable[float64] `json:"errorRate,omitempty"` | ||||||||||
|
@@ -97,7 +97,7 @@ | |||||||||
|
||||||||||
return []TotalViews{{ | ||||||||||
ID: asset.PlaybackID, | ||||||||||
StartViews: startViews, | ||||||||||
StartViews: data.ToNullable[int64](startViews, true, true), | ||||||||||
}}, nil | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -126,9 +126,9 @@ | |||||||||
return &Metric{ | ||||||||||
PlaybackID: toStringPtr(summary.PlaybackID, summary.PlaybackID.Valid), | ||||||||||
DStorageURL: toStringPtr(summary.DStorageURL, summary.DStorageURL.Valid), | ||||||||||
ViewCount: summary.ViewCount, | ||||||||||
ViewCount: toInt64Ptr(summary.ViewCount, summary.ViewCount.Valid), | ||||||||||
LegacyViewCount: data.ToNullable[int64](legacyViewCount, true, true), | ||||||||||
PlaytimeMins: summary.PlaytimeMins, | ||||||||||
PlaytimeMins: toFloat64Ptr(summary.PlaytimeMins, summary.PlaytimeMins.Valid), | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -187,8 +187,8 @@ | |||||||||
Subdivision: toStringPtr(row.Subdivision, spec.hasBreakdownBy("subdivision")), | ||||||||||
TimeZone: toStringPtr(row.TimeZone, spec.hasBreakdownBy("timezone")), | ||||||||||
GeoHash: toStringPtr(row.GeoHash, spec.hasBreakdownBy("geohash")), | ||||||||||
ViewCount: row.ViewCount, | ||||||||||
PlaytimeMins: row.PlaytimeMins, | ||||||||||
ViewCount: toInt64Ptr(row.ViewCount, spec.Detailed), | ||||||||||
PlaytimeMins: toFloat64Ptr(row.PlaytimeMins, spec.Detailed), | ||||||||||
Comment on lines
+190
to
+191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 2 fields are actually not detailed, they belong to the basic viewership metrics and should always be in the response. So they are always "asked".
Suggested change
(otherwise if you call the API without
Comment on lines
+190
to
+191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking further about this, we probably don't want to return |
||||||||||
TtffMs: toFloat64Ptr(row.TtffMs, spec.Detailed), | ||||||||||
RebufferRatio: toFloat64Ptr(row.RebufferRatio, spec.Detailed), | ||||||||||
ErrorRate: toFloat64Ptr(row.ErrorRate, spec.Detailed), | ||||||||||
|
@@ -205,6 +205,10 @@ | |||||||||
return metrics | ||||||||||
} | ||||||||||
|
||||||||||
func toInt64Ptr(bqInt bigquery.NullInt64, asked bool) data.Nullable[int64] { | ||||||||||
return data.ToNullable(bqInt.Int64, bqInt.Valid, asked) | ||||||||||
} | ||||||||||
|
||||||||||
func toFloat64Ptr(bqFloat bigquery.NullFloat64, asked bool) data.Nullable[float64] { | ||||||||||
return data.ToNullable(bqFloat.Float64, bqFloat.Valid, asked) | ||||||||||
} | ||||||||||
|
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.
Any idea how these can ever be null?
Not that I think we shouldn't make this fix, but these are the most basic fields that should always be there, defaulting to
0
, so it kinda looks like a data pipeline problem.