feat: split out messages table from main database

This commit is contained in:
spiral
2022-11-23 09:17:19 +00:00
parent 09ac002d26
commit bf7747ab34
14 changed files with 119 additions and 84 deletions
+5 -7
View File
@@ -36,14 +36,12 @@ func update_db_meta() {
}
func update_db_message_meta() {
// since we're doing this concurrently, it needs a separate db connection
tmp_db := pg_connect(get_env_var("DATA_DB_URI"))
defer tmp_db.Close(context.Background())
count := get_message_count()
key := "message"
q := fmt.Sprintf("update info set %s_count = (select count(*) from %s)", key, plural(key))
log.Println("data db query:", q)
run_simple_pg_query(tmp_db, q)
_, err := data_db.Exec(context.Background(), "update info set message_count = $1", count)
if err != nil {
panic(err)
}
}
func update_stats() {