add favorites for app

This commit is contained in:
Ruben Fiszel
2022-11-30 13:04:05 +01:00
parent ca6abb0ffc
commit ee436712cb
2 changed files with 11 additions and 0 deletions
+2
View File
@@ -4823,6 +4823,8 @@ components:
type: object
additionalProperties:
type: boolean
starred:
type: boolean
execution_mode:
type: string
enum: [viewer, publisher, anonymous]
+9
View File
@@ -54,6 +54,7 @@ pub struct ListableApp {
pub version: i64,
pub extra_perms: serde_json::Value,
pub execution_mode: String,
pub starred: bool,
}
#[derive(FromRow, Serialize, Deserialize)]
@@ -132,7 +133,15 @@ async fn list_apps(
"versions[array_upper(versions, 1)] as version",
"policy->>'execution_mode' as execution_mode",
"extra_perms",
"favorite.path IS NOT NULL as starred",
])
.left()
.join("favorite")
.on(
"favorite.favorite_kind = 'app' AND favorite.workspace_id = o.workspace_id AND favorite.path = o.path AND favorite.usr = ?"
.bind(&authed.username),
)
.order_desc("favorite.path IS NOT NULL")
.order_by("path", true)
.and_where("workspace_id = ?".bind(&w_id))
.offset(offset)