You've already forked AstralRinth
forked from didirus/AstralRinth
Add dependencies to search (#578)
* Add dependencies to search * add attrs for faceting * run prepare * Add user data route from token * update to 24hrs * Fix report bugs
This commit is contained in:
@@ -42,8 +42,7 @@ impl ThreadMessageBuilder {
|
||||
&self,
|
||||
transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,
|
||||
) -> Result<ThreadMessageId, DatabaseError> {
|
||||
let thread_message_id =
|
||||
generate_thread_message_id(&mut *transaction).await?;
|
||||
let thread_message_id = generate_thread_message_id(&mut *transaction).await?;
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
@@ -76,14 +75,16 @@ impl ThreadBuilder {
|
||||
sqlx::query!(
|
||||
"
|
||||
INSERT INTO threads (
|
||||
id, thread_type
|
||||
id, thread_type, report_id, project_id
|
||||
)
|
||||
VALUES (
|
||||
$1, $2
|
||||
$1, $2, $3, $4
|
||||
)
|
||||
",
|
||||
thread_id as ThreadId,
|
||||
self.type_.as_str(),
|
||||
self.report_id.map(|x| x.0),
|
||||
self.project_id.map(|x| x.0),
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
@@ -110,10 +111,7 @@ impl ThreadBuilder {
|
||||
}
|
||||
|
||||
impl Thread {
|
||||
pub async fn get<'a, E>(
|
||||
id: ThreadId,
|
||||
exec: E,
|
||||
) -> Result<Option<Thread>, sqlx::Error>
|
||||
pub async fn get<'a, E>(id: ThreadId, exec: E) -> Result<Option<Thread>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
@@ -131,8 +129,7 @@ impl Thread {
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
let thread_ids_parsed: Vec<i64> =
|
||||
thread_ids.iter().map(|x| x.0).collect();
|
||||
let thread_ids_parsed: Vec<i64> = thread_ids.iter().map(|x| x.0).collect();
|
||||
let threads = sqlx::query!(
|
||||
"
|
||||
SELECT t.id, t.thread_type, t.show_in_mod_inbox, t.project_id, t.report_id,
|
||||
@@ -230,8 +227,7 @@ impl ThreadMessage {
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
let message_ids_parsed: Vec<i64> =
|
||||
message_ids.iter().map(|x| x.0).collect();
|
||||
let message_ids_parsed: Vec<i64> = message_ids.iter().map(|x| x.0).collect();
|
||||
let messages = sqlx::query!(
|
||||
"
|
||||
SELECT tm.id, tm.author_id, tm.thread_id, tm.body, tm.created
|
||||
@@ -246,8 +242,7 @@ impl ThreadMessage {
|
||||
id: ThreadMessageId(x.id),
|
||||
thread_id: ThreadId(x.thread_id),
|
||||
author_id: x.author_id.map(UserId),
|
||||
body: serde_json::from_value(x.body)
|
||||
.unwrap_or(MessageBody::Deleted),
|
||||
body: serde_json::from_value(x.body).unwrap_or(MessageBody::Deleted),
|
||||
created: x.created,
|
||||
}))
|
||||
})
|
||||
@@ -268,8 +263,7 @@ impl ThreadMessage {
|
||||
WHERE id = $1
|
||||
",
|
||||
id as ThreadMessageId,
|
||||
serde_json::to_value(MessageBody::Deleted)
|
||||
.unwrap_or(serde_json::json!({}))
|
||||
serde_json::to_value(MessageBody::Deleted).unwrap_or(serde_json::json!({}))
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user