lemmy/lemmy_db/src/aggregates/site_aggregates.rs

22 lines
524 B
Rust
Raw Normal View History

2020-12-03 03:39:31 +00:00
use crate::schema::site_aggregates;
use diesel::{result::Error, *};
use serde::Serialize;
#[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
#[table_name = "site_aggregates"]
pub struct SiteAggregates {
pub id: i32,
pub users: i64,
pub posts: i64,
pub comments: i64,
pub communities: i64,
}
impl SiteAggregates {
pub fn read(conn: &PgConnection) -> Result<Self, Error> {
site_aggregates::table.first::<Self>(conn)
}
}
2020-12-03 15:18:17 +00:00
// TODO add unit tests, to make sure triggers are working