Removed the concept of down & upvotes
This commit is contained in:
parent
84defa703e
commit
2e23c7919f
11 changed files with 58 additions and 120 deletions
|
|
@ -39,7 +39,7 @@ pub async fn db_get_comments(
|
|||
) -> Vec<PublicComment> {
|
||||
sqlx::query_as!(
|
||||
PublicComment,
|
||||
"SELECT id, parent_post_id, upvotes, downvotes, content, created_at, updated_at
|
||||
"SELECT id, parent_post_id, content, created_at, updated_at
|
||||
FROM comments WHERE parent_post_id = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3",
|
||||
parent_post_id,
|
||||
limit,
|
||||
|
|
@ -54,7 +54,7 @@ pub async fn db_get_comments(
|
|||
pub async fn db_get_latest_posts(pool: &PgPool, limit: i64, offset: i64) -> Vec<PublicPost> {
|
||||
sqlx::query_as!(
|
||||
PublicPost,
|
||||
"SELECT id, content, upvotes, downvotes, created_at, updated_at FROM posts ORDER BY created_at DESC LIMIT $1 OFFSET $2",
|
||||
"SELECT id, content, created_at, updated_at FROM posts ORDER BY created_at DESC LIMIT $1 OFFSET $2",
|
||||
limit,
|
||||
offset
|
||||
)
|
||||
|
|
@ -67,7 +67,7 @@ pub async fn db_get_latest_posts(pool: &PgPool, limit: i64, offset: i64) -> Vec<
|
|||
pub async fn db_get_post(id: i64, pool: &PgPool) -> Option<PublicPost> {
|
||||
sqlx::query_as!(
|
||||
PublicPost,
|
||||
"SELECT id, content, upvotes, downvotes, created_at, updated_at FROM posts WHERE id = $1",
|
||||
"SELECT id, content, created_at, updated_at FROM posts WHERE id = $1",
|
||||
id
|
||||
)
|
||||
.fetch_one(pool)
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ pub struct Comment {
|
|||
pub parent_post_id: i64,
|
||||
pub parent_comment_id: Option<i64>,
|
||||
pub author_user_id: i64,
|
||||
pub upvotes: i32,
|
||||
pub downvotes: i32,
|
||||
pub content: String,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
pub updated_at: chrono::NaiveDateTime,
|
||||
|
|
@ -28,8 +26,6 @@ pub struct Comment {
|
|||
pub struct PublicComment {
|
||||
pub id: i64,
|
||||
pub parent_post_id: i64,
|
||||
pub upvotes: i32,
|
||||
pub downvotes: i32,
|
||||
pub content: String,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
pub updated_at: chrono::NaiveDateTime,
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ pub struct Post {
|
|||
pub id: i64,
|
||||
pub user_id: i64,
|
||||
pub content: String,
|
||||
pub upvotes: i64,
|
||||
pub downvotes: i64,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
pub updated_at: chrono::NaiveDateTime,
|
||||
}
|
||||
|
|
@ -26,8 +24,6 @@ pub struct Post {
|
|||
pub struct PublicPost {
|
||||
pub id: i64,
|
||||
pub content: String,
|
||||
pub upvotes: i64,
|
||||
pub downvotes: i64,
|
||||
#[serde(rename = "createdAt")]
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
#[serde(rename = "updatedAt")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue