From ee436712cb327c366228a76c6e5a6b92ea20ba0b Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 30 Nov 2022 13:04:05 +0100 Subject: [PATCH] add favorites for app --- backend/windmill-api/openapi.yaml | 2 ++ backend/windmill-api/src/apps.rs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index 20c019621e..8d2d41ea16 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -4823,6 +4823,8 @@ components: type: object additionalProperties: type: boolean + starred: + type: boolean execution_mode: type: string enum: [viewer, publisher, anonymous] diff --git a/backend/windmill-api/src/apps.rs b/backend/windmill-api/src/apps.rs index 25ed3b0ab7..a071ae1f98 100644 --- a/backend/windmill-api/src/apps.rs +++ b/backend/windmill-api/src/apps.rs @@ -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)