Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

6.4 KB
Raw Blame
{
  "db_name": "PostgreSQL",
  "query": "\n            WITH source_ids AS (\n                SELECT DISTINCT stored_for_id, stored_for_auth_entity\n                FROM UNNEST($1::text[], $2::text[])\n                    AS source_rows(stored_for_id, stored_for_auth_entity)\n            ),\n            deduped AS (\n                SELECT DISTINCT ON (fe.foreign_entity_source, fe.foreign_entity_id,\n                    CASE WHEN $13::uuid[] IS NOT NULL THEN fe.id END)\n                    fe.id,\n                    fe.foreign_entity_id,\n                    fe.foreign_entity_source,\n                    fe.metadata,\n                    fe.stored_for_id,\n                    fe.stored_for_auth_entity,\n                    fe.created_at,\n                    COALESCE(gpr.github_updated_at, fe.updated_at) AS updated_at,\n                    CASE $3::text\n                        WHEN 'created_at' THEN fe.created_at\n                        ELSE COALESCE(gpr.github_updated_at, fe.updated_at)\n                    END AS sort_at\n                FROM foreign_entity fe\n                LEFT JOIN github_pull_request gpr ON gpr.github_key = fe.foreign_entity_id\n                WHERE fe.foreign_entity_source = $10::text\n                  AND ($13::uuid[] IS NULL OR fe.id = ANY($13))\n                  AND EXISTS (\n                    SELECT 1\n                    FROM source_ids s\n                    WHERE s.stored_for_id = fe.stored_for_id\n                      AND s.stored_for_auth_entity = fe.stored_for_auth_entity\n                )\n                  AND (\n                    $4::text IS NULL\n                    OR jsonb_path_match(\n                        jsonb_build_object(\n                            'id', fe.id::text,\n                            'foreignEntityId', fe.foreign_entity_id,\n                            'foreignEntitySource', fe.foreign_entity_source\n                        ),\n                        ($4::text)::jsonpath\n                    )\n                  )\n                  AND (\n                    $11::text IS NULL\n                    OR (gpr.github_key IS NOT NULL AND jsonb_path_match(\n                        jsonb_build_object(\n                            'repositoryId', gpr.repository_id,\n                            'authorId', gpr.author_github_user_id,\n                            'status', gpr.status,\n                            'draft', gpr.draft,\n                            'requestedReviewers', to_jsonb(gpr.requested_reviewer_github_user_ids),\n                            'participants', to_jsonb(gpr.participant_github_user_ids),\n                            'assignees', jsonb_path_query_array(gpr.assignees, '$[*].githubUserId'),\n                            'labels', jsonb_path_query_array(gpr.labels, '$[*].name'),\n                            'reviewers', jsonb_path_query_array(gpr.reviews, '$[*].reviewerGithubUserId'),\n                            'reviewDecision', gpr.review_decision,\n                            'reviewCount', jsonb_array_length(gpr.reviews)\n                        ),\n                        ($11::text)::jsonpath\n                    ))\n                  )\n                  AND (\n                    $8::int[] IS NULL\n                    OR ($9::text IS NOT NULL AND (\n                        SELECT COALESCE(bit_or(CASE un.state\n                            WHEN 'unseen' THEN 1 WHEN 'seen' THEN 2 WHEN 'done' THEN 4 END), 0)\n                        FROM user_notification un\n                        WHERE un.user_id = $9::text\n                          AND un.deleted_at IS NULL\n                          AND un.event_item_type = 'foreign_entity'\n                          AND un.event_item_id = fe.id::text\n                    ) = ANY($8::int[]))\n                  )\n                ORDER BY\n                    fe.foreign_entity_source,\n                    fe.foreign_entity_id,\n                    CASE WHEN $13::uuid[] IS NOT NULL THEN fe.id END,\n                    sort_at DESC,\n                    fe.updated_at DESC,\n                    fe.id DESC\n            )\n            SELECT\n                id as \"id!: Uuid\",\n                foreign_entity_id as \"foreign_entity_id!: String\",\n                foreign_entity_source as \"foreign_entity_source!: String\",\n                metadata as \"metadata!: serde_json::Value\",\n                stored_for_id as \"stored_for_id!: String\",\n                stored_for_auth_entity as \"stored_for_auth_entity!: String\",\n                created_at as \"created_at!: DateTime<Utc>\",\n                updated_at as \"updated_at!: DateTime<Utc>\"\n            FROM deduped\n            WHERE $5::timestamptz IS NULL\n               OR ($12::bool AND (sort_at, id) > ($5::timestamptz, $6::uuid))\n               OR (NOT $12::bool AND (sort_at, id) < ($5::timestamptz, $6::uuid))\n            ORDER BY\n                CASE WHEN $12::bool THEN sort_at END ASC,\n                CASE WHEN $12::bool THEN id END ASC,\n                sort_at DESC,\n                id DESC\n            LIMIT $7\n            ",
  "describe": {
    "columns": [
      {
        "ordinal": 0,
        "name": "id!: Uuid",
        "type_info": "Uuid"
      },
      {
        "ordinal": 1,
        "name": "foreign_entity_id!: String",
        "type_info": "Text"
      },
      {
        "ordinal": 2,
        "name": "foreign_entity_source!: String",
        "type_info": "Text"
      },
      {
        "ordinal": 3,
        "name": "metadata!: serde_json::Value",
        "type_info": "Jsonb"
      },
      {
        "ordinal": 4,
        "name": "stored_for_id!: String",
        "type_info": "Text"
      },
      {
        "ordinal": 5,
        "name": "stored_for_auth_entity!: String",
        "type_info": "Text"
      },
      {
        "ordinal": 6,
        "name": "created_at!: DateTime<Utc>",
        "type_info": "Timestamptz"
      },
      {
        "ordinal": 7,
        "name": "updated_at!: DateTime<Utc>",
        "type_info": "Timestamptz"
      }
    ],
    "parameters": {
      "Left": [
        "TextArray",
        "TextArray",
        "Text",
        "Text",
        "Timestamptz",
        "Uuid",
        "Int8",
        "Int4Array",
        "Text",
        "Text",
        "Text",
        "Bool",
        "UuidArray"
      ]
    },
    "nullable": [
      false,
      false,
      false,
      false,
      false,
      false,
      false,
      null
    ]
  },
  "hash": "32ca8ccd308eebdc3daf7555114ff2b980ff31abcbb28f99dcda7e8dee50c0f0"
}