Skip to content

Commit

Permalink
Merge pull request #1141 from AppFlowy-IO/select-most-recent-non-orig…
Browse files Browse the repository at this point in the history
…inal-workspace

fix: select most recent non original namespace
  • Loading branch information
khorshuheng authored Jan 9, 2025
2 parents f380c34 + 6d09fbb commit bb08655
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions libs/database/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ pub async fn select_default_published_view_id<'a, E: Executor<'a, Database = Pos
Ok(res)
}

async fn select_first_non_original_namespace(
async fn select_most_recent_non_original_namespace(
pg_pool: &PgPool,
namespace: &str,
) -> Result<Option<String>, AppError> {
Expand All @@ -535,7 +535,7 @@ async fn select_first_non_original_namespace(
FROM af_workspace_namespace
WHERE workspace_id = (SELECT workspace_id FROM af_workspace_namespace WHERE namespace = $1)
AND is_original = FALSE
ORDER BY created_at ASC
ORDER BY created_at DESC
LIMIT 1
"#,
namespace,
Expand Down Expand Up @@ -575,7 +575,7 @@ pub async fn select_publish_info_for_view_ids(
return Ok(res);
}
if let Some(non_original_namespace) =
select_first_non_original_namespace(pg_pool, &res[0].namespace).await?
select_most_recent_non_original_namespace(pg_pool, &res[0].namespace).await?
{
res.iter_mut().for_each(|info| {
info.namespace.clone_from(&non_original_namespace);
Expand Down Expand Up @@ -633,7 +633,7 @@ async fn use_non_orginal_namespace_if_possible(
}

if let Some(non_original_namespace) =
select_first_non_original_namespace(pg_pool, &publish_infos[0].namespace).await?
select_most_recent_non_original_namespace(pg_pool, &publish_infos[0].namespace).await?
{
publish_infos.iter_mut().for_each(|info| {
info.namespace.clone_from(&non_original_namespace);
Expand Down

0 comments on commit bb08655

Please sign in to comment.