-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TypeORM: AggregateColumn Decorator (#8)
* feat: add Aggregate directive * feat: add AggregateColumn * docs: * * test: fix wait 1 second longer for cagg * refactor: remove create_group_indexes * refactor: remove materialized_only * feat: introduce AggregateType * refactor: more usage of AggregateType * fix: more AggregateType usage * feat: add BucketColumn * test: fix update snaps
- Loading branch information
Showing
14 changed files
with
286 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,30 @@ | ||
import { ViewColumn } from 'typeorm'; | ||
import { ContinuousAggregate } from '@timescaledb/typeorm'; | ||
import { ContinuousAggregate, AggregateColumn, BucketColumn } from '@timescaledb/typeorm'; | ||
import { PageLoad } from './PageLoad'; | ||
import { AggregateType } from '@timescaledb/schemas'; | ||
|
||
@ContinuousAggregate(PageLoad, { | ||
name: 'hourly_page_views', | ||
bucket_interval: '1 hour', | ||
time_column: 'time', | ||
materialized_only: true, | ||
create_group_indexes: true, | ||
aggregates: { | ||
total_views: { | ||
type: 'count', | ||
column_alias: 'total_views', | ||
}, | ||
unique_users: { | ||
type: 'count_distinct', | ||
column: 'user_agent', | ||
column_alias: 'unique_users', | ||
}, | ||
}, | ||
refresh_policy: { | ||
start_offset: '3 days', | ||
end_offset: '1 hour', | ||
schedule_interval: '1 hour', | ||
}, | ||
}) | ||
export class HourlyPageViews { | ||
@ViewColumn() | ||
@BucketColumn({ | ||
source_column: 'time', | ||
}) | ||
bucket!: Date; | ||
|
||
@ViewColumn() | ||
@AggregateColumn({ | ||
type: AggregateType.Count, | ||
}) | ||
total_views!: number; | ||
|
||
@ViewColumn() | ||
@AggregateColumn({ | ||
type: AggregateType.CountDistinct, | ||
column: 'user_agent', | ||
}) | ||
unique_users!: number; | ||
} |
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
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
Oops, something went wrong.