You've already forked AstralRinth
forked from didirus/AstralRinth
tweak(labrinth): create Clickhouse tables with a TTL for staging env (#4343)
* tweak(labrinth): create Clickhouse tables with a TTL for staging env * chore: fix syntax error in Clickhouse DDL
This commit is contained in:
committed by
GitHub
parent
0511a14bd9
commit
e2f07a7848
@@ -48,6 +48,13 @@ pub async fn init_client_with_database(
|
|||||||
"MergeTree()"
|
"MergeTree()"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// For the Clickhouse database on the staging environment, set a TTL to avoid accumulating too much data
|
||||||
|
let ttl = if database == "staging_analytics" {
|
||||||
|
"TTL toDateTime(recorded) + INTERVAL 1 DAY"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
client
|
client
|
||||||
.query(&format!(
|
.query(&format!(
|
||||||
"
|
"
|
||||||
@@ -67,6 +74,7 @@ pub async fn init_client_with_database(
|
|||||||
headers Array(Tuple(String, String))
|
headers Array(Tuple(String, String))
|
||||||
)
|
)
|
||||||
ENGINE = {engine}
|
ENGINE = {engine}
|
||||||
|
{ttl}
|
||||||
PRIMARY KEY (project_id, recorded, ip)
|
PRIMARY KEY (project_id, recorded, ip)
|
||||||
SETTINGS index_granularity = 8192
|
SETTINGS index_granularity = 8192
|
||||||
"
|
"
|
||||||
@@ -93,6 +101,7 @@ pub async fn init_client_with_database(
|
|||||||
headers Array(Tuple(String, String))
|
headers Array(Tuple(String, String))
|
||||||
)
|
)
|
||||||
ENGINE = {engine}
|
ENGINE = {engine}
|
||||||
|
{ttl}
|
||||||
PRIMARY KEY (project_id, recorded, ip)
|
PRIMARY KEY (project_id, recorded, ip)
|
||||||
SETTINGS index_granularity = 8192
|
SETTINGS index_granularity = 8192
|
||||||
"
|
"
|
||||||
@@ -117,6 +126,7 @@ pub async fn init_client_with_database(
|
|||||||
parent UInt64
|
parent UInt64
|
||||||
)
|
)
|
||||||
ENGINE = {engine}
|
ENGINE = {engine}
|
||||||
|
{ttl}
|
||||||
PRIMARY KEY (project_id, recorded, user_id)
|
PRIMARY KEY (project_id, recorded, user_id)
|
||||||
SETTINGS index_granularity = 8192
|
SETTINGS index_granularity = 8192
|
||||||
"
|
"
|
||||||
|
|||||||
Reference in New Issue
Block a user