Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(dss|search|soup): update all document models to return is_task (#448)
Will Hutchinsonec0eb7d1cd70
diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/get_batch_preview.rs b/rust/cloud-storage/document_storage_service/src/api/documents/get_batch_preview.rsindex 88b6829633..6b3cb772a1 100644--- a/rust/cloud-storage/document_storage_service/src/api/documents/get_batch_preview.rs+++ b/rust/cloud-storage/document_storage_service/src/api/documents/get_batch_preview.rs@@ -57,6 +57,7 @@ pub async fn get_batch_preview_handler(file_type: preview_data.file_type.clone(),owner: preview_data.owner.clone(),updated_at: preview_data.updated_at,+ is_task: preview_data.is_task,})}DocumentPreviewV2::DoesNotExist(preview_data) => {diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-1f4e2a83d6a137cc6e15e4facb94e404a5aa8a301e9c28e0d5680b79a18da4fd.json b/rust/cloud-storage/macro_db_client/.sqlx/query-1f4e2a83d6a137cc6e15e4facb94e404a5aa8a301e9c28e0d5680b79a18da4fd.jsonnew file mode 100644index 0000000000..f56b186c03--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-1f4e2a83d6a137cc6e15e4facb94e404a5aa8a301e9c28e0d5680b79a18da4fd.json@@ -0,0 +1,22 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT document_id FROM document_task WHERE document_id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "document_id",+ "type_info": "Text"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ false+ ]+ },+ "hash": "1f4e2a83d6a137cc6e15e4facb94e404a5aa8a301e9c28e0d5680b79a18da4fd"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-2c704ca8ff6085f844e5cab2e9d340d36e19a599a7e8180b97a63387653b4b5a.json b/rust/cloud-storage/macro_db_client/.sqlx/query-2c704ca8ff6085f844e5cab2e9d340d36e19a599a7e8180b97a63387653b4b5a.jsonnew file mode 100644index 0000000000..6568db15d0--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-2c704ca8ff6085f844e5cab2e9d340d36e19a599a7e8180b97a63387653b4b5a.json@@ -0,0 +1,112 @@+{+ "db_name": "PostgreSQL",+ "query": "\n WITH UserHistories AS (\n SELECT\n h.\"itemId\" as item_id,\n h.\"itemType\" as item_type\n FROM \"UserHistory\" h\n WHERE h.\"userId\" = $1\n ), Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"projectId\" as \"project_id\",\n d.\"deletedAt\"::timestamptz as \"deleted_at\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n INNER JOIN UserHistories uh ON uh.item_id = d.id AND uh.item_type = 'document'\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON true\n UNION ALL\n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at\",\n c.\"updatedAt\"::timestamptz as \"updated_at\",\n c.\"projectId\" as \"project_id\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\"\n FROM \"Chat\" c\n INNER JOIN UserHistories uh ON uh.item_id = c.id AND uh.item_type = 'chat'\n UNION ALL\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at\",\n p.\"updatedAt\"::timestamptz as \"updated_at\",\n p.\"parentId\" as \"project_id\",\n p.\"deletedAt\"::timestamptz as \"deleted_at\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\"\n FROM \"Project\" p\n INNER JOIN UserHistories uh ON uh.item_id = p.id AND uh.item_type = 'project'\n )\n SELECT * FROM Combined\n ORDER BY updated_at DESC\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "item_type!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "id!",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "document_version_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "user_id!",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "name!",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "branched_from_id",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "branched_from_version_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 7,+ "name": "document_family_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 8,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 10,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 11,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "deleted_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 13,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 14,+ "name": "sha",+ "type_info": "Text"+ },+ {+ "ordinal": 15,+ "name": "is_task!",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "2c704ca8ff6085f844e5cab2e9d340d36e19a599a7e8180b97a63387653b4b5a"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-fe3e4b8e8d51b71be681eafd1b866571c0fb275bf69bb80282e5e5cc5f550f2e.json b/rust/cloud-storage/macro_db_client/.sqlx/query-317713a06e38e92d9f99d4170cac7e566e4a76412bae191404ecec4ca88e23e4.jsonsimilarity index 55%rename from rust/cloud-storage/macro_db_client/.sqlx/query-fe3e4b8e8d51b71be681eafd1b866571c0fb275bf69bb80282e5e5cc5f550f2e.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-317713a06e38e92d9f99d4170cac7e566e4a76412bae191404ecec4ca88e23e4.jsonindex f92ed98375..07e84cead5 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-fe3e4b8e8d51b71be681eafd1b866571c0fb275bf69bb80282e5e5cc5f550f2e.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-317713a06e38e92d9f99d4170cac7e566e4a76412bae191404ecec4ca88e23e4.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n d.id as document_id,\n d.owner as owner,\n d.name as document_name,\n COALESCE(db.id, di.id) as \"document_version_id!\",\n d.\"branchedFromId\" as \"branched_from_id?\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id?\",\n d.\"documentFamilyId\" as \"document_family_id?\",\n d.\"fileType\" as file_type,\n d.\"createdAt\"::timestamptz as created_at,\n d.\"updatedAt\"::timestamptz as updated_at,\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id?\",\n p.name as \"project_name?\",\n di.sha as \"sha?\"\n FROM\n \"Document\" d\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx'\n LEFT JOIN \"Project\" p ON p.id = d.\"projectId\"\n WHERE\n d.\"deletedAt\" IS NULL\n ORDER BY d.\"createdAt\" DESC\n LIMIT $1 OFFSET $2\n\n ",+ "query": "\n SELECT\n d.id as document_id,\n d.owner as owner,\n d.name as document_name,\n COALESCE(db.id, di.id) as \"document_version_id!\",\n d.\"branchedFromId\" as \"branched_from_id?\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id?\",\n d.\"documentFamilyId\" as \"document_family_id?\",\n d.\"fileType\" as file_type,\n d.\"createdAt\"::timestamptz as created_at,\n d.\"updatedAt\"::timestamptz as updated_at,\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id?\",\n p.name as \"project_name?\",\n di.sha as \"sha?\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM\n \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx'\n LEFT JOIN \"Project\" p ON p.id = d.\"projectId\"\n WHERE\n d.\"deletedAt\" IS NULL\n ORDER BY d.\"createdAt\" DESC\n LIMIT $1 OFFSET $2\n\n ","describe": {"columns": [{@@ -77,6 +77,11 @@"ordinal": 14,"name": "sha?","type_info": "Text"+ },+ {+ "ordinal": 15,+ "name": "is_task!",+ "type_info": "Bool"}],"parameters": {@@ -100,8 +105,9 @@null,true,false,- false+ false,+ null]},- "hash": "fe3e4b8e8d51b71be681eafd1b866571c0fb275bf69bb80282e5e5cc5f550f2e"+ "hash": "317713a06e38e92d9f99d4170cac7e566e4a76412bae191404ecec4ca88e23e4"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-97c585df277c244a330e227bba437cc8b0109c1fc3a140e37006c904431a235e.json b/rust/cloud-storage/macro_db_client/.sqlx/query-509366e20760bbad7e094429de614fd01d041aa084effbee6a272e4f61fa61ba.jsonsimilarity index 54%rename from rust/cloud-storage/macro_db_client/.sqlx/query-97c585df277c244a330e227bba437cc8b0109c1fc3a140e37006c904431a235e.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-509366e20760bbad7e094429de614fd01d041aa084effbee6a272e4f61fa61ba.jsonindex 0e47596e3a..be44bc0760 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-97c585df277c244a330e227bba437cc8b0109c1fc3a140e37006c904431a235e.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-509366e20760bbad7e094429de614fd01d041aa084effbee6a272e4f61fa61ba.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n d.id as \"document_id\",\n d.owner as \"owner\",\n COALESCE(db.id, di.id) as \"document_version_id!\",\n d.name as \"document_name\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"fileType\" as \"file_type\",\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id\",\n p.name as \"project_name?\",\n di.sha as \"sha?\"\n FROM\n \"Document\" d\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.sha,\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"createdAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx'\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n p.name\n FROM \"Project\" p\n WHERE p.id = d.\"projectId\"\n ) p ON d.\"projectId\" IS NOT NULL\n WHERE\n d.id = $1\n LIMIT 1\n ",+ "query": "\n SELECT\n d.id as \"document_id\",\n d.owner as \"owner\",\n COALESCE(db.id, di.id) as \"document_version_id!\",\n d.name as \"document_name\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"fileType\" as \"file_type\",\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id\",\n p.name as \"project_name?\",\n di.sha as \"sha?\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM\n \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.sha,\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"createdAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx'\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n p.name\n FROM \"Project\" p\n WHERE p.id = d.\"projectId\"\n ) p ON d.\"projectId\" IS NOT NULL\n WHERE\n d.id = $1\n LIMIT 1\n ","describe": {"columns": [{@@ -77,6 +77,11 @@"ordinal": 14,"name": "sha?","type_info": "Text"+ },+ {+ "ordinal": 15,+ "name": "is_task!",+ "type_info": "Bool"}],"parameters": {@@ -99,8 +104,9 @@null,true,false,- false+ false,+ null]},- "hash": "97c585df277c244a330e227bba437cc8b0109c1fc3a140e37006c904431a235e"+ "hash": "509366e20760bbad7e094429de614fd01d041aa084effbee6a272e4f61fa61ba"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-56760728c44729a4ba166cda98fee580b844bd74d297f2016a50a079258ea44e.json b/rust/cloud-storage/macro_db_client/.sqlx/query-56760728c44729a4ba166cda98fee580b844bd74d297f2016a50a079258ea44e.jsondeleted file mode 100644index af111b2d39..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-56760728c44729a4ba166cda98fee580b844bd74d297f2016a50a079258ea44e.json+++ /dev/null@@ -1,82 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"deletedAt\"::timestamptz as \"deleted_at\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\"\n FROM \"Document\" d\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT\n i.id\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON true\n WHERE d.owner = $1 AND d.\"deletedAt\" IS NOT NULL\n UNION ALL\n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at\",\n c.\"updatedAt\"::timestamptz as \"updated_at\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\"\n FROM \"Chat\" c\n WHERE c.\"userId\" = $1 AND c.\"deletedAt\" IS NOT NULL\n UNION ALL\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at\",\n p.\"updatedAt\"::timestamptz as \"updated_at\",\n p.\"deletedAt\"::timestamptz as \"deleted_at\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\"\n FROM \"Project\" p\n WHERE p.\"userId\" = $1 AND p.\"deletedAt\" IS NOT NULL\n ORDER BY deleted_at DESC\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "item_type!",- "type_info": "Text"- },- {- "ordinal": 1,- "name": "id!",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "document_version_id",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "user_id!",- "type_info": "Text"- },- {- "ordinal": 4,- "name": "name!",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "file_type",- "type_info": "Text"- },- {- "ordinal": 6,- "name": "created_at",- "type_info": "Timestamptz"- },- {- "ordinal": 7,- "name": "updated_at",- "type_info": "Timestamptz"- },- {- "ordinal": 8,- "name": "deleted_at",- "type_info": "Timestamptz"- },- {- "ordinal": 9,- "name": "project_id",- "type_info": "Text"- },- {- "ordinal": 10,- "name": "is_persistent",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "56760728c44729a4ba166cda98fee580b844bd74d297f2016a50a079258ea44e"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-cf207456850d0b08afbe06c8967e778b3fb2c6b08ff5b8d0158d45a9c7971659.json b/rust/cloud-storage/macro_db_client/.sqlx/query-5b9295bd6d3093e90710529c92fdef5bd20eda2603cf884e0fb0363b1ee1b529.jsonsimilarity index 83%rename from rust/cloud-storage/macro_db_client/.sqlx/query-cf207456850d0b08afbe06c8967e778b3fb2c6b08ff5b8d0158d45a9c7971659.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-5b9295bd6d3093e90710529c92fdef5bd20eda2603cf884e0fb0363b1ee1b529.jsonindex 04416dfbab..530b70cf25 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-cf207456850d0b08afbe06c8967e778b3fb2c6b08ff5b8d0158d45a9c7971659.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-5b9295bd6d3093e90710529c92fdef5bd20eda2603cf884e0fb0363b1ee1b529.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n d.id as document_id,\n d.owner as owner,\n d.name as document_name,\n COALESCE(db.id, di.id) as \"document_version_id!\",\n d.\"fileType\" as \"file_type?\",\n d.\"createdAt\"::timestamptz as created_at,\n d.\"updatedAt\"::timestamptz as updated_at,\n d.\"projectId\" as \"project_id?\"\n FROM\n \"Document\" d\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"createdAt\",\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx'\n WHERE d.\"projectId\" = $1 AND d.\"deletedAt\" IS NULL\n ",+ "query": "\n SELECT\n d.id as document_id,\n d.owner as owner,\n d.name as document_name,\n COALESCE(db.id, di.id) as \"document_version_id!\",\n d.\"fileType\" as \"file_type?\",\n d.\"createdAt\"::timestamptz as created_at,\n d.\"updatedAt\"::timestamptz as updated_at,\n d.\"projectId\" as \"project_id?\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM\n \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"createdAt\",\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx'\n WHERE d.\"projectId\" = $1 AND d.\"deletedAt\" IS NULL\n ","describe": {"columns": [{@@ -42,6 +42,11 @@"ordinal": 7,"name": "project_id?","type_info": "Text"+ },+ {+ "ordinal": 8,+ "name": "is_task!",+ "type_info": "Bool"}],"parameters": {@@ -57,8 +62,9 @@true,null,null,- true+ true,+ null]},- "hash": "cf207456850d0b08afbe06c8967e778b3fb2c6b08ff5b8d0158d45a9c7971659"+ "hash": "5b9295bd6d3093e90710529c92fdef5bd20eda2603cf884e0fb0363b1ee1b529"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-4bf57bf947dc4fce7000fde3a8de48e79be4c1c40d8a68370c728b92a94332ec.json b/rust/cloud-storage/macro_db_client/.sqlx/query-7245c15f8766cf7f511fa11cf0a43e61ed6d4ff1eb25bd94a2870cc762a33f78.jsonsimilarity index 55%rename from rust/cloud-storage/macro_db_client/.sqlx/query-4bf57bf947dc4fce7000fde3a8de48e79be4c1c40d8a68370c728b92a94332ec.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-7245c15f8766cf7f511fa11cf0a43e61ed6d4ff1eb25bd94a2870cc762a33f78.jsonindex 1ea6dfe8b5..3c59d2dd25 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-4bf57bf947dc4fce7000fde3a8de48e79be4c1c40d8a68370c728b92a94332ec.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-7245c15f8766cf7f511fa11cf0a43e61ed6d4ff1eb25bd94a2870cc762a33f78.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n d.id as \"document_id\",\n d.owner as \"owner\",\n d.name as \"document_name\",\n COALESCE(di.id, db.id) as \"document_version_id!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"fileType\" as \"file_type\",\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id?\",\n p.name as \"project_name?\",\n di.sha as \"sha?\"\n FROM\n \"Document\" d\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.sha,\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n AND\n i.id = $2\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx'\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n AND\n b.id = $2\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n p.name\n FROM \"Project\" p\n WHERE p.id = d.\"projectId\"\n ) p ON d.\"projectId\" IS NOT NULL\n WHERE\n d.id = $1\n LIMIT 1\n ",+ "query": "\n SELECT\n d.id as \"document_id\",\n d.owner as \"owner\",\n d.name as \"document_name\",\n COALESCE(di.id, db.id) as \"document_version_id!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"fileType\" as \"file_type\",\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id?\",\n p.name as \"project_name?\",\n di.sha as \"sha?\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM\n \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.sha,\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n AND\n i.id = $2\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx'\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n AND\n b.id = $2\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n p.name\n FROM \"Project\" p\n WHERE p.id = d.\"projectId\"\n ) p ON d.\"projectId\" IS NOT NULL\n WHERE\n d.id = $1\n LIMIT 1\n ","describe": {"columns": [{@@ -77,6 +77,11 @@"ordinal": 14,"name": "sha?","type_info": "Text"+ },+ {+ "ordinal": 15,+ "name": "is_task!",+ "type_info": "Bool"}],"parameters": {@@ -100,8 +105,9 @@null,true,false,- false+ false,+ null]},- "hash": "4bf57bf947dc4fce7000fde3a8de48e79be4c1c40d8a68370c728b92a94332ec"+ "hash": "7245c15f8766cf7f511fa11cf0a43e61ed6d4ff1eb25bd94a2870cc762a33f78"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-7c27ef41f565e0275493e8f6047bde2baf27edcae4ae04e675708963bef5f08f.json b/rust/cloud-storage/macro_db_client/.sqlx/query-7c27ef41f565e0275493e8f6047bde2baf27edcae4ae04e675708963bef5f08f.jsondeleted file mode 100644index fe0da60feb..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-7c27ef41f565e0275493e8f6047bde2baf27edcae4ae04e675708963bef5f08f.json+++ /dev/null@@ -1,106 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH PinnedItems AS (\n SELECT\n p.\"pinnedItemId\" as pin_item_id,\n p.\"pinnedItemType\" as pin_item_type,\n p.\"pinIndex\" as pin_index\n FROM \"Pin\" p\n WHERE p.\"userId\" = $1\n ), Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"projectId\" as \"project_id\",\n di.sha as \"sha\",\n NULL as \"is_persistent\",\n pi.pin_index as \"pin_index\"\n FROM \"Document\" d\n INNER JOIN PinnedItems pi ON pi.pin_item_id = d.id AND pi.pin_item_type = 'document'\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON true\n UNION ALL\n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at\",\n c.\"updatedAt\"::timestamptz as \"updated_at\",\n c.\"projectId\" as \"project_id\",\n NULL as \"sha\",\n c.\"isPersistent\" as \"is_persistent\",\n pi.pin_index as \"pin_index\"\n FROM \"Chat\" c\n INNER JOIN PinnedItems pi ON pi.pin_item_id = c.id AND pi.pin_item_type = 'chat'\n UNION ALL\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at\",\n p.\"updatedAt\"::timestamptz as \"updated_at\",\n p.\"parentId\" as \"project_id\",\n NULL as \"sha\",\n NULL as \"is_persistent\",\n pi.pin_index as \"pin_index\"\n FROM \"Project\" p\n INNER JOIN PinnedItems pi ON pi.pin_item_id = p.id AND pi.pin_item_type = 'project'\n )\n SELECT * FROM Combined\n ORDER BY pin_index ASC\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "item_type!",- "type_info": "Text"- },- {- "ordinal": 1,- "name": "id!",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "document_version_id",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "user_id!",- "type_info": "Text"- },- {- "ordinal": 4,- "name": "name!",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "branched_from_id",- "type_info": "Text"- },- {- "ordinal": 6,- "name": "branched_from_version_id",- "type_info": "Int8"- },- {- "ordinal": 7,- "name": "document_family_id",- "type_info": "Int8"- },- {- "ordinal": 8,- "name": "file_type",- "type_info": "Text"- },- {- "ordinal": 9,- "name": "created_at",- "type_info": "Timestamptz"- },- {- "ordinal": 10,- "name": "updated_at",- "type_info": "Timestamptz"- },- {- "ordinal": 11,- "name": "project_id",- "type_info": "Text"- },- {- "ordinal": 12,- "name": "sha",- "type_info": "Text"- },- {- "ordinal": 13,- "name": "is_persistent",- "type_info": "Bool"- },- {- "ordinal": 14,- "name": "pin_index",- "type_info": "Int4"- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "7c27ef41f565e0275493e8f6047bde2baf27edcae4ae04e675708963bef5f08f"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-7756867bf7e7a0530c155ad9f266f7416f8f40ade686ea78dabf97d4a3b77f65.json b/rust/cloud-storage/macro_db_client/.sqlx/query-81900e6129d69cfb027846be355850b8a4183e3a3c8d767895c91379dde90e62.jsonsimilarity index 69%rename from rust/cloud-storage/macro_db_client/.sqlx/query-7756867bf7e7a0530c155ad9f266f7416f8f40ade686ea78dabf97d4a3b77f65.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-81900e6129d69cfb027846be355850b8a4183e3a3c8d767895c91379dde90e62.jsonindex 0f653d76af..1fb946a15b 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-7756867bf7e7a0530c155ad9f266f7416f8f40ade686ea78dabf97d4a3b77f65.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-81900e6129d69cfb027846be355850b8a4183e3a3c8d767895c91379dde90e62.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n c.\"id\" as \"item_id!\",\n c.\"owner\" as \"owner\",\n c.\"fileType\" as \"file_type\",\n c.\"name\" as \"file_name\",\n c.\"createdAt\" as \"created_at!\",\n c.\"updatedAt\" as \"updated_at!\",\n c.\"deletedAt\" as \"deleted_at?\",\n uh.\"updatedAt\" as \"viewed_at?\",\n c.\"projectId\" as \"project_id?\"\n FROM\n \"Document\" c\n LEFT JOIN\n \"UserHistory\" uh ON uh.\"itemId\" = c.\"id\"\n AND uh.\"userId\" = $1\n AND uh.\"itemType\" = 'document'\n WHERE\n c.\"id\" = ANY($2)\n ORDER BY\n c.\"updatedAt\" DESC\n ",+ "query": "\n SELECT\n c.\"id\" as \"item_id!\",\n c.\"owner\" as \"owner\",\n c.\"fileType\" as \"file_type\",\n c.\"name\" as \"file_name\",\n c.\"createdAt\" as \"created_at!\",\n c.\"updatedAt\" as \"updated_at!\",\n c.\"deletedAt\" as \"deleted_at?\",\n uh.\"updatedAt\" as \"viewed_at?\",\n c.\"projectId\" as \"project_id?\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM\n \"Document\" c\n LEFT JOIN document_task dt ON dt.document_id = c.id\n LEFT JOIN\n \"UserHistory\" uh ON uh.\"itemId\" = c.\"id\"\n AND uh.\"userId\" = $1\n AND uh.\"itemType\" = 'document'\n WHERE\n c.\"id\" = ANY($2)\n ORDER BY\n c.\"updatedAt\" DESC\n ","describe": {"columns": [{@@ -47,6 +47,11 @@"ordinal": 8,"name": "project_id?","type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "is_task!",+ "type_info": "Bool"}],"parameters": {@@ -64,8 +69,9 @@false,true,false,- true+ true,+ null]},- "hash": "7756867bf7e7a0530c155ad9f266f7416f8f40ade686ea78dabf97d4a3b77f65"+ "hash": "81900e6129d69cfb027846be355850b8a4183e3a3c8d767895c91379dde90e62"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-bdf007b9a0df2ea5463e92c0f32afbfe820d2ecdfdd53cef99423a3e2f288cd8.json b/rust/cloud-storage/macro_db_client/.sqlx/query-bdf007b9a0df2ea5463e92c0f32afbfe820d2ecdfdd53cef99423a3e2f288cd8.jsonnew file mode 100644index 0000000000..9883669606--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-bdf007b9a0df2ea5463e92c0f32afbfe820d2ecdfdd53cef99423a3e2f288cd8.json@@ -0,0 +1,88 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"deletedAt\"::timestamptz as \"deleted_at\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT\n i.id\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON true\n WHERE d.owner = $1 AND d.\"deletedAt\" IS NOT NULL\n UNION ALL\n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at\",\n c.\"updatedAt\"::timestamptz as \"updated_at\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n false as \"is_task\"\n FROM \"Chat\" c\n WHERE c.\"userId\" = $1 AND c.\"deletedAt\" IS NOT NULL\n UNION ALL\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at\",\n p.\"updatedAt\"::timestamptz as \"updated_at\",\n p.\"deletedAt\"::timestamptz as \"deleted_at\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n false as \"is_task\"\n FROM \"Project\" p\n WHERE p.\"userId\" = $1 AND p.\"deletedAt\" IS NOT NULL\n ORDER BY deleted_at DESC\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "item_type!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "id!",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "document_version_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "user_id!",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "name!",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 7,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 8,+ "name": "deleted_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 9,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 10,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 11,+ "name": "is_task!",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "bdf007b9a0df2ea5463e92c0f32afbfe820d2ecdfdd53cef99423a3e2f288cd8"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-c4106ef98c8dc34111487de73c4cfaa25b1a65792cd1c5cf14b7f1d86a951567.json b/rust/cloud-storage/macro_db_client/.sqlx/query-c4106ef98c8dc34111487de73c4cfaa25b1a65792cd1c5cf14b7f1d86a951567.jsondeleted file mode 100644index 088491ac08..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-c4106ef98c8dc34111487de73c4cfaa25b1a65792cd1c5cf14b7f1d86a951567.json+++ /dev/null@@ -1,106 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH UserHistories AS (\n SELECT\n h.\"itemId\" as item_id,\n h.\"itemType\" as item_type\n FROM \"UserHistory\" h\n WHERE h.\"userId\" = $1\n ), Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"projectId\" as \"project_id\",\n d.\"deletedAt\"::timestamptz as \"deleted_at\",\n NULL as \"is_persistent\",\n di.sha as \"sha\"\n FROM \"Document\" d\n INNER JOIN UserHistories uh ON uh.item_id = d.id AND uh.item_type = 'document'\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON true\n UNION ALL\n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at\",\n c.\"updatedAt\"::timestamptz as \"updated_at\",\n c.\"projectId\" as \"project_id\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\"\n FROM \"Chat\" c\n INNER JOIN UserHistories uh ON uh.item_id = c.id AND uh.item_type = 'chat'\n UNION ALL\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at\",\n p.\"updatedAt\"::timestamptz as \"updated_at\",\n p.\"parentId\" as \"project_id\",\n p.\"deletedAt\"::timestamptz as \"deleted_at\",\n NULL as \"is_persistent\",\n NULL as \"sha\"\n FROM \"Project\" p\n INNER JOIN UserHistories uh ON uh.item_id = p.id AND uh.item_type = 'project'\n )\n SELECT * FROM Combined\n ORDER BY updated_at DESC\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "item_type!",- "type_info": "Text"- },- {- "ordinal": 1,- "name": "id!",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "document_version_id",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "user_id!",- "type_info": "Text"- },- {- "ordinal": 4,- "name": "name!",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "branched_from_id",- "type_info": "Text"- },- {- "ordinal": 6,- "name": "branched_from_version_id",- "type_info": "Int8"- },- {- "ordinal": 7,- "name": "document_family_id",- "type_info": "Int8"- },- {- "ordinal": 8,- "name": "file_type",- "type_info": "Text"- },- {- "ordinal": 9,- "name": "created_at",- "type_info": "Timestamptz"- },- {- "ordinal": 10,- "name": "updated_at",- "type_info": "Timestamptz"- },- {- "ordinal": 11,- "name": "project_id",- "type_info": "Text"- },- {- "ordinal": 12,- "name": "deleted_at",- "type_info": "Timestamptz"- },- {- "ordinal": 13,- "name": "is_persistent",- "type_info": "Bool"- },- {- "ordinal": 14,- "name": "sha",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "c4106ef98c8dc34111487de73c4cfaa25b1a65792cd1c5cf14b7f1d86a951567"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-00b05287f77baebb2155e5297a617132165dd9f297b036927a876cb20e2b3371.json b/rust/cloud-storage/macro_db_client/.sqlx/query-cd03404aa4732898d67a1d88abd2e11691b9647640780c5d5c26e4e399c7a8d5.jsonsimilarity index 72%rename from rust/cloud-storage/macro_db_client/.sqlx/query-00b05287f77baebb2155e5297a617132165dd9f297b036927a876cb20e2b3371.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-cd03404aa4732898d67a1d88abd2e11691b9647640780c5d5c26e4e399c7a8d5.jsonindex efdcf0071b..bd2ce31111 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-00b05287f77baebb2155e5297a617132165dd9f297b036927a876cb20e2b3371.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-cd03404aa4732898d67a1d88abd2e11691b9647640780c5d5c26e4e399c7a8d5.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n d.id as document_id,\n d.name as document_name,\n d.\"fileType\" as file_type,\n d.owner as owner,\n d.\"updatedAt\"::timestamptz as \"updated_at\"\n FROM \"Document\" d\n WHERE\n d.\"id\" = ANY($1)\n ",+ "query": "\n SELECT\n d.id as document_id,\n d.name as document_name,\n d.\"fileType\" as file_type,\n d.owner as owner,\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n WHERE\n d.\"id\" = ANY($1)\n ","describe": {"columns": [{@@ -27,6 +27,11 @@"ordinal": 4,"name": "updated_at","type_info": "Timestamptz"+ },+ {+ "ordinal": 5,+ "name": "is_task!",+ "type_info": "Bool"}],"parameters": {@@ -39,8 +44,9 @@false,true,false,+ null,null]},- "hash": "00b05287f77baebb2155e5297a617132165dd9f297b036927a876cb20e2b3371"+ "hash": "cd03404aa4732898d67a1d88abd2e11691b9647640780c5d5c26e4e399c7a8d5"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-d3cad313940f62e92c58011860b89ea382239b9cf86f5d24779814361aface7d.json b/rust/cloud-storage/macro_db_client/.sqlx/query-d3cad313940f62e92c58011860b89ea382239b9cf86f5d24779814361aface7d.jsonnew file mode 100644index 0000000000..9e4898540b--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-d3cad313940f62e92c58011860b89ea382239b9cf86f5d24779814361aface7d.json@@ -0,0 +1,112 @@+{+ "db_name": "PostgreSQL",+ "query": "\n WITH PinnedItems AS (\n SELECT\n p.\"pinnedItemId\" as pin_item_id,\n p.\"pinnedItemType\" as pin_item_type,\n p.\"pinIndex\" as pin_index\n FROM \"Pin\" p\n WHERE p.\"userId\" = $1\n ), Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"projectId\" as \"project_id\",\n di.sha as \"sha\",\n NULL as \"is_persistent\",\n (dt.document_id IS NOT NULL) as \"is_task!\",\n pi.pin_index as \"pin_index\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n INNER JOIN PinnedItems pi ON pi.pin_item_id = d.id AND pi.pin_item_type = 'document'\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON true\n UNION ALL\n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at\",\n c.\"updatedAt\"::timestamptz as \"updated_at\",\n c.\"projectId\" as \"project_id\",\n NULL as \"sha\",\n c.\"isPersistent\" as \"is_persistent\",\n false as \"is_task\",\n pi.pin_index as \"pin_index\"\n FROM \"Chat\" c\n INNER JOIN PinnedItems pi ON pi.pin_item_id = c.id AND pi.pin_item_type = 'chat'\n UNION ALL\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at\",\n p.\"updatedAt\"::timestamptz as \"updated_at\",\n p.\"parentId\" as \"project_id\",\n NULL as \"sha\",\n NULL as \"is_persistent\",\n false as \"is_task\",\n pi.pin_index as \"pin_index\"\n FROM \"Project\" p\n INNER JOIN PinnedItems pi ON pi.pin_item_id = p.id AND pi.pin_item_type = 'project'\n )\n SELECT * FROM Combined\n ORDER BY pin_index ASC\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "item_type!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "id!",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "document_version_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "user_id!",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "name!",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "branched_from_id",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "branched_from_version_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 7,+ "name": "document_family_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 8,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 10,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 11,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "sha",+ "type_info": "Text"+ },+ {+ "ordinal": 13,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 14,+ "name": "is_task!",+ "type_info": "Bool"+ },+ {+ "ordinal": 15,+ "name": "pin_index",+ "type_info": "Int4"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "d3cad313940f62e92c58011860b89ea382239b9cf86f5d24779814361aface7d"+}diff --git a/rust/cloud-storage/macro_db_client/src/activity/get_recent_activities.rs b/rust/cloud-storage/macro_db_client/src/activity/get_recent_activities.rsindex b64e4c89e2..9596019ecf 100644--- a/rust/cloud-storage/macro_db_client/src/activity/get_recent_activities.rs+++ b/rust/cloud-storage/macro_db_client/src/activity/get_recent_activities.rs@@ -55,9 +55,11 @@ pub async fn get_recent_activities(d."updatedAt"::timestamptz as "updated_at",d."projectId" as "project_id",NULL as "is_persistent",- di.sha as "sha"+ di.sha as "sha",+ (dt.document_id IS NOT NULL) as "is_task"FROM"Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTb.id@@ -101,7 +103,8 @@ pub async fn get_recent_activities(c."updatedAt"::timestamptz as "updated_at",c."projectId" as "project_id",c."isPersistent" as "is_persistent",- NULL as "sha"+ NULL as "sha",+ false as "is_task!"FROM "Chat" cWHERE c."userId" = $1 AND c."deletedAt" IS NULLORDER BY updated_at DESC@@ -125,6 +128,7 @@ pub async fn get_recent_activities(let created_at: Option<chrono::DateTime<chrono::Utc>> = r.get("created_at");let updated_at: Option<chrono::DateTime<chrono::Utc>> = r.get("updated_at");let project_id: Option<String> = r.get("project_id");+ let is_task: bool = r.get("is_task");match row_type.as_ref() {"document" => {@@ -143,6 +147,7 @@ pub async fn get_recent_activities(branched_from_id: r.get("branched_from_id"),branched_from_version_id: r.get("branched_from_version_id"),project_id,+ is_task,}))}"chat" => Some(Activity::Chat(Chat {diff --git a/rust/cloud-storage/macro_db_client/src/convert/mod.rs b/rust/cloud-storage/macro_db_client/src/convert/mod.rsindex 54c8745751..2d31dddd5a 100644--- a/rust/cloud-storage/macro_db_client/src/convert/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/convert/mod.rs@@ -92,6 +92,7 @@ pub async fn get_docx_files(branched_from_version_id: None,document_family_id: None,modification_data: None,+ is_task: false,}).fetch_all(db).await?;diff --git a/rust/cloud-storage/macro_db_client/src/document/copy_document/mod.rs b/rust/cloud-storage/macro_db_client/src/document/copy_document/mod.rsindex 4952aeaade..73da4a62c4 100644--- a/rust/cloud-storage/macro_db_client/src/document/copy_document/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/document/copy_document/mod.rs@@ -142,6 +142,7 @@ pub(in crate::document) async fn copy_docx_document(document_bom: Some(saved_bom_parts),created_at: document.created_at,updated_at: document.updated_at,+ is_task: false, // docx documents are not tasks})}@@ -249,6 +250,7 @@ pub(in crate::document) async fn copy_non_docx_document(modification_data: original_modification_data,created_at: document.created_at,updated_at: document.updated_at,+ is_task: false, // TODO: @daniel please update this when you add in task creation/copy})}@@ -277,6 +279,7 @@ mod tests {None,None,None,+ false,),"macro|[email protected]","new name",diff --git a/rust/cloud-storage/macro_db_client/src/document/create_blank_docx.rs b/rust/cloud-storage/macro_db_client/src/document/create_blank_docx.rsindex a447a609ea..ea02571504 100644--- a/rust/cloud-storage/macro_db_client/src/document/create_blank_docx.rs+++ b/rust/cloud-storage/macro_db_client/src/document/create_blank_docx.rs@@ -156,6 +156,7 @@ pub async fn create_blank_docx(modification_data: None,created_at: document_version.created_at,updated_at: document_version.updated_at,+ is_task: false, // docx documents are not tasks})}diff --git a/rust/cloud-storage/macro_db_client/src/document/create_document.rs b/rust/cloud-storage/macro_db_client/src/document/create_document.rsindex 597f9e43d7..8a486dcce1 100644--- a/rust/cloud-storage/macro_db_client/src/document/create_document.rs+++ b/rust/cloud-storage/macro_db_client/src/document/create_document.rs@@ -176,6 +176,8 @@ pub async fn create_document(project_name.as_deref(),document_version.created_at,document_version.updated_at,+ false, // TODO: @daniel please update this when you add in task creation in create document+ // endpoint))}diff --git a/rust/cloud-storage/macro_db_client/src/document/get_all_documents.rs b/rust/cloud-storage/macro_db_client/src/document/get_all_documents.rsindex 5ab340316c..e4141a2adb 100644--- a/rust/cloud-storage/macro_db_client/src/document/get_all_documents.rs+++ b/rust/cloud-storage/macro_db_client/src/document/get_all_documents.rs@@ -42,9 +42,11 @@ pub async fn get_all_documents(di.modification_data as "modification_data?",d."projectId" as "project_id?",p.name as "project_name?",- di.sha as "sha?"+ di.sha as "sha?",+ (dt.document_id IS NOT NULL) as "is_task!"FROM"Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTb.id,diff --git a/rust/cloud-storage/macro_db_client/src/document/get_document.rs b/rust/cloud-storage/macro_db_client/src/document/get_document.rsindex 9ba0187428..e375711f8b 100644--- a/rust/cloud-storage/macro_db_client/src/document/get_document.rs+++ b/rust/cloud-storage/macro_db_client/src/document/get_document.rs@@ -244,9 +244,11 @@ pub async fn get_document(di.modification_data as "modification_data?",d."projectId" as "project_id",p.name as "project_name?",- di.sha as "sha?"+ di.sha as "sha?",+ (dt.document_id IS NOT NULL) as "is_task!"FROM"Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTi.id,@@ -336,9 +338,11 @@ pub async fn get_document_version(di.modification_data as "modification_data?",d."projectId" as "project_id?",p.name as "project_name?",- di.sha as "sha?"+ di.sha as "sha?",+ (dt.document_id IS NOT NULL) as "is_task!"FROM"Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTi.id,diff --git a/rust/cloud-storage/macro_db_client/src/document/get_document_history.rs b/rust/cloud-storage/macro_db_client/src/document/get_document_history.rsindex 6d1b239ace..021fd40a76 100644--- a/rust/cloud-storage/macro_db_client/src/document/get_document_history.rs+++ b/rust/cloud-storage/macro_db_client/src/document/get_document_history.rs@@ -21,6 +21,8 @@ pub struct DocumentHistoryInfo {pub project_id: Option<String>,/// Deleted atpub deleted_at: Option<DateTime<Utc>>,+ /// Whether the document is a task+ pub is_task: bool,}/// Gets document history information including when a user last viewed each document@@ -46,9 +48,11 @@ pub async fn get_document_history_info(c."updatedAt" as "updated_at!",c."deletedAt" as "deleted_at?",uh."updatedAt" as "viewed_at?",- c."projectId" as "project_id?"+ c."projectId" as "project_id?",+ (dt.document_id IS NOT NULL) as "is_task!"FROM"Document" c+ LEFT JOIN document_task dt ON dt.document_id = c.idLEFT JOIN"UserHistory" uh ON uh."itemId" = c."id"AND uh."userId" = $1@@ -81,6 +85,7 @@ pub async fn get_document_history_info(deleted_at: row.deleted_at.map(|dt| DateTime::<Utc>::from_naive_utc_and_offset(dt, Utc)),+ is_task: row.is_task,};(row.item_id, info)})diff --git a/rust/cloud-storage/macro_db_client/src/document/get_user_documents.rs b/rust/cloud-storage/macro_db_client/src/document/get_user_documents.rsindex 5f735368ab..961cd2f017 100644--- a/rust/cloud-storage/macro_db_client/src/document/get_user_documents.rs+++ b/rust/cloud-storage/macro_db_client/src/document/get_user_documents.rs@@ -106,9 +106,11 @@ pub async fn get_user_documents(di.modification_data as "modification_data",d."projectId" as "project_id",p.name as "project_name",- di.sha as "sha"+ di.sha as "sha",+ (dt.document_id IS NOT NULL) as "is_task"FROM"Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTb.id,diff --git a/rust/cloud-storage/macro_db_client/src/document/initialize_onboarding_documents.rs b/rust/cloud-storage/macro_db_client/src/document/initialize_onboarding_documents.rsindex 1a3a4e0846..b2ef8dfa26 100644--- a/rust/cloud-storage/macro_db_client/src/document/initialize_onboarding_documents.rs+++ b/rust/cloud-storage/macro_db_client/src/document/initialize_onboarding_documents.rs@@ -155,6 +155,7 @@ pub async fn create_onboarding_documents(created_at: None,updated_at: None,deleted_at: None,+ is_task: false,});});@@ -218,5 +219,6 @@ pub async fn create_onboarding_docx(created_at: None,updated_at: None,deleted_at: None,+ is_task: false,})}diff --git a/rust/cloud-storage/macro_db_client/src/document/preview.rs b/rust/cloud-storage/macro_db_client/src/document/preview.rsindex 275d87990b..5c28fce262 100644--- a/rust/cloud-storage/macro_db_client/src/document/preview.rs+++ b/rust/cloud-storage/macro_db_client/src/document/preview.rs@@ -15,8 +15,10 @@ pub async fn batch_get_document_preview_v2(d.name as document_name,d."fileType" as file_type,d.owner as owner,- d."updatedAt"::timestamptz as "updated_at"+ d."updatedAt"::timestamptz as "updated_at",+ (dt.document_id IS NOT NULL) as "is_task!"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idWHEREd."id" = ANY($1)"#,diff --git a/rust/cloud-storage/macro_db_client/src/document/save_document.rs b/rust/cloud-storage/macro_db_client/src/document/save_document.rsindex 3f79b44ad8..52d5e90767 100644--- a/rust/cloud-storage/macro_db_client/src/document/save_document.rs+++ b/rust/cloud-storage/macro_db_client/src/document/save_document.rs@@ -562,6 +562,15 @@ pub async fn save_document(}};+ let is_task = sqlx::query!(+ r#"+ SELECT document_id FROM document_task WHERE document_id = $1+ "#,+ document_id+ )+ .fetch_optional(&mut *transaction)+ .await?;+if let Err(err) = transaction.commit().await {tracing::error!(error=?err, "unable to commit transaction");return Err(err.into());@@ -583,6 +592,7 @@ pub async fn save_document(project_name,created_at: document_version.created_at,updated_at: document_version.updated_at,+ is_task: is_task.is_some(),})}diff --git a/rust/cloud-storage/macro_db_client/src/document/v2/create.rs b/rust/cloud-storage/macro_db_client/src/document/v2/create.rsindex 4e8d5070d3..1f34b44e73 100644--- a/rust/cloud-storage/macro_db_client/src/document/v2/create.rs+++ b/rust/cloud-storage/macro_db_client/src/document/v2/create.rs@@ -207,6 +207,7 @@ pub async fn create_document_txn(project_name,document_version.created_at,document_version.updated_at,+ false, // TODO: @daniel please update this when you add in task creation in create document))}diff --git a/rust/cloud-storage/macro_db_client/src/history/mod.rs b/rust/cloud-storage/macro_db_client/src/history/mod.rsindex a7b214e95a..494e955ac4 100644--- a/rust/cloud-storage/macro_db_client/src/history/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/history/mod.rs@@ -36,8 +36,10 @@ pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::Resd."projectId" as "project_id",d."deletedAt"::timestamptz as "deleted_at",NULL as "is_persistent",- di.sha as "sha"+ di.sha as "sha",+ (dt.document_id IS NOT NULL) as "is_task!"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idINNER JOIN UserHistories uh ON uh.item_id = d.id AND uh.item_type = 'document'LEFT JOIN LATERAL (SELECT@@ -81,7 +83,8 @@ pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::Resc."projectId" as "project_id",c."deletedAt"::timestamptz as "deleted_at",c."isPersistent" as "is_persistent",- NULL as "sha"+ NULL as "sha",+ false as "is_task"FROM "Chat" cINNER JOIN UserHistories uh ON uh.item_id = c.id AND uh.item_type = 'chat'UNION ALL@@ -100,7 +103,8 @@ pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::Resp."parentId" as "project_id",p."deletedAt"::timestamptz as "deleted_at",NULL as "is_persistent",- NULL as "sha"+ NULL as "sha",+ false as "is_task"FROM "Project" pINNER JOIN UserHistories uh ON uh.item_id = p.id AND uh.item_type = 'project')@@ -125,6 +129,7 @@ pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::Resr.branched_from_id,r.branched_from_version_id,r.project_id,+ r.is_task,).map_err(|e| sqlx::Error::TypeNotFound {type_name: e.to_string(),diff --git a/rust/cloud-storage/macro_db_client/src/pins/mod.rs b/rust/cloud-storage/macro_db_client/src/pins/mod.rsindex 01e6916403..e9265afadf 100644--- a/rust/cloud-storage/macro_db_client/src/pins/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/pins/mod.rs@@ -79,8 +79,10 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Pd."projectId" as "project_id",di.sha as "sha",NULL as "is_persistent",+ (dt.document_id IS NOT NULL) as "is_task!",pi.pin_index as "pin_index"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idINNER JOIN PinnedItems pi ON pi.pin_item_id = d.id AND pi.pin_item_type = 'document'LEFT JOIN LATERAL (SELECT@@ -124,6 +126,7 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Pc."projectId" as "project_id",NULL as "sha",c."isPersistent" as "is_persistent",+ false as "is_task",pi.pin_index as "pin_index"FROM "Chat" cINNER JOIN PinnedItems pi ON pi.pin_item_id = c.id AND pi.pin_item_type = 'chat'@@ -143,6 +146,7 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Pp."parentId" as "project_id",NULL as "sha",NULL as "is_persistent",+ false as "is_task",pi.pin_index as "pin_index"FROM "Project" pINNER JOIN PinnedItems pi ON pi.pin_item_id = p.id AND pi.pin_item_type = 'project'@@ -174,6 +178,7 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Pr.branched_from_id,r.branched_from_version_id,r.project_id,+ r.is_task,).map_err(|e| sqlx::Error::TypeNotFound {type_name: e.to_string(),diff --git a/rust/cloud-storage/macro_db_client/src/projects/get_project/get_sub_items.rs b/rust/cloud-storage/macro_db_client/src/projects/get_project/get_sub_items.rsindex 18618d38ac..69d4e78861 100644--- a/rust/cloud-storage/macro_db_client/src/projects/get_project/get_sub_items.rs+++ b/rust/cloud-storage/macro_db_client/src/projects/get_project/get_sub_items.rs@@ -84,9 +84,11 @@ pub async fn get_sub_documents(d."fileType" as "file_type?",d."createdAt"::timestamptz as created_at,d."updatedAt"::timestamptz as updated_at,- d."projectId" as "project_id?"+ d."projectId" as "project_id?",+ (dt.document_id IS NOT NULL) as "is_task!"FROM"Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTb.id@@ -131,6 +133,7 @@ pub async fn get_sub_documents(created_at: row.created_at,updated_at: row.updated_at,deleted_at: None, // Don't care about the deleted_at+ is_task: row.is_task,}}).fetch_all(transaction.as_mut())diff --git a/rust/cloud-storage/macro_db_client/src/recents/deleted.rs b/rust/cloud-storage/macro_db_client/src/recents/deleted.rsindex dff1016ecd..8b1519d5fd 100644--- a/rust/cloud-storage/macro_db_client/src/recents/deleted.rs+++ b/rust/cloud-storage/macro_db_client/src/recents/deleted.rs@@ -24,8 +24,10 @@ pub async fn get_recently_deleted(d."updatedAt"::timestamptz as "updated_at",d."deletedAt"::timestamptz as "deleted_at",d."projectId" as "project_id",- NULL as "is_persistent"+ NULL as "is_persistent",+ (dt.document_id IS NOT NULL) as "is_task!"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTb.id@@ -61,7 +63,8 @@ pub async fn get_recently_deleted(c."updatedAt"::timestamptz as "updated_at",c."deletedAt"::timestamptz as "deleted_at",c."projectId" as "project_id",- c."isPersistent" as "is_persistent"+ c."isPersistent" as "is_persistent",+ false as "is_task"FROM "Chat" cWHERE c."userId" = $1 AND c."deletedAt" IS NOT NULLUNION ALL@@ -76,7 +79,8 @@ pub async fn get_recently_deleted(p."updatedAt"::timestamptz as "updated_at",p."deletedAt"::timestamptz as "deleted_at",p."parentId" as "project_id",- NULL as "is_persistent"+ NULL as "is_persistent",+ false as "is_task"FROM "Project" pWHERE p."userId" = $1 AND p."deletedAt" IS NOT NULLORDER BY deleted_at DESC@@ -99,6 +103,7 @@ pub async fn get_recently_deleted(None, // don't care about branched_from_idNone, // don't care about branched_from_version_idr.project_id,+ r.is_task,).map_err(|e| sqlx::Error::TypeNotFound {type_name: e.to_string(),diff --git a/rust/cloud-storage/model-entity/src/lib.rs b/rust/cloud-storage/model-entity/src/lib.rsindex 80a1f6140a..9b43f24984 100644--- a/rust/cloud-storage/model-entity/src/lib.rs+++ b/rust/cloud-storage/model-entity/src/lib.rs@@ -38,7 +38,7 @@ pub enum EntityType {Chat,/// The entity is a channel (slack-like) conversationChannel,- /// The entity is a markdown document+ /// The entity is a documentDocument,/// The entity is a collection of other entitiesProject,diff --git a/rust/cloud-storage/model/src/activity/map_item.rs b/rust/cloud-storage/model/src/activity/map_item.rsindex 23a51e4d0b..03fa42ce55 100644--- a/rust/cloud-storage/model/src/activity/map_item.rs+++ b/rust/cloud-storage/model/src/activity/map_item.rs@@ -17,6 +17,7 @@ pub fn map_document_item(branched_from_id: Option<String>,branched_from_version_id: Option<i64>,project_id: Option<String>,+ is_task: bool,) -> anyhow::Result<BasicDocument> {Ok(BasicDocument {document_id: id,@@ -32,6 +33,7 @@ pub fn map_document_item(branched_from_id,branched_from_version_id,project_id,+ is_task,})}diff --git a/rust/cloud-storage/model/src/document/mod.rs b/rust/cloud-storage/model/src/document/mod.rsindex 1630f739b0..f07669cd7f 100644--- a/rust/cloud-storage/model/src/document/mod.rs+++ b/rust/cloud-storage/model/src/document/mod.rs@@ -84,6 +84,10 @@ pub struct BasicDocument {#[serde(skip_serializing_if = "Option::is_none", with = "ts_seconds_option")]#[schema(value_type = i64, nullable=true)]pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,++ /// Whether or not the document is a task.+ /// This is only applicable for md documents.+ pub is_task: bool,}#[derive(sqlx::FromRow, serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone)]@@ -176,6 +180,10 @@ pub struct DocumentMetadata {#[serde(with = "ts_seconds_option")]#[schema(value_type = i64, nullable=false)]pub updated_at: Option<chrono::DateTime<chrono::Utc>>,++ /// Whether or not the document is a task.+ /// This is only applicable for md documents.+ pub is_task: bool,}impl DocumentMetadata {@@ -213,6 +221,7 @@ impl DocumentMetadata {project_name,created_at,updated_at,+ is_task: false,}}@@ -235,6 +244,7 @@ impl DocumentMetadata {project_name: Option<&str>,created_at: Option<chrono::DateTime<chrono::Utc>>,updated_at: Option<chrono::DateTime<chrono::Utc>>,+ is_task: bool,) -> Self {Self {document_id: document_id.to_string(),@@ -252,6 +262,7 @@ impl DocumentMetadata {project_name: project_name.map(|s| s.to_string()),created_at,updated_at,+ is_task,}}@@ -274,6 +285,7 @@ impl DocumentMetadata {project_name: Option<String>,created_at: Option<chrono::DateTime<chrono::Utc>>,updated_at: Option<chrono::DateTime<chrono::Utc>>,+ is_task: bool,) -> Self {Self {document_id: document_id.to_string(),@@ -291,6 +303,7 @@ impl DocumentMetadata {project_name,created_at,updated_at,+ is_task,}}}@@ -320,6 +333,9 @@ pub struct DocumentPreviewData {#[serde(with = "ts_seconds_option")]#[schema(value_type = i64, nullable=false)]pub updated_at: Option<chrono::DateTime<chrono::Utc>>,+ /// Whether or not the document is a task.+ /// This is only applicable for md documents.+ pub is_task: bool,}#[derive(diff --git a/rust/cloud-storage/model/src/document/response/mod.rs b/rust/cloud-storage/model/src/document/response/mod.rsindex e53b4a29a9..82d535910b 100644--- a/rust/cloud-storage/model/src/document/response/mod.rs+++ b/rust/cloud-storage/model/src/document/response/mod.rs@@ -127,6 +127,9 @@ pub struct DocumentResponseMetadata {#[serde(with = "ts_seconds_option")]#[schema(value_type = i64, nullable=false)]pub updated_at: Option<chrono::DateTime<chrono::Utc>>,+ /// Whether or not the document is a task.+ /// This is only applicable for md documents.+ pub is_task: bool,}impl DocumentResponseMetadata {@@ -146,6 +149,7 @@ impl DocumentResponseMetadata {document_family_id: document_metadata.document_family_id,created_at: document_metadata.created_at,updated_at: document_metadata.updated_at,+ is_task: document_metadata.is_task,}}diff --git a/rust/cloud-storage/model/src/item/map_item.rs b/rust/cloud-storage/model/src/item/map_item.rsindex aea4958c42..870d6f08f5 100644--- a/rust/cloud-storage/model/src/item/map_item.rs+++ b/rust/cloud-storage/model/src/item/map_item.rs@@ -18,6 +18,7 @@ pub fn map_document_item(branched_from_id: Option<String>,branched_from_version_id: Option<i64>,project_id: Option<String>,+ is_task: bool,) -> anyhow::Result<BasicDocument> {Ok(BasicDocument {document_id: id,@@ -33,6 +34,7 @@ pub fn map_document_item(branched_from_id,branched_from_version_id,project_id,+ is_task,})}diff --git a/rust/cloud-storage/models_search/src/document.rs b/rust/cloud-storage/models_search/src/document.rsindex f65f7f734b..34934da490 100644--- a/rust/cloud-storage/models_search/src/document.rs+++ b/rust/cloud-storage/models_search/src/document.rs@@ -3,7 +3,7 @@ use schemars::JsonSchema;use serde::{Deserialize, Serialize};use utoipa::ToSchema;-use crate::{MatchType, SearchHighlight, SearchOn, SearchResponseItem};+use crate::{MatchType, SearchHighlight, SearchOn};/// A document match for a given node#[derive(Debug, Serialize, Deserialize, ToSchema)]@@ -31,13 +31,14 @@ pub struct DocumentSearchResponseItem {pub id: String,pub name: String,pub owner_id: String,-/// The id of the documentpub document_id: String,/// The name of the documentpub document_name: String,/// The file type of the documentpub file_type: Option<String>,+ /// Whether the document is a task+ pub is_task: bool,/// The search results for the document/// This may be empty if the search result match was on the document name onlypub document_search_results: Vec<DocumentSearchResult>,@@ -76,22 +77,6 @@ pub struct DocumentSearchMetadata {pub file_type: Option<String>,}-impl From<SearchResponseItem<DocumentSearchResult, DocumentSearchMetadata>>- for DocumentSearchResponseItem-{- fn from(response: SearchResponseItem<DocumentSearchResult, DocumentSearchMetadata>) -> Self {- DocumentSearchResponseItem {- id: response.metadata.document_id.clone(),- name: response.metadata.document_name.clone(),- document_id: response.metadata.document_id.clone(),- document_name: response.metadata.document_name,- owner_id: response.metadata.owner_id,- file_type: response.metadata.file_type,- document_search_results: response.results,- }- }-}-/// The document search response object#[derive(Debug, Serialize, Deserialize, ToSchema)]pub struct DocumentSearchResponse {diff --git a/rust/cloud-storage/models_soup/src/document.rs b/rust/cloud-storage/models_soup/src/document.rsindex 2209a687cf..8065b3e2ec 100644--- a/rust/cloud-storage/models_soup/src/document.rs+++ b/rust/cloud-storage/models_soup/src/document.rs@@ -61,4 +61,8 @@ pub struct SoupDocument {#[serde(with = "chrono::serde::ts_milliseconds_option")]#[cfg_attr(feature = "schema", schema(value_type = i64, nullable = true))]pub viewed_at: Option<chrono::DateTime<Utc>>,++ /// Whether or not the document is a task.+ /// This is only applicable for md documents.+ pub is_task: bool,}diff --git a/rust/cloud-storage/search_service/src/api/search/document.rs b/rust/cloud-storage/search_service/src/api/search/document.rsindex 4381d2e4f5..1d13d5af58 100644--- a/rust/cloud-storage/search_service/src/api/search/document.rs+++ b/rust/cloud-storage/search_service/src/api/search/document.rs@@ -154,6 +154,7 @@ pub fn construct_search_result(document_name: info.file_name,owner_id: info.owner,file_type: info.file_type,+ is_task: info.is_task,document_search_results: hits,},})diff --git a/rust/cloud-storage/search_service/src/api/search/document/test.rs b/rust/cloud-storage/search_service/src/api/search/document/test.rsindex 560d9fc3ea..6c598a16f7 100644--- a/rust/cloud-storage/search_service/src/api/search/document/test.rs+++ b/rust/cloud-storage/search_service/src/api/search/document/test.rs@@ -44,6 +44,7 @@ fn test_construct_search_result_single_document() {file_name: "Test Document".to_string(),owner: "user1".to_string(),deleted_at: None,+ is_task: false,},);@@ -123,6 +124,7 @@ fn test_construct_search_result_multiple_nodes_same_document() {owner: "user_1".to_string(),deleted_at: None,file_type: Some("pdf".to_string()),+ is_task: false,},);@@ -417,6 +419,7 @@ fn test_document_history_deleted() {file_type: Some("pdf".to_string()),owner: "user_1".to_string(),file_name: "name".to_string(),+ is_task: false,},);diff --git a/rust/cloud-storage/soup/.sqlx/query-52eff164a09a6b7a9eb2f1c7c64f9f5a0e5512f46b3ca607cd456aca66f42cbc.json b/rust/cloud-storage/soup/.sqlx/query-459855355e37d708a9d6118da102a4457168c72c972bbad8d4748a2cb269b0e5.jsonsimilarity index 62%rename from rust/cloud-storage/soup/.sqlx/query-52eff164a09a6b7a9eb2f1c7c64f9f5a0e5512f46b3ca607cd456aca66f42cbc.jsonrename to rust/cloud-storage/soup/.sqlx/query-459855355e37d708a9d6118da102a4457168c72c972bbad8d4748a2cb269b0e5.jsonindex 41dd4a5407..f52e6e3f78 100644--- a/rust/cloud-storage/soup/.sqlx/query-52eff164a09a6b7a9eb2f1c7c64f9f5a0e5512f46b3ca607cd456aca66f42cbc.json+++ b/rust/cloud-storage/soup/.sqlx/query-459855355e37d708a9d6118da102a4457168c72c972bbad8d4748a2cb269b0e5.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'\n -- This MUST be a LEFT JOIN to support all three sort methods\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = d.id AND uh.\"itemType\" = 'document' AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = c.id AND uh.\"itemType\" = 'chat' AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT Combined.* FROM Combined\n LEFT JOIN frecency_aggregates fa\n ON fa.entity_id = Combined.\"id!\"\n AND fa.entity_type = Combined.\"item_type!\"\n AND fa.user_id = $1\n WHERE fa.id IS NULL\n AND (\n ($4::timestamptz IS NULL)\n OR\n (Combined.\"sort_ts!\", Combined.\"id!\"::text) < ($4, $5)\n )\n ORDER BY Combined.\"sort_ts!\" DESC, Combined.\"updated_at!\" DESC\n LIMIT $3\n ",+ "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n (dt.document_id IS NOT NULL) as \"is_task!\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'\n -- This MUST be a LEFT JOIN to support all three sort methods\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = d.id AND uh.\"itemType\" = 'document' AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = c.id AND uh.\"itemType\" = 'chat' AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT Combined.* FROM Combined\n LEFT JOIN frecency_aggregates fa\n ON fa.entity_id = Combined.\"id!\"\n AND fa.entity_type = Combined.\"item_type!\"\n AND fa.user_id = $1\n WHERE fa.id IS NULL\n AND (\n ($4::timestamptz IS NULL)\n OR\n (Combined.\"sort_ts!\", Combined.\"id!\"::text) < ($4, $5)\n )\n ORDER BY Combined.\"sort_ts!\" DESC, Combined.\"updated_at!\" DESC\n LIMIT $3\n ","describe": {"columns": [{@@ -75,11 +75,16 @@},{"ordinal": 14,+ "name": "is_task!",+ "type_info": "Bool"+ },+ {+ "ordinal": 15,"name": "viewed_at","type_info": "Timestamptz"},{- "ordinal": 15,+ "ordinal": 16,"name": "sort_ts!","type_info": "Timestamptz"}@@ -109,8 +114,9 @@null,null,null,+ null,null]},- "hash": "52eff164a09a6b7a9eb2f1c7c64f9f5a0e5512f46b3ca607cd456aca66f42cbc"+ "hash": "459855355e37d708a9d6118da102a4457168c72c972bbad8d4748a2cb269b0e5"}diff --git a/rust/cloud-storage/soup/.sqlx/query-c620bfe9a68fc36c22cd7f8d023b030f8088ee62691a0c8128608801ef20900c.json b/rust/cloud-storage/soup/.sqlx/query-4636b3a76ef00d0fc743f3bff7ccd78991dc75ec953c61a96ef107df174b2a89.jsonsimilarity index 56%rename from rust/cloud-storage/soup/.sqlx/query-c620bfe9a68fc36c22cd7f8d023b030f8088ee62691a0c8128608801ef20900c.jsonrename to rust/cloud-storage/soup/.sqlx/query-4636b3a76ef00d0fc743f3bff7ccd78991dc75ec953c61a96ef107df174b2a89.jsonindex 0c9f3544b2..6206d8d77c 100644--- a/rust/cloud-storage/soup/.sqlx/query-c620bfe9a68fc36c22cd7f8d023b030f8088ee62691a0c8128608801ef20900c.json+++ b/rust/cloud-storage/soup/.sqlx/query-4636b3a76ef00d0fc743f3bff7ccd78991dc75ec953c61a96ef107df174b2a89.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT Combined.* FROM Combined\n LEFT JOIN frecency_aggregates fa\n ON fa.entity_id = Combined.\"id!\"\n AND fa.entity_type = Combined.\"item_type!\"\n AND fa.user_id = $1\n WHERE fa.id IS NULL\n AND (\n ($4::timestamptz IS NULL)\n OR\n (Combined.\"sort_ts!\", Combined.\"id!\") < ($4, $5)\n )\n ORDER BY Combined.\"sort_ts!\" DESC, Combined.\"updated_at!\" DESC\n LIMIT $3\n ",+ "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n (dt.document_id IS NOT NULL) as \"is_task!\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT Combined.* FROM Combined\n LEFT JOIN frecency_aggregates fa\n ON fa.entity_id = Combined.\"id!\"\n AND fa.entity_type = Combined.\"item_type!\"\n AND fa.user_id = $1\n WHERE fa.id IS NULL\n AND (\n ($4::timestamptz IS NULL)\n OR\n (Combined.\"sort_ts!\", Combined.\"id!\") < ($4, $5)\n )\n ORDER BY Combined.\"sort_ts!\" DESC, Combined.\"updated_at!\" DESC\n LIMIT $3\n ","describe": {"columns": [{@@ -75,11 +75,16 @@},{"ordinal": 14,+ "name": "is_task!",+ "type_info": "Bool"+ },+ {+ "ordinal": 15,"name": "viewed_at","type_info": "Timestamptz"},{- "ordinal": 15,+ "ordinal": 16,"name": "sort_ts!","type_info": "Timestamptz"}@@ -109,8 +114,9 @@null,null,null,+ null,null]},- "hash": "c620bfe9a68fc36c22cd7f8d023b030f8088ee62691a0c8128608801ef20900c"+ "hash": "4636b3a76ef00d0fc743f3bff7ccd78991dc75ec953c61a96ef107df174b2a89"}diff --git a/rust/cloud-storage/soup/.sqlx/query-b8e7abd96ea80bb45986ebb8e36f62af3852fe34b25058b3e79425def0ea0ebe.json b/rust/cloud-storage/soup/.sqlx/query-68e324da11741f98e638a23ba950e89f44afd3c4e26ee90e59904ea77bf1f981.jsonsimilarity index 64%rename from rust/cloud-storage/soup/.sqlx/query-b8e7abd96ea80bb45986ebb8e36f62af3852fe34b25058b3e79425def0ea0ebe.jsonrename to rust/cloud-storage/soup/.sqlx/query-68e324da11741f98e638a23ba950e89f44afd3c4e26ee90e59904ea77bf1f981.jsonindex 4cf296c7f6..608288bfdc 100644--- a/rust/cloud-storage/soup/.sqlx/query-b8e7abd96ea80bb45986ebb8e36f62af3852fe34b25058b3e79425def0ea0ebe.json+++ b/rust/cloud-storage/soup/.sqlx/query-68e324da11741f98e638a23ba950e89f44afd3c4e26ee90e59904ea77bf1f981.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'\n -- This MUST be a LEFT JOIN to support all three sort methods\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = d.id AND uh.\"itemType\" = 'document' AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = c.id AND uh.\"itemType\" = 'chat' AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT * FROM Combined\n WHERE\n ($4::timestamptz IS NULL)\n OR\n (\"sort_ts!\", \"id!\"::text) < ($4, $5)\n ORDER BY \"sort_ts!\" DESC, \"updated_at!\" DESC\n LIMIT $3\n",+ "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n (dt.document_id IS NOT NULL) as \"is_task!\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'\n -- This MUST be a LEFT JOIN to support all three sort methods\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = d.id AND uh.\"itemType\" = 'document' AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = c.id AND uh.\"itemType\" = 'chat' AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT * FROM Combined\n WHERE\n ($4::timestamptz IS NULL)\n OR\n (\"sort_ts!\", \"id!\"::text) < ($4, $5)\n ORDER BY \"sort_ts!\" DESC, \"updated_at!\" DESC\n LIMIT $3\n","describe": {"columns": [{@@ -75,11 +75,16 @@},{"ordinal": 14,+ "name": "is_task!",+ "type_info": "Bool"+ },+ {+ "ordinal": 15,"name": "viewed_at","type_info": "Timestamptz"},{- "ordinal": 15,+ "ordinal": 16,"name": "sort_ts!","type_info": "Timestamptz"}@@ -109,8 +114,9 @@null,null,null,+ null,null]},- "hash": "b8e7abd96ea80bb45986ebb8e36f62af3852fe34b25058b3e79425def0ea0ebe"+ "hash": "68e324da11741f98e638a23ba950e89f44afd3c4e26ee90e59904ea77bf1f981"}diff --git a/rust/cloud-storage/soup/.sqlx/query-495c575d60a26b458bc7c94a66e10634fd02cbd23eecc083108ab8326b73b38f.json b/rust/cloud-storage/soup/.sqlx/query-798bee060040707282eea0e9204b73f859ebb7de05deefba7f5e03019be71ee5.jsonsimilarity index 66%rename from rust/cloud-storage/soup/.sqlx/query-495c575d60a26b458bc7c94a66e10634fd02cbd23eecc083108ab8326b73b38f.jsonrename to rust/cloud-storage/soup/.sqlx/query-798bee060040707282eea0e9204b73f859ebb7de05deefba7f5e03019be71ee5.jsonindex c44322c582..a89c9bd33a 100644--- a/rust/cloud-storage/soup/.sqlx/query-495c575d60a26b458bc7c94a66e10634fd02cbd23eecc083108ab8326b73b38f.json+++ b/rust/cloud-storage/soup/.sqlx/query-798bee060040707282eea0e9204b73f859ebb7de05deefba7f5e03019be71ee5.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n d.\"updatedAt\"::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n AND d.id = ANY($2::text[])\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n c.\"updatedAt\"::timestamptz as \"sort_ts!\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n AND c.id = ANY($3::text[])\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n p.\"updatedAt\"::timestamptz as \"sort_ts!\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n AND p.id = ANY($4::text[])\n )\n SELECT * \n FROM Combined\n ",+ "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n (dt.document_id IS NOT NULL) as \"is_task!\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n d.\"updatedAt\"::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n AND d.id = ANY($2::text[])\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n c.\"updatedAt\"::timestamptz as \"sort_ts!\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n AND c.id = ANY($3::text[])\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n p.\"updatedAt\"::timestamptz as \"sort_ts!\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n AND p.id = ANY($4::text[])\n )\n SELECT * \n FROM Combined\n ","describe": {"columns": [{@@ -75,11 +75,16 @@},{"ordinal": 14,+ "name": "is_task!",+ "type_info": "Bool"+ },+ {+ "ordinal": 15,"name": "viewed_at","type_info": "Timestamptz"},{- "ordinal": 15,+ "ordinal": 16,"name": "sort_ts!","type_info": "Timestamptz"}@@ -108,8 +113,9 @@null,null,null,+ null,null]},- "hash": "495c575d60a26b458bc7c94a66e10634fd02cbd23eecc083108ab8326b73b38f"+ "hash": "798bee060040707282eea0e9204b73f859ebb7de05deefba7f5e03019be71ee5"}diff --git a/rust/cloud-storage/soup/.sqlx/query-c208856e2f2bec2528358118007f6092a068983036fc0c668f477e02cea6f2df.json b/rust/cloud-storage/soup/.sqlx/query-d3e11b3bf100dd1eb5fb77bc34d73a660f5e9cef395665bdd4e55a786261f2af.jsonsimilarity index 85%rename from rust/cloud-storage/soup/.sqlx/query-c208856e2f2bec2528358118007f6092a068983036fc0c668f477e02cea6f2df.jsonrename to rust/cloud-storage/soup/.sqlx/query-d3e11b3bf100dd1eb5fb77bc34d73a660f5e9cef395665bdd4e55a786261f2af.jsonindex 09c1c893ec..c500afa018 100644--- a/rust/cloud-storage/soup/.sqlx/query-c208856e2f2bec2528358118007f6092a068983036fc0c668f477e02cea6f2df.json+++ b/rust/cloud-storage/soup/.sqlx/query-d3e11b3bf100dd1eb5fb77bc34d73a660f5e9cef395665bdd4e55a786261f2af.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\"\n FROM \"Document\" d\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n AND d.id = ANY($2::text[])\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n AND c.id = ANY($3::text[])\n )\n SELECT * \n FROM Combined\n ",+ "query": "\n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n (dt.document_id IS NOT NULL) as \"is_task!\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n AND d.id = ANY($2::text[])\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n AND c.id = ANY($3::text[])\n )\n SELECT * \n FROM Combined\n ","describe": {"columns": [{@@ -75,6 +75,11 @@},{"ordinal": 14,+ "name": "is_task!",+ "type_info": "Bool"+ },+ {+ "ordinal": 15,"name": "viewed_at","type_info": "Timestamptz"}@@ -101,8 +106,9 @@null,null,null,+ null,null]},- "hash": "c208856e2f2bec2528358118007f6092a068983036fc0c668f477e02cea6f2df"+ "hash": "d3e11b3bf100dd1eb5fb77bc34d73a660f5e9cef395665bdd4e55a786261f2af"}diff --git a/rust/cloud-storage/soup/.sqlx/query-75bdff1c596b09d3937d4915ee3f3e733bbae5308e62b5fe952c5c02e0f03a78.json b/rust/cloud-storage/soup/.sqlx/query-d8658c4258ac6b3e9508a4c38b52c807d046220a7bd0db09e279ece161a586e6.jsonsimilarity index 58%rename from rust/cloud-storage/soup/.sqlx/query-75bdff1c596b09d3937d4915ee3f3e733bbae5308e62b5fe952c5c02e0f03a78.jsonrename to rust/cloud-storage/soup/.sqlx/query-d8658c4258ac6b3e9508a4c38b52c807d046220a7bd0db09e279ece161a586e6.jsonindex a8b662fe8f..b69959befc 100644--- a/rust/cloud-storage/soup/.sqlx/query-75bdff1c596b09d3937d4915ee3f3e733bbae5308e62b5fe952c5c02e0f03a78.json+++ b/rust/cloud-storage/soup/.sqlx/query-d8658c4258ac6b3e9508a4c38b52c807d046220a7bd0db09e279ece161a586e6.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT * \n FROM Combined\n WHERE ($4::timestamptz IS NULL)\n OR (\"sort_ts!\", \"id!\") < ($4, $5)\n ORDER BY \"sort_ts!\" DESC, \"updated_at!\" DESC\n LIMIT $3\n ",+ "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n (dt.document_id IS NOT NULL) as \"is_task!\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT * \n FROM Combined\n WHERE ($4::timestamptz IS NULL)\n OR (\"sort_ts!\", \"id!\") < ($4, $5)\n ORDER BY \"sort_ts!\" DESC, \"updated_at!\" DESC\n LIMIT $3\n ","describe": {"columns": [{@@ -75,11 +75,16 @@},{"ordinal": 14,+ "name": "is_task!",+ "type_info": "Bool"+ },+ {+ "ordinal": 15,"name": "viewed_at","type_info": "Timestamptz"},{- "ordinal": 15,+ "ordinal": 16,"name": "sort_ts!","type_info": "Timestamptz"}@@ -109,8 +114,9 @@null,null,null,+ null,null]},- "hash": "75bdff1c596b09d3937d4915ee3f3e733bbae5308e62b5fe952c5c02e0f03a78"+ "hash": "d8658c4258ac6b3e9508a4c38b52c807d046220a7bd0db09e279ece161a586e6"}diff --git a/rust/cloud-storage/soup/src/domain/service/tests.rs b/rust/cloud-storage/soup/src/domain/service/tests.rsindex 2b0284f820..35c8b6a178 100644--- a/rust/cloud-storage/soup/src/domain/service/tests.rs+++ b/rust/cloud-storage/soup/src/domain/service/tests.rs@@ -87,6 +87,7 @@ fn soup_document_uuid_with_updated(id: Uuid, updated_at: DateTime<Utc>) -> SoupDcreated_at: Default::default(),updated_at,viewed_at: Default::default(),+ is_task: false,}}diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rsindex abba68b325..01d7f0cfb5 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs@@ -167,6 +167,7 @@ macro_rules! map_soup_type {created_at: r.created_at,updated_at: r.updated_at,viewed_at: r.viewed_at,+ is_task: r.is_task,},)),"chat" => Ok(::models_soup::item::SoupItem::Chat(diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_cursor.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_cursor.rsindex 5a5be3e8fd..0a2e7d8635 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_cursor.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_cursor.rs@@ -86,6 +86,7 @@ r#"d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",+ (dt.document_id IS NOT NULL) as "is_task!",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", d."updatedAt")@@ -94,6 +95,7 @@ r#"ELSE d."updatedAt"END::timestamptz as "sort_ts!"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'-- This MUST be a LEFT JOIN to support all three sort methodsLEFT JOIN "UserHistory" uh ON uh."itemId" = d.id AND uh."itemType" = 'document' AND uh."userId" = $1@@ -130,6 +132,7 @@ r#"c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", c."updatedAt")@@ -159,6 +162,7 @@ r#"p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", p."updatedAt")@@ -270,6 +274,7 @@ r#"d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",+ (dt.document_id IS NOT NULL) as "is_task!",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", d."updatedAt")@@ -278,6 +283,7 @@ r#"ELSE d."updatedAt"END::timestamptz as "sort_ts!"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'-- This MUST be a LEFT JOIN to support all three sort methodsLEFT JOIN "UserHistory" uh ON uh."itemId" = d.id AND uh."itemType" = 'document' AND uh."userId" = $1@@ -314,6 +320,7 @@ r#"c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", c."updatedAt")@@ -343,6 +350,7 @@ r#"p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", p."updatedAt")diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_ids.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_ids.rsindex 06bc5f0894..6c1842569d 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_ids.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_ids.rs@@ -91,8 +91,10 @@ pub async fn expanded_soup_by_ids<'a>(d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",+ (dt.document_id IS NOT NULL) as "is_task!",uh."updatedAt"::timestamptz as "viewed_at"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -134,6 +136,7 @@ pub async fn expanded_soup_by_ids<'a>(c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at"FROM "Chat" cINNER JOIN UserAccessibleItems uaidiff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rsindex 15726c0c9c..c19810bd82 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs@@ -77,6 +77,7 @@ static DOCUMENT_CLAUSE: &str = r#"d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",+ (dt.document_id IS NOT NULL) as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", d."updatedAt")@@ -85,6 +86,7 @@ static DOCUMENT_CLAUSE: &str = r#"ELSE d."updatedAt"END::timestamptz as "sort_ts"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'-- This MUST be a LEFT JOIN to support all three sort methodsLEFT JOIN "UserHistory" uh ON uh."itemId" = d.id AND uh."itemType" = 'document' AND uh."userId" = $1@@ -121,6 +123,7 @@ static CHAT_CLAUSE: &str = r#"c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", c."updatedAt")@@ -150,6 +153,7 @@ static PROJECT_CLAUSE: &str = r#"p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", p."updatedAt")@@ -307,6 +311,7 @@ struct DocumentRow {created_at: DateTime<Utc>,updated_at: DateTime<Utc>,viewed_at: Option<DateTime<Utc>>,+ is_task: bool,}#[derive(Debug, FromRow)]@@ -371,6 +376,7 @@ impl SoupRow {created_at,updated_at,viewed_at,+ is_task,}) => SoupItem::Document(SoupDocument {id: Uuid::parse_str(&id).map_err(type_err)?,document_version_id: document_version_id@@ -397,6 +403,7 @@ impl SoupRow {created_at,updated_at,viewed_at,+ is_task,}),SoupRow::Chat(ChatRow {id,diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_cursor.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_cursor.rsindex 3e61e9c645..aa037b7ebe 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_cursor.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_cursor.rs@@ -58,6 +58,7 @@ pub async fn unexpanded_generic_cursor_soup(d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",+ (dt.document_id IS NOT NULL) as "is_task!",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", d."updatedAt")@@ -66,6 +67,7 @@ pub async fn unexpanded_generic_cursor_soup(ELSE d."updatedAt"END::timestamptz as "sort_ts!"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -106,6 +108,7 @@ pub async fn unexpanded_generic_cursor_soup(c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", c."updatedAt")@@ -140,6 +143,7 @@ pub async fn unexpanded_generic_cursor_soup(p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", p."updatedAt")@@ -228,6 +232,7 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",+ (dt.document_id IS NOT NULL) as "is_task!",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", d."updatedAt")@@ -236,6 +241,7 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(ELSE d."updatedAt"END::timestamptz as "sort_ts!"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -276,6 +282,7 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", c."updatedAt")@@ -310,6 +317,7 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", p."updatedAt")diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_ids.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_ids.rsindex 95d5a16637..f60cf1703a 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_ids.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_ids.rs@@ -66,9 +66,11 @@ pub async fn unexpanded_soup_by_ids<'a>(d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",+ (dt.document_id IS NOT NULL) as "is_task!",uh."updatedAt"::timestamptz as "viewed_at",d."updatedAt"::timestamptz as "sort_ts!"FROM "Document" d+ LEFT JOIN document_task dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -110,6 +112,7 @@ pub async fn unexpanded_soup_by_ids<'a>(c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",c."updatedAt"::timestamptz as "sort_ts!"FROM "Chat" c@@ -140,6 +143,7 @@ pub async fn unexpanded_soup_by_ids<'a>(p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",+ false as "is_task",uh."updatedAt"::timestamptz as "viewed_at",p."updatedAt"::timestamptz as "sort_ts!"FROM "Project" pdiff --git a/rust/cloud-storage/sqlx.just b/rust/cloud-storage/sqlx.justindex 2531634025..5dc7da5f4a 100644--- a/rust/cloud-storage/sqlx.just+++ b/rust/cloud-storage/sqlx.just@@ -8,7 +8,7 @@ migrate_db $DATABASE_URL:[no-cd]prepare_db $DATABASE_URL *FLAGS:- cargo sqlx prepare -- {{ FLAGS }}+ cargo sqlx prepare -- {{ FLAGS }} --all-features[no-cd]drop_db $DATABASE_URL *FLAGS: