api icon indicating copy to clipboard operation
api copied to clipboard

Feature: Ability to pin a workspace

Open jpmcb opened this issue 1 year ago • 0 comments

Suggested solution

Currently, when you get all workspaces via https://api.opensauced.pizza/v2/workspaces, you get the whole smattering of workspaces. This is fine, and we can now filter on the most recently updated: https://github.com/open-sauced/api/pull/761

But we had talked about how we could make this easier.

@zeucapua had the idea that we could add a "pinned" field in the workspaces to denote if it should be pinned to the top of the search. Noting that idea down in an issue for future reference but that would basically look like adding an additional row to the workspaces table:

alter table workspaces add column pinned boolean default false;

Then, when we get the workspaces, we can make this part of the metadata when we return the workspaces. This "pinned" part of the metadata would always be present, no matter which page you were on:

{
  "data": [
    {
      "id": "a34a3625-009f-4896-a946-3bb430eb671d",
      "created_at": "2024-02-20T20:08:20.209Z",
      "updated_at": "2024-04-05T23:12:55.245Z",
      "deleted_at": null,
      "name": "Your workspace",
      "description": "Your personal workspace",
      "is_public": true,
      "payee_user_id": 23109390,
      "members": [
        {
          "id": "e2631622-f1ad-403f-8511-6e948fea1dc5",
          "user_id": 23109390,
          "workspace_id": "a34a3625-009f-4896-a946-3bb430eb671d",
          "created_at": "2024-02-20T20:08:20.209Z",
          "updated_at": "2024-02-20T20:08:20.209Z",
          "deleted_at": null,
          "role": "owner"
        }
      ]
    }
  ],
  "meta": {
    "pinned": {
      "id": "abc-123",
      "created_at": "2024-02-20T20:08:20.209Z",
      "updated_at": "2024-04-05T23:12:55.245Z",
      "deleted_at": null,
      "name": "My pinned workspace",
      "description": "Your personal workspace",
      "is_public": true,
      "payee_user_id": 23109390,
      "members": [
        {
          "id": "e2631622-f1ad-403f-8511-6e948fea1dc5",
          "user_id": 23109390,
          "workspace_id": "a34a3625-009f-4896-a946-3bb430eb671d",
          "created_at": "2024-02-20T20:08:20.209Z",
          "updated_at": "2024-02-20T20:08:20.209Z",
          "deleted_at": null,
          "role": "owner"
        }
      ]
    }
    "page": 1,
    "limit": 10,
    "itemCount": 1,
    "pageCount": 1,
    "hasPreviousPage": false,
    "hasNextPage": false
  }
}

jpmcb avatar May 03 '24 22:05 jpmcb