| 36537112 Andy McCall ↶ |
1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
use crate::event::Event; |
| 7 |
use sqlx::SqliteConnection; |
| 8 |
|
| 9 |
|
| 5eb57578 Andy McCall ↶ |
10 |
pub const TABLES: &[&str] = &[ |
| 11 |
"event_counts", |
| 12 |
"identities", |
| 13 |
"agents", |
| 14 |
"projects", |
| 15 |
"project_relations", |
| 16 |
"presence", |
| 17 |
"sessions", |
| 18 |
"channels", |
| 19 |
"messages", |
| 20 |
"reactions", |
| 21 |
"inbox", |
| 22 |
"messages_fts", |
| b044d909 Andy McCall ↶ |
23 |
"briefs", |
| 5eb57578 Andy McCall ↶ |
24 |
]; |
| 36537112 Andy McCall ↶ |
25 |
|
| 26 |
|
| 27 |
pub async fn apply(conn: &mut SqliteConnection, e: &Event) -> sqlx::Result<()> { |
| 28 |
sqlx::query("INSERT INTO event_counts (kind, n) VALUES (?, 1) ON CONFLICT(kind) DO UPDATE SET n = n + 1") |
| 29 |
.bind(&e.kind) |
| 30 |
.execute(&mut *conn) |
| 31 |
.await?; |
| 09752034 Andy McCall ↶ |
32 |
crate::principals::project(conn, e).await?; |
| 2fc88a7b Andy McCall ↶ |
33 |
crate::projects::project(conn, e).await?; |
| 34 |
crate::presence::project(conn, e).await?; |
| 5eb57578 Andy McCall ↶ |
35 |
crate::conversation::project(conn, e).await?; |
| 037c45d8 Andy McCall ↶ |
36 |
crate::rules::project(conn, e).await?; |
| 36537112 Andy McCall ↶ |
37 |
Ok(()) |
| 38 |
} |