Skip to content

Commit f9fbff3

Browse files
committed
Refactor(web_feature_consumer): Use ProcessedWebFeaturesData for insertion
This commit refactors the InsertWebFeatures function and its call sites to use the ProcessedWebFeaturesData struct instead of a raw map of features. In the future, we will need this information to know which features were moved.
1 parent ece0338 commit f9fbff3

File tree

4 files changed

+925
-475
lines changed

4 files changed

+925
-475
lines changed

lib/gcpspanner/spanneradapters/web_features_consumer.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/GoogleChrome/webstatus.dev/lib/gcpspanner"
2323
"github.com/GoogleChrome/webstatus.dev/lib/gen/jsonschema/web_platform_dx__web_features"
24+
"github.com/GoogleChrome/webstatus.dev/lib/webdxfeaturetypes"
2425
)
2526

2627
// WebFeatureSpannerClient expects a subset of the functionality from lib/gcpspanner that only apply to WebFeatures.
@@ -53,11 +54,11 @@ type WebFeaturesConsumer struct {
5354

5455
func (c *WebFeaturesConsumer) InsertWebFeatures(
5556
ctx context.Context,
56-
data map[string]web_platform_dx__web_features.FeatureValue,
57+
data *webdxfeaturetypes.ProcessedWebFeaturesData,
5758
startAt, endAt time.Time) (map[string]string, error) {
5859
// 1. Prepare all WebFeature structs from the input data.
59-
allFeatures := make([]gcpspanner.WebFeature, 0, len(data))
60-
for featureID, featureData := range data {
60+
allFeatures := make([]gcpspanner.WebFeature, 0, len(data.Features.Data))
61+
for featureID, featureData := range data.Features.Data {
6162
webFeature := gcpspanner.WebFeature{
6263
FeatureKey: featureID,
6364
Name: featureData.Name,
@@ -76,7 +77,7 @@ func (c *WebFeaturesConsumer) InsertWebFeatures(
7677
}
7778

7879
// 3. Loop through the data again to process all related entities for each feature.
79-
for featureID, featureData := range data {
80+
for featureID, featureData := range data.Features.Data {
8081
featureBaselineStatus := gcpspanner.FeatureBaselineStatus{
8182
Status: getBaselineStatusEnum(featureData.Status),
8283
LowDate: nil,

0 commit comments

Comments
 (0)