add: forges ui

TODO: forges tickets feed, posts open/closed state
This commit is contained in:
trisua 2025-06-09 16:45:36 -04:00
parent 5b1db42c51
commit a6140f7c8c
40 changed files with 1664 additions and 1270 deletions

View file

@ -872,7 +872,7 @@ impl DataManager {
let res = query_row!(
&conn,
"SELECT * FROM posts WHERE context LIKE $1 AND owner = $2 LIMIT 1",
"SELECT * FROM posts WHERE context LIKE $1 AND owner = $2 AND is_deleted = 0 LIMIT 1",
params![&format!("%\"answering\":{question}%"), &(owner as i64),],
|x| { Ok(Self::get_post_from_row(x)) }
);
@ -1494,6 +1494,9 @@ impl DataManager {
// increase user post count
self.incr_user_post_count(data.owner).await?;
// increase community post count
self.incr_community_post_count(data.community).await?;
// return
Ok(data.id)
}
@ -1546,6 +1549,13 @@ impl DataManager {
self.decr_user_post_count(y.owner).await?;
}
// decr community post count
let community = self.get_community_by_id_no_void(y.community).await?;
if community.post_count > 0 {
self.decr_community_post_count(y.community).await?;
}
// decr question answer count
if y.context.answering != 0 {
let question = self.get_question_by_id(y.context.answering).await?;
@ -1622,12 +1632,19 @@ impl DataManager {
self.decr_user_post_count(y.owner).await?;
}
// decr community post count
let community = self.get_community_by_id_no_void(y.community).await?;
if community.post_count > 0 {
self.decr_community_post_count(y.community).await?;
}
// decr question answer count
if y.context.answering != 0 {
let question = self.get_question_by_id(y.context.answering).await?;
if question.is_global {
self.incr_question_answer_count(y.context.answering).await?;
self.decr_question_answer_count(y.context.answering).await?;
}
}
@ -1644,12 +1661,15 @@ impl DataManager {
// incr user post count
self.incr_user_post_count(y.owner).await?;
// incr community post count
self.incr_community_post_count(y.community).await?;
// incr question answer count
if y.context.answering != 0 {
let question = self.get_question_by_id(y.context.answering).await?;
if question.is_global {
self.decr_question_answer_count(y.context.answering).await?;
self.incr_question_answer_count(y.context.answering).await?;
}
}