gcpspanner

package
v0.0.0-...-a690eb5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 24 Imported by: 8

Documentation

Index

Constants

View Source
const LatestDailyChromiumHistogramMetricsTable = "LatestDailyChromiumHistogramMetrics"
View Source
const LatestWPTRunFeatureMetricsTable = "LatestWPTRunFeatureMetrics"
View Source
const WPTRunFeatureMetricTable = "WPTRunFeatureMetrics"

Variables

View Source
var (
	// ErrUsageMetricUpsertNoFeatureIDFound indicates that no web feature ID was found
	// when attempting to upsert a usage metric using the chromiumHistogramEnumValueID.
	// This typically occurs when there is no corresponding web feature associated with
	// the given chromiumHistogramEnumValueID.
	ErrUsageMetricUpsertNoFeatureIDFound = errors.New("no web feature id found when upserting usage metric")

	// ErrUsageMetricUpsertNoHistogramFound indicates that the chromium histogram metric
	// was not found when attempting to upsert a usage metric.
	ErrUsageMetricUpsertNoHistogramFound = errors.New("histogram not found when upserting usage metric")

	// ErrUsageMetricUpsertNoHistogramEnumFound indicates that the chromium histogram enum
	// was not found when attempting to upsert a usage metric. This typically occurs when
	// the histogram name associated with the metric is not found, possibly due to
	// a draft or obsolete feature for which the corresponding enum ID has not been created.
	ErrUsageMetricUpsertNoHistogramEnumFound = errors.New("histogram enum not found when upserting usage metric")
)

DailyChromiumHistogramMetrics specific errors.

View Source
var ErrBadClientConfig = errors.New("projectID, instanceID and name must not be empty")

ErrBadClientConfig indicates the the config to setup a Client is invalid.

View Source
var ErrFailedToEstablishClient = errors.New("failed to establish spanner client")

ErrFailedToEstablishClient indicates the spanner client failed to create.

View Source
var ErrInternalQueryFailure = errors.New("internal spanner query failure")

ErrInternalQueryFailure is a catch-all error for now.

View Source
var ErrInvalidCursorFormat = errors.New("invalid cursor format")

ErrInvalidCursorFormat indicates the cursor is not the correct format.

View Source
var ErrMissingRequiredRole = errors.New("user is missing required role")

ErrMissingRequiredRole indicates that the user is missing the required role for the transaction.

View Source
var (
	// ErrOwnerSavedSearchLimitExceeded indicates that the user already has
	// reached the limit of saved searches that a given user can own.
	ErrOwnerSavedSearchLimitExceeded = errors.New("saved search limit reached")
)
View Source
var ErrQueryReturnedNoResults = errors.New("query returned no results")

ErrQueryReturnedNoResults indicates no results were returned.

Functions

This section is empty.

Types

type BaseQueryTemplate

type BaseQueryTemplate struct {
	// contains filtered or unexported fields
}

func NewQueryTemplate

func NewQueryTemplate(in string) BaseQueryTemplate

func (*BaseQueryTemplate) Execute

func (t *BaseQueryTemplate) Execute(data any) string

TODO: Pass in context to be used by slog.ErrorContext.

type BaselineStatus

type BaselineStatus string

Options come from https://github.com/web-platform-dx/web-features/blob/3d4d066c47c9f07514bf743b3955572a6073ff1e/packages/web-features/README.md nolint: lll

const (
	BaselineStatusNone BaselineStatus = "none"
	BaselineStatusLow  BaselineStatus = "low"
	BaselineStatusHigh BaselineStatus = "high"
)

type BrowserFeatureAvailability

type BrowserFeatureAvailability struct {
	BrowserName    string
	BrowserVersion string
}

BrowserFeatureAvailability contains availability information for a particular feature in a browser.

type BrowserFeatureCountCursor

type BrowserFeatureCountCursor struct {
	LastReleaseDate     time.Time `json:"last_release_date"`
	LastCumulativeCount int64     `json:"last_cumulative_count"`
}

BrowserFeatureCountCursor: Represents a point for resuming feature count queries. Designed for efficient pagination by storing the following:

  • LastReleaseDate: The release date of the last result from the previous page, used to continue fetching from the correct point.
  • LastCumulativeCount: The cumulative count of features up to (and including) the 'LastReleaseDate'. This eliminates the need to recalculate the count for prior pages.

type BrowserFeatureCountMetric

type BrowserFeatureCountMetric struct {
	ReleaseDate  time.Time `spanner:"ReleaseDate"`
	FeatureCount int64     `spanner:"FeatureCount"`
}

BrowserFeatureCountMetric contains a row of data returned by the feature count query.

type BrowserFeatureCountResultPage

type BrowserFeatureCountResultPage struct {
	NextPageToken *string
	Metrics       []BrowserFeatureCountMetric
}

type BrowserFeatureSupportEvent

type BrowserFeatureSupportEvent struct {
	TargetBrowserName string                      `spanner:"TargetBrowserName"`
	EventBrowserName  string                      `spanner:"EventBrowserName"`
	EventReleaseDate  time.Time                   `spanner:"EventReleaseDate"`
	WebFeatureID      string                      `spanner:"WebFeatureID"`
	SupportStatus     BrowserFeatureSupportStatus `spanner:"SupportStatus"`
}

type BrowserFeatureSupportStatus

type BrowserFeatureSupportStatus string
const (
	UnsupportedFeatureSupport BrowserFeatureSupportStatus = "unsupported"
	SupportedFeatureSupport   BrowserFeatureSupportStatus = "supported"
)

type BrowserImplementationStatus

type BrowserImplementationStatus string

BrowserImplementationStatus is an enumeration of the possible implementation states for a feature in a browser.

const (
	Available   BrowserImplementationStatus = "available"
	Unavailable BrowserImplementationStatus = "unavailable"
)

type BrowserRelease

type BrowserRelease struct {
	BrowserName    string    `spanner:"BrowserName"`
	BrowserVersion string    `spanner:"BrowserVersion"`
	ReleaseDate    time.Time `spanner:"ReleaseDate"`
}

BrowserRelease contains information regarding a certain browser release.

type ChromiumDailyUsageCursor

type ChromiumDailyUsageCursor struct {
	LastDate civil.Date `json:"last_date"`
}

type ChromiumDailyUsageStatWithDate

type ChromiumDailyUsageStatWithDate struct {
	Date  civil.Date `spanner:"Date"`
	Usage *big.Rat   `spanner:"Usage"`
}

ChromiumDailyUsageStatsWithDate contains usage stats for a feature at a given date.

type ChromiumDailyUsageTemplateData

type ChromiumDailyUsageTemplateData struct {
	PageFilter string
}

ChromiumDailyUsageTemplateData contains the variables for getChromiumDailyUsageBaseRawTemplate.

type ChromiumHistogramEnum

type ChromiumHistogramEnum struct {
	HistogramName string `spanner:"HistogramName"`
}

type ChromiumHistogramEnumValue

type ChromiumHistogramEnumValue struct {
	ChromiumHistogramEnumID string `spanner:"ChromiumHistogramEnumID"`
	BucketID                int64  `spanner:"BucketID"`
	Label                   string `spanner:"Label"`
}

type Client

type Client struct {
	*spanner.Client
	// contains filtered or unexported fields
}

Client is the client for interacting with GCP Spanner.

func NewSpannerClient

func NewSpannerClient(projectID string, instanceID string, name string) (*Client, error)

NewSpannerClient returns a Client for the Google Spanner service.

func (*Client) AddUserSearchBookmark

func (c *Client) AddUserSearchBookmark(ctx context.Context, req UserSavedSearchBookmark) error

func (*Client) CreateNewUserSavedSearch

func (c *Client) CreateNewUserSavedSearch(
	ctx context.Context,
	newSearch CreateUserSavedSearchRequest) (*string, error)

CreateNewUserSavedSearch creates a new user-owned saved search. It returns the ID of the newly created saved search if successful.

func (*Client) CreateSpannerWPTRunFeatureMetric

func (c *Client) CreateSpannerWPTRunFeatureMetric(
	webFeatureID string,
	wptRunData WPTRunDataForMetrics,
	in WPTRunFeatureMetric) SpannerWPTRunFeatureMetric

func (*Client) DeleteUserSearchBookmark

func (c *Client) DeleteUserSearchBookmark(ctx context.Context, req UserSavedSearchBookmark) error

func (*Client) FeaturesSearch

func (c *Client) FeaturesSearch(
	ctx context.Context,
	pageToken *string,
	pageSize int,
	searchNode *searchtypes.SearchNode,
	sortOrder Sortable,
	wptMetricView WPTMetricView,
	browsers []string,
) (*FeatureResultPage, error)

func (*Client) GetFeature

func (c *Client) GetFeature(
	ctx context.Context,
	filter Filterable,
	wptMetricView WPTMetricView,
	browsers []string,
) (*FeatureResult, error)

func (*Client) GetGroupIDFromGroupKey

func (c *Client) GetGroupIDFromGroupKey(ctx context.Context, groupKey string) (*string, error)

func (*Client) GetIDFromChromiumHistogramEnumValueKey

func (c *Client) GetIDFromChromiumHistogramEnumValueKey(
	ctx context.Context, chromiumHistogramEnumID string, bucketID int64) (*string, error)

func (*Client) GetIDFromChromiumHistogramKey

func (c *Client) GetIDFromChromiumHistogramKey(
	ctx context.Context, histogramName string) (*string, error)

func (*Client) GetIDFromFeatureKey

func (c *Client) GetIDFromFeatureKey(ctx context.Context, filter *FeatureIDFilter) (*string, error)

func (*Client) GetSnapshotIDFromSnapshotKey

func (c *Client) GetSnapshotIDFromSnapshotKey(ctx context.Context, snapshotKey string) (*string, error)

func (*Client) GetUserSavedSearch

func (c *Client) GetUserSavedSearch(
	ctx context.Context,
	savedSearchID string,
	authenticatedUserID *string) (*UserSavedSearch, error)

func (*Client) GetWPTRunDataByRunIDForMetrics

func (c *Client) GetWPTRunDataByRunIDForMetrics(ctx context.Context, runID int64) (*WPTRunDataForMetrics, error)

GetWPTRunDataByRunIDForMetrics is a helper function to help get a subsection of the WPT Run information. This information will be used to create the WPT Run metrics.

func (*Client) HasDailyChromiumHistogramCapstone

func (c *Client) HasDailyChromiumHistogramCapstone(
	ctx context.Context, in DailyChromiumHistogramEnumCapstone) (*bool, error)

func (*Client) InsertBrowserFeatureAvailability

func (c *Client) InsertBrowserFeatureAvailability(
	ctx context.Context,
	webFeatureID string,
	input BrowserFeatureAvailability) error

InsertBrowserFeatureAvailability will insert the given browser feature availability.

func (*Client) InsertBrowserRelease

func (c *Client) InsertBrowserRelease(ctx context.Context, release BrowserRelease) error

InsertBrowserRelease will insert the given browser release.

func (*Client) InsertWPTRun

func (c *Client) InsertWPTRun(ctx context.Context, run WPTRun) error

InsertWPTRun will insert the given WPT Run.

func (*Client) ListBrowserFeatureCountMetric

func (c *Client) ListBrowserFeatureCountMetric(
	ctx context.Context,
	browser string,
	startAt time.Time,
	endAt time.Time,
	pageSize int,
	pageToken *string,
) (*BrowserFeatureCountResultPage, error)

func (*Client) ListChromiumDailyUsageStatsForFeatureID

func (c *Client) ListChromiumDailyUsageStatsForFeatureID(
	ctx context.Context,
	featureKey string,
	startAt time.Time,
	endAt time.Time,
	pageSize int,
	pageToken *string,
) ([]ChromiumDailyUsageStatWithDate, *string, error)

nolint: revive

func (*Client) ListMetricsForFeatureIDBrowserAndChannel

func (c *Client) ListMetricsForFeatureIDBrowserAndChannel(
	ctx context.Context,
	featureKey string,
	browser string,
	channel string,
	metric WPTMetricView,
	startAt time.Time,
	endAt time.Time,
	pageSize int,
	pageToken *string,
) ([]WPTRunFeatureMetricWithTime, *string, error)

ListMetricsForFeatureIDBrowserAndChannel attempts to return a page of metrics based on a web feature key, browser name and channel. A time window must be specified to analyze the runs according to the TimeStart of the run. If the page size matches the pageSize, a page token is returned. Else, no page token is returned.

func (*Client) ListMetricsOverTimeWithAggregatedTotals

func (c *Client) ListMetricsOverTimeWithAggregatedTotals(
	ctx context.Context,
	featureKeys []string,
	browser string,
	channel string,
	metric WPTMetricView,
	startAt, endAt time.Time,
	pageSize int,
	pageToken *string,
) ([]WPTRunAggregationMetricWithTime, *string, error)

ListMetricsOverTimeWithAggregatedTotals attempts to return a page of metrics based on browser name and channel. Users can provide a list of web feature keys. If the list is provided, the aggregation will be scoped to those feature keys. If an empty or nil list is provided, the aggregation is applied to all features. A time window must be specified to analyze the runs according to the TimeStart of the run. If the page size matches the pageSize, a page token is returned. Else, no page token is returned.

func (*Client) ListMissingOneImplCounts

func (c *Client) ListMissingOneImplCounts(
	ctx context.Context,
	targetBrowser string,
	otherBrowsers []string,
	startAt time.Time,
	endAt time.Time,
	pageSize int,
	pageToken *string,
) (*MissingOneImplCountPage, error)

func (*Client) PrecalculateBrowserFeatureSupportEvents

func (c *Client) PrecalculateBrowserFeatureSupportEvents(ctx context.Context, startAt, endAt time.Time) error

PrecalculateBrowserFeatureSupportEvents populates the BrowserFeatureSupportEvents table with pre-calculated data.

func (*Client) SetFeatureSearchBaseQuery

func (c *Client) SetFeatureSearchBaseQuery(query FeatureSearchBaseQuery)

func (*Client) SetMisingOneImplementationQuery

func (c *Client) SetMisingOneImplementationQuery(query MissingOneImplementationQuery)

func (*Client) UpdateUserSavedSearch

func (c *Client) UpdateUserSavedSearch(ctx context.Context, req UpdateSavedSearchRequest) error

func (*Client) UpsertChromiumHistogramEnum

func (c *Client) UpsertChromiumHistogramEnum(ctx context.Context, in ChromiumHistogramEnum) (*string, error)

func (*Client) UpsertChromiumHistogramEnumValue

func (c *Client) UpsertChromiumHistogramEnumValue(ctx context.Context, in ChromiumHistogramEnumValue) (*string, error)

func (*Client) UpsertDailyChromiumHistogramCapstone

func (c *Client) UpsertDailyChromiumHistogramCapstone(
	ctx context.Context, in DailyChromiumHistogramEnumCapstone) error

func (*Client) UpsertDailyChromiumHistogramMetric

func (c *Client) UpsertDailyChromiumHistogramMetric(
	ctx context.Context,
	histogramName metricdatatypes.HistogramName,
	bucketID int64,
	metric DailyChromiumHistogramMetric) error

UpsertDailyChromiumHistogramMetric upserts a daily chromium histogram metric.

Errors:

  • ErrQueryReturnedNoResults: If the histogram key or value ID is not found.
  • ErrInternalQueryFailure: If any internal query fails during the process.
  • ErrUsageMetricUpsertNoFeatureIDFound: If no feature ID is found while attempting to upsert the latest daily chromium usage metric.
  • ErrUsageMetricUpsertNoHistogramFound: If the histogram is not found
  • ErrUsageMetricUpsertNoHistogramEnumFound: If a particular enum in the histogram is not found.

func (*Client) UpsertFeatureBaselineStatus

func (c *Client) UpsertFeatureBaselineStatus(ctx context.Context,
	featureKey string, input FeatureBaselineStatus) error

UpsertWebFeature will update the given baseline status. If the status, does not exist, it will insert a new status. If the status exists, it will allow updates to the status, low date and high date.

func (*Client) UpsertFeatureSpec

func (c *Client) UpsertFeatureSpec(
	ctx context.Context,
	webFeatureID string,
	input FeatureSpec) error

InsertFeatureSpec will insert the given feature spec information. If the spec info, does not exist, it will insert a new spec info. If the spec info exists, it currently overwrites the data.

func (*Client) UpsertGroup

func (c *Client) UpsertGroup(ctx context.Context, group Group) (*string, error)

func (*Client) UpsertGroupDescendantInfo

func (c *Client) UpsertGroupDescendantInfo(
	ctx context.Context, groupKey string, descendantInfo GroupDescendantInfo) error

func (*Client) UpsertSnapshot

func (c *Client) UpsertSnapshot(ctx context.Context, snapshot Snapshot) (*string, error)

func (*Client) UpsertWPTRunFeatureMetrics

func (c *Client) UpsertWPTRunFeatureMetrics(
	ctx context.Context,
	externalRunID int64,
	inputMetrics map[string]WPTRunFeatureMetric) error

UpsertWPTRunFeatureMetrics will upsert WPT Run metrics for a given WPT Run ID. The RunID must exist in a row in the WPTRuns table.

func (*Client) UpsertWebFeature

func (c *Client) UpsertWebFeature(ctx context.Context, feature WebFeature) (*string, error)

func (*Client) UpsertWebFeatureChromiumHistogramEnumValue

func (c *Client) UpsertWebFeatureChromiumHistogramEnumValue(
	ctx context.Context, in WebFeatureChromiumHistogramEnumValue) error

func (*Client) UpsertWebFeatureGroup

func (c *Client) UpsertWebFeatureGroup(ctx context.Context, group WebFeatureGroup) error

func (*Client) UpsertWebFeatureSnapshot

func (c *Client) UpsertWebFeatureSnapshot(ctx context.Context, snapshot WebFeatureSnapshot) error

type CommonFSCountTemplateData

type CommonFSCountTemplateData struct {
	BaseQueryFragment string
	Filters           []string
}

CommonFSCountTemplateData contains the template for commonCountQueryTemplate.

type CommonFSSelectTemplateData

type CommonFSSelectTemplateData struct {
	BaseQueryFragment    string
	StableMetrics        string
	ExperimentalMetrics  string
	ImplementationStatus string
	PageFilters          []string
	Filters              []string
	SortClause           string
	Offset               int
	PageSize             int
	OptionalJoins        []JoinData
}

type CreateUserSavedSearchRequest

type CreateUserSavedSearchRequest struct {
	Name        string
	Query       string
	OwnerUserID string
	Description *string
}

CreateUserSavedSearchRequest is the request to create a new user saved search.

type DailyChromiumHistogramEnumCapstone

type DailyChromiumHistogramEnumCapstone struct {
	Day           civil.Date
	HistogramName metricdatatypes.HistogramName
}

type DailyChromiumHistogramMetric

type DailyChromiumHistogramMetric struct {
	Day  civil.Date `spanner:"Day"`
	Rate big.Rat    `spanner:"Rate"`
}

type FeatureBaselineStatus

type FeatureBaselineStatus struct {
	Status   *BaselineStatus `spanner:"-"` // Spanner can not handle pointer to custom type. So ignore it.
	LowDate  *time.Time      `spanner:"LowDate"`
	HighDate *time.Time      `spanner:"HighDate"`
}

FeatureBaselineStatus contains information about the current baseline status of a feature.

type FeatureIDFilter

type FeatureIDFilter struct {
	// contains filtered or unexported fields
}

FeatureIDFilter will limit the search to a particular feature ID.

func NewFeatureKeyFilter

func NewFeatureKeyFilter(featureKey string) *FeatureIDFilter

func (FeatureIDFilter) Clause

func (f FeatureIDFilter) Clause() string

func (FeatureIDFilter) Params

func (f FeatureIDFilter) Params() map[string]interface{}

type FeatureMetricsTemplateData

type FeatureMetricsTemplateData struct {
	TotalColumn      string
	PassColumn       string
	PageFilter       string
	FeatureKeyFilter string
	ExtraFilter      string
	IsSingleFeature  bool
}

FeatureMetricsTemplateData contains the variables for getFeatureMetricBaseRawTemplate.

type FeatureResult

type FeatureResult struct {
	FeatureKey             string                  `spanner:"FeatureKey"`
	Name                   string                  `spanner:"Name"`
	Status                 *string                 `spanner:"Status"`
	StableMetrics          []*FeatureResultMetric  `spanner:"StableMetrics"`
	ExperimentalMetrics    []*FeatureResultMetric  `spanner:"ExperimentalMetrics"`
	ImplementationStatuses []*ImplementationStatus `spanner:"ImplementationStatuses"`
	LowDate                *time.Time              `spanner:"LowDate"`
	HighDate               *time.Time              `spanner:"HighDate"`
	SpecLinks              []string                `spanner:"SpecLinks"`
	ChromiumUsage          *big.Rat                `spanner:"ChromiumUsage"`
}

FeatureResult contains information regarding a particular feature.

type FeatureResultMetric

type FeatureResultMetric struct {
	BrowserName       string                 `spanner:"BrowserName"`
	PassRate          *big.Rat               `spanner:"PassRate"`
	FeatureRunDetails map[string]interface{} `spanner:"-"`
}

FeatureResultMetric contains metric information for a feature result query. Very similar to WPTRunFeatureMetric.

type FeatureResultOffsetCursor

type FeatureResultOffsetCursor struct {
	Offset int `json:"offset"`
}

FeatureResultOffsetCursor: A numerical offset from the start of the result set. Enables the construction of human-friendly URLs specifying an exact page offset. Disclaimer: External users should be aware that the format of this token is subject to change and should not be treated as a stable interface. Instead, external users should rely on the returned pagination token long term.

type FeatureResultPage

type FeatureResultPage struct {
	Total         int64
	NextPageToken *string
	Features      []FeatureResult
}

FeatureResultPage contains the details for the feature search request.

type FeatureSearchBaseQuery

type FeatureSearchBaseQuery interface {
	// Query generates a query to return rows about the features in the system.
	// Each row includes:
	//  1. The Internal ID of the feature
	//  2. The external ID from web features repo
	//  3. The human readable name.
	//  4. The baseline status.
	//  5. The latest metrics from WPT.
	//     It provides these metrics for both "stable" and "experimental" channels.
	//     The metrics retrieved are for each unique BrowserName/Channel/WebFeatureID.
	Query(args FeatureSearchQueryArgs) (string, map[string]interface{})

	// CountQuery generates the base query to return only the count of items.
	CountQuery(args FeatureSearchCountArgs) string
}

FeatureSearchBaseQuery contains the base query for all feature search related queries.

type FeatureSearchColumn

type FeatureSearchColumn string

FeatureSearchColumn is the high level column returned in the FeatureSearch Query from spanner.

func (FeatureSearchColumn) ToFilterColumn

func (f FeatureSearchColumn) ToFilterColumn() string

type FeatureSearchCompiledFilter

type FeatureSearchCompiledFilter struct {
	// contains filtered or unexported fields
}

func (FeatureSearchCompiledFilter) Filters

func (f FeatureSearchCompiledFilter) Filters() []string

func (FeatureSearchCompiledFilter) Params

func (f FeatureSearchCompiledFilter) Params() map[string]interface{}

type FeatureSearchCountArgs

type FeatureSearchCountArgs struct {
	Filters []string
}

type FeatureSearchFilterBuilder

type FeatureSearchFilterBuilder struct {
	// contains filtered or unexported fields
}

func NewFeatureSearchFilterBuilder

func NewFeatureSearchFilterBuilder() *FeatureSearchFilterBuilder

func (*FeatureSearchFilterBuilder) Build

Build constructs a Spanner query for the FeaturesSearch function.

type FeatureSearchQueryArgs

type FeatureSearchQueryArgs struct {
	MetricView              WPTMetricView
	Filters                 []string
	PageFilters             []string
	PageSize                int
	Offset                  int
	SortClause              string
	SortByStableBrowserImpl *SortByBrowserImplDetails
	SortByExpBrowserImpl    *SortByBrowserImplDetails
	Browsers                []string
}

type FeatureSearchQueryBuilder

type FeatureSearchQueryBuilder struct {
	// contains filtered or unexported fields
}

FeatureSearchQueryBuilder builds a query to search for features.

func (FeatureSearchQueryBuilder) Build

func (FeatureSearchQueryBuilder) CountQueryBuild

type FeatureSpec

type FeatureSpec struct {
	Links []string
}

FeatureSpec contains availability information for a particular feature in a browser.

type FeaturesSearchSortTarget

type FeaturesSearchSortTarget string

FeaturesSearchSortTarget is an enumeration of the data that is being targeted for the sort operation. This is used to know which column(s) to encode and decode in the pagination token.

const (
	IDSort               FeaturesSearchSortTarget = "id"
	NameSort             FeaturesSearchSortTarget = "name"
	StatusSort           FeaturesSearchSortTarget = "status"
	StableImplSort       FeaturesSearchSortTarget = "stable_browser_impl"
	ExperimentalImplSort FeaturesSearchSortTarget = "experimental_browser_impl"
	ChromiumUsageSort    FeaturesSearchSortTarget = "chromium_usage"
)

type Filterable

type Filterable interface {
	Params() map[string]interface{}
	Clause() string
}

Filterable modifies a query with a given filter.

type GCPFSBrowserImplStatusTemplateData

type GCPFSBrowserImplStatusTemplateData struct {
	BrowserNameParam string
}

GCPFSBrowserImplStatusTemplateData contains the template data for gcpFSBrowserImplementationStatusTemplate.

type GCPFSBrowserMetricTemplateData

type GCPFSBrowserMetricTemplateData struct {
	BrowserNameParam string
	GCPFSMetricsTemplateData
}

GCPFSBrowserMetricTemplateData contains the template data for gcpFSPassRateForBrowserTemplate.

type GCPFSCountTemplateData

type GCPFSCountTemplateData struct {
	CommonFSCountTemplateData
}

GCPFSCountTemplateData contains the template for gcpFSCountQueryTemplate.

type GCPFSMetricsTemplateData

type GCPFSMetricsTemplateData struct {
	Channel        string
	BrowserList    []string
	PassRateColumn string
	ChannelParam   string
	MetricIndex    string
}

GCPFSMetricsTemplateData contains the template data for gcpFSMetricsSubQueryTemplate.

type GCPFSSelectTemplateData

type GCPFSSelectTemplateData struct {
	CommonFSSelectTemplateData
}

GCPFSSelectTemplateData contains the template data for gcpFSSelectQueryTemplate.

type GCPFeatureSearchBaseQuery

type GCPFeatureSearchBaseQuery struct{}

GCPFeatureSearchBaseQuery provides a base query that is optimal for GCP Spanner to retrieve the information described in the FeatureBaseQuery interface.

func (GCPFeatureSearchBaseQuery) CountQuery

func (GCPFeatureSearchBaseQuery) Query

func (f GCPFeatureSearchBaseQuery) Query(args FeatureSearchQueryArgs) (
	string, map[string]interface{})

Query uses the latest browsername/channel/timestart mapping to build a query.

type GCPMissingOneImplementationQuery

type GCPMissingOneImplementationQuery struct{}

GCPMissingOneImplementationQuery provides a base query that is optimal for GCP Spanner to retrieve the information described in the MissingOneImplementationQuery interface.

func (GCPMissingOneImplementationQuery) Query

func (q GCPMissingOneImplementationQuery) Query(data missingOneImplTemplateData) string

type GetFeatureQueryBuilder

type GetFeatureQueryBuilder struct {
	// contains filtered or unexported fields
}

GetFeatureQueryBuilder builds a query to search for one feature.

func (GetFeatureQueryBuilder) Build

type Group

type Group struct {
	GroupKey string `spanner:"GroupKey"`
	Name     string `spanner:"Name"`
}

Group contains common metadata for a group from the WebDX web-feature repository. Columns come from the ../../infra/storage/spanner/migrations/*.sql files.

type GroupDescendantInfo

type GroupDescendantInfo struct {
	DescendantGroupIDs []string `spanner:"DescendantGroupIDs"`
}

type ImplementationStatus

type ImplementationStatus struct {
	BrowserName           string                      `spanner:"BrowserName"`
	ImplementationStatus  BrowserImplementationStatus `spanner:"ImplementationStatus"`
	ImplementationDate    *time.Time                  `spanner:"ImplementationDate"`
	ImplementationVersion *string                     `spanner:"ImplementationVersion"`
}

ImplementationStatus contains the implementation status information for a given browser.

type JoinData

type JoinData struct {
	Alias    string
	Template string
}

JoinData contains template data for the optional joins.

type LatestRunResult

type LatestRunResult struct {
	Channel     string    `spanner:"Channel"`
	BrowserName string    `spanner:"BrowserName"`
	TimeStart   time.Time `spanner:"TimeStart"`
}

LatestRunResult contains the information for when a given BrowserName & Channel combination last ran.

type LatestRunResultsGroupedByChannel

type LatestRunResultsGroupedByChannel map[string][]LatestRunResult

LatestRunResultsGroupedByChannel is a mapping of channel to list LatestRunResult. Useful for building the filter per channel in the Query method of GCPFeatureSearchBaseQuery.

type LocalBatchWriter

type LocalBatchWriter struct{}

LocalBatchWriter is a batch writer for local environments using the emulator. BatchWrite is not implemented in the emulator. https://github.com/GoogleCloudPlatform/cloud-spanner-emulator/issues/154 Instead, do Apply which does multiple statements atomically. Remove this once the emulator supports BatchWrite. This is only exported for the load_fake_data utility.

func (LocalBatchWriter) BatchWriteMutations

func (w LocalBatchWriter) BatchWriteMutations(
	ctx context.Context, client *spanner.Client, mutations []*spanner.Mutation) error

type LocalFSBrowserImplStatusTemplateData

type LocalFSBrowserImplStatusTemplateData struct {
	BrowserNameParam string
}

LocalFSBrowserImplStatusTemplateData contains the template data for localFSBrowserImplementationStatusTemplate.

type LocalFSBrowserMetricTemplateData

type LocalFSBrowserMetricTemplateData struct {
	BrowserNameParam string
	LocalFSMetricsTemplateData
}

LocalFSBrowserMetricTemplateData contains the template data for localFSPassRateForBrowserTemplate.

type LocalFSCountTemplateData

type LocalFSCountTemplateData struct {
	CommonFSCountTemplateData
}

LocalFSCountTemplateData contains the template for localFSCountQueryTemplate.

type LocalFSMetricsTemplateData

type LocalFSMetricsTemplateData struct {
	Channel        string
	PassRateColumn string
	ChannelParam   string
}

LocalFSMetricsTemplateData contains the template for localFSMetricsSubQueryTemplate.

type LocalFSSelectTemplateData

type LocalFSSelectTemplateData struct {
	CommonFSSelectTemplateData
	PassRateColumn string
}

LocalFSSelectTemplateData contains the template data for localFSSelectQueryTemplate.

type LocalFeatureBaseQuery

type LocalFeatureBaseQuery struct{}

LocalFeatureBaseQuery is a version of the base query that works well on the local emulator. For some reason, the local emulator takes forever for the GCPFeatureSearchBaseQuery as the number of features and metrics grows. But GCPFeatureSearchBaseQuery works extremely well on GCP. At least 1.5-2x faster than LocalFeatureBaseQuery with 2400 metrics as of March 2024. Rather han sacrifice performance for the sake of compatibility, we have this LocalFeatureBaseQuery implementation which is good for the volume of data locally. TODO. Consolidate to using either LocalFeatureBaseQuery to reduce the maintenance burden.

func (LocalFeatureBaseQuery) CountQuery

func (LocalFeatureBaseQuery) Query

func (f LocalFeatureBaseQuery) Query(args FeatureSearchQueryArgs) (
	string, map[string]interface{})

Query is a version of the base query that works on the local emulator. It leverages a common table expression CTE to help query the metrics.

type LocalMissingOneImplementationQuery

type LocalMissingOneImplementationQuery struct{}

LocalMissingOneImplementationQuery is a version of the base query that works well on the local emulator. For some reason, the local emulator takes at least 1 minute with the fake data when using the GCPMissingOneImplementationQuery. Rather than sacrifice performance for the sake of compatibility, we have this LocalMissingOneImplementationQuery implementation which is good for the volume of data locally. TODO. Consolidate to using either LocalMissingOneImplementationQuery or GCPMissingOneImplementationQuery to reduce the maintenance burden.

func (LocalMissingOneImplementationQuery) Query

func (q LocalMissingOneImplementationQuery) Query(data missingOneImplTemplateData) string

type MissingOneImplCount

type MissingOneImplCount struct {
	EventReleaseDate time.Time `spanner:"EventReleaseDate"`
	Count            int64     `spanner:"Count"`
}

MissingOneImplCount contains information regarding the count of features implemented in all other browsers but not in the target browser.

type MissingOneImplCountPage

type MissingOneImplCountPage struct {
	NextPageToken *string
	Metrics       []MissingOneImplCount
}

MissingOneImplCountPage contains the details for the missing one implementation count request.

type MissingOneImplementationQuery

type MissingOneImplementationQuery interface {
	Query(missingOneImplTemplateData) string
}

MissingOneImplementationQuery contains the base query for all missing one implementation related queries.

type OptionallySet

type OptionallySet[T any] struct {
	Value T
	IsSet bool
}

OptionallySet allows distinguishing between setting a value and leaving it unchanged. Useful for PATCH operations where only specific fields are updated.

type SavedSearch

type SavedSearch struct {
	ID          string           `spanner:"ID"`
	Name        string           `spanner:"Name"`
	Description *string          `spanner:"Description"`
	Query       string           `spanner:"Query"`
	Scope       SavedSearchScope `spanner:"Scope"`
	AuthorID    string           `spanner:"AuthorID"`
	CreatedAt   time.Time        `spanner:"CreatedAt"`
	UpdatedAt   time.Time        `spanner:"UpdatedAt"`
}

SavedSearch represents a saved search row in the SavedSearches table.

type SavedSearchRole

type SavedSearchRole string

SavedSearchRole is the enum for the saved searches role.

const (
	// SavedSearchOwner indicates the user owns the saved search query.
	SavedSearchOwner SavedSearchRole = "OWNER"
)

type SavedSearchScope

type SavedSearchScope string

SavedSearchScope represents the scope of a saved search.

const (
	// UserPublicScope indicates that this is user created saved search meant to be publicly accessible.
	UserPublicScope SavedSearchScope = "USER_PUBLIC"
)

type SavedSearchUserRole

type SavedSearchUserRole struct {
	SavedSearchID string          `spanner:"SavedSearchID"`
	UserID        string          `spanner:"UserID"`
	UserRole      SavedSearchRole `spanner:"UserRole"`
}

SavedSearchUserRole represents a user's role in relation to a saved search.

type Snapshot

type Snapshot struct {
	SnapshotKey string `spanner:"SnapshotKey"`
	Name        string `spanner:"Name"`
}

Snapshot contains common metadata for a snapshot from the WebDX web-feature repository. Columns come from the ../../infra/storage/spanner/migrations/*.sql files.

type SortByBrowserImplDetails

type SortByBrowserImplDetails struct {
	BrowserName string
}

SortByBrowserImplDetails contains parameter data for the Implementation Status templates.

type Sortable

type Sortable struct {
	// contains filtered or unexported fields
}

Sortable is a basic class that all/most sortables can include.

func NewBaselineStatusSort

func NewBaselineStatusSort(isAscending bool) Sortable

NewBaselineStatusSort returns a Sortable specifically for the Status column.

func NewBrowserImplSort

func NewBrowserImplSort(isAscending bool, browserName string, isStable bool) Sortable

NewBrowserImplSort creates a Sortable configuration for ordering Web Features. The primary sorting criterion is the pass rate of stable or experimental WPT (Web Platform Tests) metrics for the specified browser. The secondary sorting criterion is the implementation status ("available" or "unavailable") of the feature in the specified browser.

Arguments:

  • isAscending: Whether the sorting should be ascending (true) or descending (false).
  • browserName: The name of the browser ("chrome", "firefox", etc.).
  • isStable: Whether to use stable (true) or experimental (false) WPT metrics.

func NewChromiumUsageSort

func NewChromiumUsageSort(isAscending bool) Sortable

NewChromiumUsageSort returns a Sortable specifically for the ChromiumUsage column.

func NewFeatureNameSort

func NewFeatureNameSort(isAscending bool) Sortable

NewFeatureNameSort returns a Sortable specifically for the Name column.

func (Sortable) BrowserTarget

func (s Sortable) BrowserTarget() string

func (Sortable) Clause

func (s Sortable) Clause() string

func (Sortable) SortTarget

func (s Sortable) SortTarget() FeaturesSearchSortTarget

type SpannerFeatureResult

type SpannerFeatureResult struct {
	ID                     string                        `spanner:"ID"`
	FeatureKey             string                        `spanner:"FeatureKey"`
	Name                   string                        `spanner:"Name"`
	Status                 *string                       `spanner:"Status"`
	StableMetrics          []*SpannerFeatureResultMetric `spanner:"StableMetrics"`
	ExperimentalMetrics    []*SpannerFeatureResultMetric `spanner:"ExperimentalMetrics"`
	ImplementationStatuses []*ImplementationStatus       `spanner:"ImplementationStatuses"`
	LowDate                *time.Time                    `spanner:"LowDate"`
	HighDate               *time.Time                    `spanner:"HighDate"`
	SpecLinks              []string                      `spanner:"SpecLinks"`
	ChromiumUsage          *big.Rat                      `spanner:"ChromiumUsage"`
}

SpannerFeatureResult is a wrapper for the feature result that is actually stored in spanner. This is useful because the spanner id is not useful to return to the end user.

type SpannerFeatureResultMetric

type SpannerFeatureResultMetric struct {
	BrowserName       string           `spanner:"BrowserName"`
	PassRate          *big.Rat         `spanner:"PassRate"`
	FeatureRunDetails spanner.NullJSON `spanner:"FeatureRunDetails"`
}

type SpannerFeatureSpec

type SpannerFeatureSpec struct {
	WebFeatureID string
	FeatureSpec
}

SpannerFeatureSpec is a wrapper for the feature spec information for a feature stored in spanner.

type SpannerLatestDailyChromiumHistogramMetric

type SpannerLatestDailyChromiumHistogramMetric struct {
	WebFeatureID                 string     `spanner:"WebFeatureID"`
	ChromiumHistogramEnumValueID string     `spanner:"ChromiumHistogramEnumValueID"`
	Day                          civil.Date `spanner:"Day"`
}

type SpannerLatestWPTRunFeatureMetric

type SpannerLatestWPTRunFeatureMetric struct {
	RunMetricID  string `spanner:"RunMetricID"`
	WebFeatureID string `spanner:"WebFeatureID"`
	BrowserName  string `spanner:"BrowserName"`
	Channel      string `spanner:"Channel"`
}

SpannerLatestWPTRunFeatureMetric represents a pointer to an entry in WPTRunFeatureMetrics.

type SpannerWPTRunFeatureMetric

type SpannerWPTRunFeatureMetric struct {
	ID                string           `spanner:"ID"`
	WebFeatureID      string           `spanner:"WebFeatureID"`
	FeatureRunDetails spanner.NullJSON `spanner:"FeatureRunDetails"`
	WPTRunFeatureMetric
	// Calculated pass rate
	TestPassRate    *big.Rat `spanner:"TestPassRate"`
	SubtestPassRate *big.Rat `spanner:"SubtestPassRate"`
	// Denormalized data from wpt runs.
	BrowserName string    `spanner:"BrowserName"`
	Channel     string    `spanner:"Channel"`
	TimeStart   time.Time `spanner:"TimeStart"`
}

SpannerWPTRunFeatureMetric is a wrapper for the metric data that is actually stored in spanner. This is useful because the spanner id is not useful to return to the end user since it is used to decouple the primary keys between this system and wpt.fyi.

type SpannerWebFeature

type SpannerWebFeature struct {
	ID string `spanner:"ID"`
	WebFeature
}

SpannerWebFeature is a wrapper for the feature that is actually stored in spanner. This is useful because the spanner id is not useful to return to the end user since it is only used to decouple the primary keys between this system and web features repo.

type UpdateSavedSearchRequest

type UpdateSavedSearchRequest struct {
	ID          string
	AuthorID    string
	Query       OptionallySet[string]
	Name        OptionallySet[string]
	Description OptionallySet[*string]
}

UpdateSavedSearchRequest is a request to update the saved search.

type UserSavedSearch

type UserSavedSearch struct {
	SavedSearch
	// Role will be nil if the user is not authenticated.
	Role *string `spanner:"Role"`
	// IsBookmarked will be nil if the user is not authenticated.
	IsBookmarked *bool `spanner:"IsBookmarked"`
}

UserSavedSearch represents a SavedSearch and a user's attributes related to that SavedSearch.

type UserSavedSearchBookmark

type UserSavedSearchBookmark struct {
	UserID        string `spanner:"UserID"`
	SavedSearchID string `spanner:"SavedSearchID"`
}

UserSavedSearchBookmark represents a user's bookmark for a saved search.

type WPTMetricView

type WPTMetricView string
const (
	WPTSubtestView WPTMetricView = "subtest"
	WPTTestView    WPTMetricView = "test"
)

type WPTRun

type WPTRun struct {
	RunID            int64     `spanner:"ExternalRunID"`
	TimeStart        time.Time `spanner:"TimeStart"`
	TimeEnd          time.Time `spanner:"TimeEnd"`
	BrowserName      string    `spanner:"BrowserName"`
	BrowserVersion   string    `spanner:"BrowserVersion"`
	Channel          string    `spanner:"Channel"`
	OSName           string    `spanner:"OSName"`
	OSVersion        string    `spanner:"OSVersion"`
	FullRevisionHash string    `spanner:"FullRevisionHash"`
}

WPTRun contains common metadata for a run. Columns come from the ../../infra/storage/spanner/migrations/*.sql files.

type WPTRunAggregationMetricWithTime

type WPTRunAggregationMetricWithTime struct {
	WPTRunFeatureMetricWithTime
}

WPTRunAggregationMetricWithTime contains metrics for a particular aggregation at a given time. For now, it is the same metrics as WPTRunFeatureMetricWithTime.

type WPTRunCursor

type WPTRunCursor struct {
	LastTimeStart time.Time `json:"last_time_start"`
	LastRunID     int64     `json:"last_run_id"`
}

WPTRunCursor: Represents a point for resuming queries based on the last TimeStart and ExternalRunID. Useful for pagination.

type WPTRunDataForMetrics

type WPTRunDataForMetrics struct {
	ID          string    `spanner:"ID"`
	BrowserName string    `spanner:"BrowserName"`
	Channel     string    `spanner:"Channel"`
	TimeStart   time.Time `spanner:"TimeStart"`
}

WPTRunDataForMetrics contains duplicate data from WPTRuns that will be stored in the individual metrics. It will allow for quicker look up of metrics.

type WPTRunFeatureMetric

type WPTRunFeatureMetric struct {
	TotalTests        *int64                 `spanner:"TotalTests"`
	TestPass          *int64                 `spanner:"TestPass"`
	TotalSubtests     *int64                 `spanner:"TotalSubtests"`
	SubtestPass       *int64                 `spanner:"SubtestPass"`
	FeatureRunDetails map[string]interface{} `spanner:"-"` // Not directly stored in Spanner
}

WPTRunFeatureMetric represents the metrics for a particular feature in a run.

type WPTRunFeatureMetricWithTime

type WPTRunFeatureMetricWithTime struct {
	TimeStart  time.Time `spanner:"TimeStart"`
	RunID      int64     `spanner:"ExternalRunID"`
	TotalTests *int64    `spanner:"TotalTests"`
	TestPass   *int64    `spanner:"TestPass"`
}

WPTRunFeatureMetricWithTime contains metrics for a feature at a given time.

type WebFeature

type WebFeature struct {
	FeatureKey string `spanner:"FeatureKey"`
	Name       string `spanner:"Name"`
}

WebFeature contains common metadata for a Web Feature. Columns come from the ../../infra/storage/spanner/migrations/*.sql files.

type WebFeatureChromiumHistogramEnumValue

type WebFeatureChromiumHistogramEnumValue struct {
	WebFeatureID                 string `spanner:"WebFeatureID"`
	ChromiumHistogramEnumValueID string `spanner:"ChromiumHistogramEnumValueID"`
}

WebFeatureChromiumHistogramEnumValue contains the mapping between ChromiumHistogramEnumValues and WebFeatures. Columns come from the ../../infra/storage/spanner/migrations/*.sql files.

type WebFeatureGroup

type WebFeatureGroup struct {
	WebFeatureID string   `spanner:"WebFeatureID"`
	GroupIDs     []string `spanner:"GroupIDs"`
}

WebFeatureGroup contains the mapping between WebDXGroups and WebFeatures. Columns come from the ../../infra/storage/spanner/migrations/*.sql files.

type WebFeatureSnapshot

type WebFeatureSnapshot struct {
	WebFeatureID string   `spanner:"WebFeatureID"`
	SnapshotIDs  []string `spanner:"SnapshotIDs"`
}

WebFeatureSnapshot contains the mapping between WebDXSnapshots and WebFeatures. Columns come from the ../../infra/storage/spanner/migrations/*.sql files.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL