Add a dashboard
This commit is contained in:
+9
-1
@@ -7,7 +7,7 @@ use reqwest::{
|
||||
use serde_json;
|
||||
use url::Url;
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
|
||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection, dsl::any};
|
||||
use openssl::{
|
||||
hash::MessageDigest,
|
||||
pkey::{PKey, Private},
|
||||
@@ -71,6 +71,14 @@ impl Blog {
|
||||
.into_iter().nth(0)
|
||||
}
|
||||
|
||||
pub fn find_for_author(conn: &PgConnection, author_id: i32) -> Vec<Blog> {
|
||||
use schema::blog_authors;
|
||||
let author_ids = blog_authors::table.filter(blog_authors::author_id.eq(author_id)).select(blog_authors::blog_id);
|
||||
blogs::table.filter(blogs::id.eq(any(author_ids)))
|
||||
.load::<Blog>(conn)
|
||||
.expect("Couldn't load blogs ")
|
||||
}
|
||||
|
||||
pub fn find_by_name(conn: &PgConnection, name: String, instance_id: i32) -> Option<Blog> {
|
||||
blogs::table.filter(blogs::actor_id.eq(name))
|
||||
.filter(blogs::instance_id.eq(instance_id))
|
||||
|
||||
Reference in New Issue
Block a user