You've already forked AstralRinth
Clear owned projects cache when deleting an org with projects (#6429)
This commit is contained in:
Generated
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT t.id team_id, m.id project_id FROM organizations o\n INNER JOIN mods m ON m.organization_id = o.id\n INNER JOIN teams t ON t.id = m.team_id\n WHERE o.id = $1 AND $1 IS NOT NULL\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "team_id",
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "project_id",
|
||||
"type_info": "Int8"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "98e3a6418947b037d45bf3b9b1b24ee0fb3c8b499b8f794c151e0c655b8f9365"
|
||||
}
|
||||
Generated
-22
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT t.id FROM organizations o\n INNER JOIN mods m ON m.organization_id = o.id\n INNER JOIN teams t ON t.id = m.team_id\n WHERE o.id = $1 AND $1 IS NOT NULL\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Int8"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "d3c5adda017df70a88983baa82e3feb0a3eb432ed2b9d3be0e7a0bc6b2421cdd"
|
||||
}
|
||||
@@ -732,9 +732,9 @@ pub async fn organization_delete(
|
||||
// Handle projects- every project that is in this organization needs to have its owner changed the organization owner
|
||||
// Now, no project should have an owner if it is in an organization, and also
|
||||
// the owner of an organization should not be a team member in any project
|
||||
let organization_project_teams = sqlx::query!(
|
||||
let organization_projects = sqlx::query!(
|
||||
"
|
||||
SELECT t.id FROM organizations o
|
||||
SELECT t.id team_id, m.id project_id FROM organizations o
|
||||
INNER JOIN mods m ON m.organization_id = o.id
|
||||
INNER JOIN teams t ON t.id = m.team_id
|
||||
WHERE o.id = $1 AND $1 IS NOT NULL
|
||||
@@ -742,9 +742,22 @@ pub async fn organization_delete(
|
||||
organization.id as database::models::ids::DBOrganizationId
|
||||
)
|
||||
.fetch(&mut transaction)
|
||||
.map_ok(|c| database::models::DBTeamId(c.id))
|
||||
.map_ok(|c| {
|
||||
(
|
||||
database::models::DBTeamId(c.team_id),
|
||||
database::models::DBProjectId(c.project_id),
|
||||
)
|
||||
})
|
||||
.try_collect::<Vec<_>>()
|
||||
.await?;
|
||||
let organization_project_teams = organization_projects
|
||||
.iter()
|
||||
.map(|(team_id, _)| *team_id)
|
||||
.collect::<Vec<_>>();
|
||||
let organization_project_ids = organization_projects
|
||||
.iter()
|
||||
.map(|(_, project_id)| *project_id)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for organization_project_team in &organization_project_teams {
|
||||
let new_id = crate::database::models::ids::generate_team_member_id(
|
||||
@@ -786,6 +799,13 @@ pub async fn organization_delete(
|
||||
database::models::DBTeamMember::clear_cache(*team_id, &redis).await?;
|
||||
}
|
||||
|
||||
for project_id in organization_project_ids {
|
||||
database::models::DBProject::clear_cache(
|
||||
project_id, None, None, &redis,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if !organization_project_teams.is_empty() {
|
||||
database::models::DBUser::clear_project_cache(&[owner_id], &redis)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user