File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
apps/labrinth/src/clickhouse Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,13 @@ pub async fn init_client_with_database(
4848 "MergeTree()"
4949 } ;
5050
51+ // For the Clickhouse database on the staging environment, set a TTL to avoid accumulating too much data
52+ let ttl = if database == "staging_analytics" {
53+ "TTL toDateTime(recorded) + INTERVAL 1 DAY"
54+ } else {
55+ ""
56+ } ;
57+
5158 client
5259 . query ( & format ! (
5360 "
@@ -67,6 +74,7 @@ pub async fn init_client_with_database(
6774 headers Array(Tuple(String, String))
6875 )
6976 ENGINE = {engine}
77+ {ttl}
7078 PRIMARY KEY (project_id, recorded, ip)
7179 SETTINGS index_granularity = 8192
7280 "
@@ -93,6 +101,7 @@ pub async fn init_client_with_database(
93101 headers Array(Tuple(String, String))
94102 )
95103 ENGINE = {engine}
104+ {ttl}
96105 PRIMARY KEY (project_id, recorded, ip)
97106 SETTINGS index_granularity = 8192
98107 "
@@ -117,6 +126,7 @@ pub async fn init_client_with_database(
117126 parent UInt64
118127 )
119128 ENGINE = {engine}
129+ {ttl}
120130 PRIMARY KEY (project_id, recorded, user_id)
121131 SETTINGS index_granularity = 8192
122132 "
You can’t perform that action at this time.
0 commit comments