Skip to content

Commit

Permalink
fix: add guidance re usage query count
Browse files Browse the repository at this point in the history
  • Loading branch information
wdoconnell committed Jul 22, 2024
1 parent 343d5c9 commit 4679df5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/cloud/usage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Organization} from '../../../src/types'

const statHeaders = [
'Data In (MB)',
'Query Count',
'Query Count (Flux Only) ?',
'Storage (GB-hr)',
'Data Out (GB)',
]
Expand Down
28 changes: 23 additions & 5 deletions src/usage/UsageSingleStat.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// Libraries
import React, {FC, useContext} from 'react'
import {Panel, ComponentSize, InfluxColors} from '@influxdata/clockface'
import {
Panel,
ComponentSize,
InfluxColors,
QuestionMarkTooltip,
} from '@influxdata/clockface'

// Components
import {View} from 'src/visualization'
import {UsageContext} from 'src/usage/context/usage'
import {UsageContext, VectorName} from 'src/usage/context/usage'

// Types
import {
Expand Down Expand Up @@ -39,6 +44,10 @@ const UsageSingleStat: FC<Props> = ({
decimalPlaces: {isEnforced: false, digits: 0},
}

// Adjusts table properties to warn user that only flux queries are included in the Query Count.
const isQueryCount: Boolean = usageVector.name === VectorName.QueryCount
const vectorName = isQueryCount ? 'Query Count (Flux Only)' : usageVector.name

const error = fromFluxResult?.table?.columns?.error?.data?.[0]

return (
Expand All @@ -51,9 +60,14 @@ const UsageSingleStat: FC<Props> = ({
size={ComponentSize.ExtraSmall}
testID="usage-single-stat--header"
>
<h5>{`${usageVector.name} ${
usageVector.unit !== '' ? `(${usageVector.unit})` : ''
}`}</h5>
<h5>
{`${vectorName} ${
usageVector.unit !== '' ? `(${usageVector.unit})` : ''
}`}
{isQueryCount && (
<QuestionMarkTooltip tooltipContents={queryCountWarning} />
)}
</h5>
</Panel.Header>
<Panel.Body className="panel-body--size" style={{height: 300 / length}}>
<View
Expand All @@ -68,4 +82,8 @@ const UsageSingleStat: FC<Props> = ({
)
}

const queryCountWarning = (
<p>SQL and InfluxQL query counts are not displayed.</p>
)

export default UsageSingleStat
7 changes: 7 additions & 0 deletions src/usage/context/usage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ const DEFAULT_USAGE: Usage = {
status: RemoteDataState.NotStarted,
}

export enum VectorName {
QueryCount = 'Query Count',
Storage = 'Storage',
DataIn = 'Data In',
DataOut = 'Data Out',
}

export interface UsageContextType {
billingDateTime: string
billingStats: FromFluxResult[]
Expand Down

0 comments on commit 4679df5

Please sign in to comment.