Local timeline
This commit is contained in:
@@ -113,6 +113,7 @@ impl Post {
|
||||
.expect("Error loading a page of posts for blog")
|
||||
}
|
||||
|
||||
/// Give a page of all the recent posts known to this instance (= federated timeline)
|
||||
pub fn get_recents_page(conn: &PgConnection, (min, max): (i32, i32)) -> Vec<Post> {
|
||||
posts::table.order(posts::creation_date.desc())
|
||||
.offset(min.into())
|
||||
@@ -121,6 +122,20 @@ impl Post {
|
||||
.expect("Error loading recent posts page")
|
||||
}
|
||||
|
||||
/// Give a page of posts from a specific instance
|
||||
pub fn get_instance_page(conn: &PgConnection, instance_id: i32, (min, max): (i32, i32)) -> Vec<Post> {
|
||||
use schema::blogs;
|
||||
|
||||
let blog_ids = blogs::table.filter(blogs::instance_id.eq(instance_id)).select(blogs::id);
|
||||
|
||||
posts::table.order(posts::creation_date.desc())
|
||||
.filter(posts::blog_id.eq(any(blog_ids)))
|
||||
.offset(min.into())
|
||||
.limit((max - min).into())
|
||||
.load::<Post>(conn)
|
||||
.expect("Error loading local posts page")
|
||||
}
|
||||
|
||||
pub fn get_authors(&self, conn: &PgConnection) -> Vec<User> {
|
||||
use schema::users;
|
||||
use schema::post_authors;
|
||||
|
||||
Reference in New Issue
Block a user