Skip to content

Commit 64828a5

Browse files
committed
Change the order in which data sources are decided
1 parent 0f171ea commit 64828a5

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Sources/DataTransferObjects/Query/CustomQuery+CompileDown.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,17 @@ extension CustomQuery {
230230
}
231231

232232
// Decide the data source based on the data source property and namespaces
233-
if let dataSource = query.dataSource, allowedDataSourceNames.contains(dataSource.name) {
234-
query.dataSource = .init(dataSource.name)
235-
} else if let namespace, (namespaceAvailableAfter ?? Date.distantPast) < earliestIntervalDate {
233+
if let namespace, (namespaceAvailableAfter ?? Date.distantPast) < earliestIntervalDate {
234+
// If a namespace is available, use the namespace, even if another data source is specified.
235+
// This allows us to specify com.telemetrydeck.all for global queries and still use the customer's
236+
// name space if they have one.
236237
query.dataSource = .init(namespace)
238+
} else if let dataSource = query.dataSource, allowedDataSourceNames.contains(dataSource.name) {
239+
// If no namespace is available and the customer requested a specific data source, use it
240+
// if it is in the list of allowed data sources.
241+
query.dataSource = .init(dataSource.name)
237242
} else {
243+
// Else fall back to telemetry-signals
238244
query.dataSource = .init("telemetry-signals")
239245
}
240246
}

0 commit comments

Comments
 (0)