mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-08 16:39:22 +00:00
2ef0f8f5f8
* implement language tags for site/community in db and api * add api checks for valid languages * during db migration, update existing users, sites, communities to have all languages enabled * init new users/communities with site languages (not all languages) * federate site/community languages * fix tests * when updating site languages, limit community languages to this subset also, when making a new post and subset of user lang, community lang contains only one item, use that as post lang * add tests for actor_language db functions * include language list in siteview/communityview * Fix some of the review comments * Some more review changes * Add todo about boxed query * Add default_post_language to GetCommunityResponse
116 lines
3.8 KiB
Rust
116 lines
3.8 KiB
Rust
use crate::newtypes::{CommentId, CommunityId, PersonId, PostId};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[cfg(feature = "full")]
|
|
use crate::schema::{
|
|
comment_aggregates,
|
|
community_aggregates,
|
|
person_aggregates,
|
|
person_post_aggregates,
|
|
post_aggregates,
|
|
site_aggregates,
|
|
};
|
|
|
|
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
|
|
#[cfg_attr(feature = "full", diesel(table_name = comment_aggregates))]
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))]
|
|
pub struct CommentAggregates {
|
|
pub id: i32,
|
|
pub comment_id: CommentId,
|
|
pub score: i64,
|
|
pub upvotes: i64,
|
|
pub downvotes: i64,
|
|
pub published: chrono::NaiveDateTime,
|
|
pub child_count: i32,
|
|
}
|
|
|
|
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
|
|
#[cfg_attr(feature = "full", diesel(table_name = community_aggregates))]
|
|
#[cfg_attr(
|
|
feature = "full",
|
|
diesel(belongs_to(crate::source::community::Community))
|
|
)]
|
|
pub struct CommunityAggregates {
|
|
pub id: i32,
|
|
pub community_id: CommunityId,
|
|
pub subscribers: i64,
|
|
pub posts: i64,
|
|
pub comments: i64,
|
|
pub published: chrono::NaiveDateTime,
|
|
pub users_active_day: i64,
|
|
pub users_active_week: i64,
|
|
pub users_active_month: i64,
|
|
pub users_active_half_year: i64,
|
|
}
|
|
|
|
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
|
|
#[cfg_attr(feature = "full", diesel(table_name = person_aggregates))]
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
|
|
pub struct PersonAggregates {
|
|
pub id: i32,
|
|
pub person_id: PersonId,
|
|
pub post_count: i64,
|
|
pub post_score: i64,
|
|
pub comment_count: i64,
|
|
pub comment_score: i64,
|
|
}
|
|
|
|
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
|
|
#[cfg_attr(feature = "full", diesel(table_name = post_aggregates))]
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))]
|
|
pub struct PostAggregates {
|
|
pub id: i32,
|
|
pub post_id: PostId,
|
|
pub comments: i64,
|
|
pub score: i64,
|
|
pub upvotes: i64,
|
|
pub downvotes: i64,
|
|
pub stickied: bool,
|
|
pub published: chrono::NaiveDateTime,
|
|
pub newest_comment_time_necro: chrono::NaiveDateTime, // A newest comment time, limited to 2 days, to prevent necrobumping
|
|
pub newest_comment_time: chrono::NaiveDateTime,
|
|
}
|
|
|
|
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
|
|
#[cfg_attr(feature = "full", diesel(table_name = person_post_aggregates))]
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
|
|
pub struct PersonPostAggregates {
|
|
pub id: i32,
|
|
pub person_id: PersonId,
|
|
pub post_id: PostId,
|
|
pub read_comments: i64,
|
|
pub published: chrono::NaiveDateTime,
|
|
}
|
|
|
|
#[derive(Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
#[cfg_attr(feature = "full", diesel(table_name = person_post_aggregates))]
|
|
pub struct PersonPostAggregatesForm {
|
|
pub person_id: PersonId,
|
|
pub post_id: PostId,
|
|
pub read_comments: i64,
|
|
pub published: Option<chrono::NaiveDateTime>,
|
|
}
|
|
|
|
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
|
|
#[cfg_attr(feature = "full", diesel(table_name = site_aggregates))]
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))]
|
|
pub struct SiteAggregates {
|
|
pub id: i32,
|
|
pub site_id: i32,
|
|
pub users: i64,
|
|
pub posts: i64,
|
|
pub comments: i64,
|
|
pub communities: i64,
|
|
pub users_active_day: i64,
|
|
pub users_active_week: i64,
|
|
pub users_active_month: i64,
|
|
pub users_active_half_year: i64,
|
|
}
|