-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(overview): update chart titles and intervals for better data vis…
…ualization
- Loading branch information
Showing
5 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { expect } from '@jest/globals' | ||
import { applyInterval } from './clickhouse-query' | ||
|
||
describe('applyInterval', () => { | ||
it('should apply toStartOfDay for toStartOfDay interval', () => { | ||
const result = applyInterval('toStartOfDay', 'myColumn', 'myAlias') | ||
expect(result).toEqual('toDate(toStartOfDay(myColumn)) as myAlias') // Change to toEqual | ||
}) | ||
|
||
it('should apply toStartOfWeek for toStartOfWeek interval', () => { | ||
const result = applyInterval('toStartOfWeek', 'myColumn') | ||
expect(result).toEqual('toDate(toStartOfDay(myColumn)) as myColumn') // Change to toEqual | ||
}) | ||
|
||
it('should apply toStartOfMonth for toStartOfMonth interval', () => { | ||
const result = applyInterval('toStartOfMonth', 'myColumn', 'myAlias') | ||
expect(result).toEqual('toDate(toStartOfDay(myColumn)) as myAlias') // Change to toEqual | ||
}) | ||
|
||
it('should apply toStartOfHour for other intervals', () => { | ||
const result = applyInterval('toStartOfHour', 'myColumn', 'myAlias') | ||
expect(result).toEqual('toStartOfHour(myColumn) as myAlias') // Change to toEqual | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { ClickHouseInterval } from '@/types/clickhouse-interval' | ||
|
||
export function applyInterval( | ||
interval: ClickHouseInterval, | ||
column: string, | ||
alias?: string | ||
) { | ||
if ( | ||
interval === 'toStartOfMonth' || | ||
interval === 'toStartOfWeek' || | ||
interval === 'toStartOfDay' | ||
) { | ||
return `toDate(toStartOfDay(${column})) as ${alias || column}` | ||
} | ||
|
||
return `toStartOfHour(${column}) as ${alias || column}` | ||
} |