MCPcopy Create free account
hub / github.com/QuantumNous/new-api / clickHouseLogCreateTableSQL

Function clickHouseLogCreateTableSQL

model/main.go:429–456  ·  view source on GitHub ↗
(ttlDays int)

Source from the content-addressed store, hash-verified

427}
428
429func clickHouseLogCreateTableSQL(ttlDays int) string {
430 return fmt.Sprintf(`
431CREATE TABLE IF NOT EXISTS logs (
432 id Int64 DEFAULT 0,
433 user_id Int32 DEFAULT 0,
434 created_at Int64 DEFAULT 0,
435 type Int32 DEFAULT 0,
436 content String DEFAULT '',
437 username String DEFAULT '',
438 token_name String DEFAULT '',
439 model_name String DEFAULT '',
440 quota Int32 DEFAULT 0,
441 prompt_tokens Int32 DEFAULT 0,
442 completion_tokens Int32 DEFAULT 0,
443 use_time Int32 DEFAULT 0,
444 is_stream UInt8 DEFAULT 0,
445 channel_id Int32 DEFAULT 0,
446 token_id Int32 DEFAULT 0,
447 `+"`group`"+` String DEFAULT '',
448 ip String DEFAULT '',
449 request_id String DEFAULT '',
450 upstream_request_id String DEFAULT '',
451 other String DEFAULT ''
452)
453ENGINE = MergeTree()
454PARTITION BY toYYYYMM(toDateTime(created_at))
455ORDER BY (created_at, request_id)%s`, clickHouseLogTTLClause(ttlDays))
456}
457
458func syncClickHouseLogTTL(ttlDays int) error {
459 expression := clickHouseLogTTLExpression(ttlDays)

Callers 2

migrateClickHouseLogDBFunction · 0.85

Calls 1

clickHouseLogTTLClauseFunction · 0.85

Tested by 1