Skip to content

Commit 188d38a

Browse files
committed
feat: update the analytics tables to include both aggregate and rolling projects
1 parent 1f69681 commit 188d38a

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

backend/migrations/0002_analytics.sql

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
create table if not exists user_stats_aggregate (
22
user_id int not null,
33
window_type text not null check (window_type in (
4-
'daily', 'weekly', 'monthly', 'yearly',
5-
'rolling_24h', 'rolling_7d', 'rolling_30d', 'rolling_365d'
4+
'daily', 'weekly', 'monthly', 'yearly'
65
)),
76
window_start timestamptz not null,
87
window_end timestamptz not null,
@@ -35,8 +34,29 @@ create table if not exists user_stats_rolling (
3534
);
3635

3736
create table if not exists user_project_stats_aggregate (
37+
user_id integer,
38+
project_path varchar(500) not null,
3839
project_id int primary key,
39-
window_type text not null check (window_type in ('day', 'week', 'month', 'year', 'last day', 'last week', 'last month', 'last year', 'all_time')),
40+
window_type text not null check (window_type in (
41+
'daily', 'weekly', 'monthly', 'yearly'
42+
)),
43+
window_start timestamp not null,
44+
window_end timestamp not null,
45+
lang_durations jsonb,
46+
machine_durations jsonb,
47+
editor_durations jsonb,
48+
activity_durations jsonb,
49+
files_durations jsonb,
50+
updated_at timestamptz default now()
51+
);
52+
53+
create table if not exists user_project_stats_rolling (
54+
user_id integer,
55+
project_path varchar(500) not null,
56+
project_id int primary key,
57+
window_type text not null check (window_type in (
58+
'rolling_24h', 'rolling_7d', 'rolling_30d', 'rolling_365d'
59+
)),
4060
window_start timestamp not null,
4161
window_end timestamp not null,
4262
lang_durations jsonb,

0 commit comments

Comments
 (0)