Testing bug fixes (#788)

* fixes

* adds tests- fixes failures

* changes

* moved transaction commits/caches around

* collections nullable

* merge fixes

* sqlx prepare

* revs

* lf fixes

* made changes back

* added collections update

---------

Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
Wyatt Verchere
2023-12-14 15:19:50 -07:00
committed by GitHub
parent 50e89ad98b
commit f939e59463
33 changed files with 494 additions and 112 deletions

View File

@@ -344,6 +344,28 @@ impl Project {
.execute(&mut **transaction)
.await?;
// Notably joins with report id and not thread.mod_id directly, as
// this is set to null for threads that are reports.
let report_threads = sqlx::query!(
"
SELECT t.id
FROM threads t
INNER JOIN reports r ON t.report_id = r.id
WHERE r.mod_id = $1 AND report_id IS NOT NULL
",
id as ProjectId,
)
.fetch_many(&mut **transaction)
.try_filter_map(|e| async { Ok(e.right().map(|x| ThreadId(x.id))) })
.try_collect::<Vec<_>>()
.await?;
for thread_id in report_threads {
models::Thread::remove_full(thread_id, transaction).await?;
}
models::Thread::remove_full(project.thread_id, transaction).await?;
sqlx::query!(
"
DELETE FROM reports
@@ -398,8 +420,6 @@ impl Project {
.execute(&mut **transaction)
.await?;
models::Thread::remove_full(project.thread_id, transaction).await?;
sqlx::query!(
"
DELETE FROM mods