diff --git a/Cargo.lock b/Cargo.lock index 7d0ff4bf4..51bcd7723 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -847,9 +847,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "es-entity" -version = "0.10.36" +version = "0.10.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffb4c045095c29c481e97358b072497865b0c45ff5ff23fdf57eaa069e59971" +checksum = "ddf124151df32af341cd82f3ca6e014c50ed948eae99f5380f84efeabf42e1a9" dependencies = [ "chrono", "derive_builder", @@ -872,9 +872,9 @@ dependencies = [ [[package]] name = "es-entity-macros" -version = "0.10.36" +version = "0.10.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1bb41f0f8f49452fa1ffd0377ddb180df35a8fcee7024a3d2a2974cd6c2d7e" +checksum = "cd38eb6d28a6e760303bc8b3940d9f114f9c49ec0bc01a02b226a73ea06d72a6" dependencies = [ "convert_case", "darling 0.23.0", diff --git a/Cargo.toml b/Cargo.toml index e0b715846..f353ebeda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ cala-types = { path = "cala-ledger-core-types", package = "cala-ledger-core-type cala-tracing = { path = "cala-tracing", version = "0.15.10-dev" } cala-ledger = { path = "cala-ledger", version = "0.15.10-dev" } -es-entity = "0.10.36" +es-entity = "0.10.37" job = { version = "0.6.25", features = ["es-entity"] } obix = { version = "0.2.27", default-features = false } diff --git a/cala-ledger/.sqlx/query-8dfaa15816547fecb125c30444481590b22abd0ed2199ecf0a099991850db17a.json b/cala-ledger/.sqlx/query-03994377e116e70dfd472474dcea39c895bf0d6815c035c397abf1fc5b44c069.json similarity index 79% rename from cala-ledger/.sqlx/query-8dfaa15816547fecb125c30444481590b22abd0ed2199ecf0a099991850db17a.json rename to cala-ledger/.sqlx/query-03994377e116e70dfd472474dcea39c895bf0d6815c035c397abf1fc5b44c069.json index 5a40d2f5b..79f019fc8 100644 --- a/cala-ledger/.sqlx/query-8dfaa15816547fecb125c30444481590b22abd0ed2199ecf0a099991850db17a.json +++ b/cala-ledger/.sqlx/query-03994377e116e70dfd472474dcea39c895bf0d6815c035c397abf1fc5b44c069.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n UPDATE job_executions\n SET state = 'pending', execute_at = $1, attempt_index = attempt_index + 1, poller_instance_id = NULL\n WHERE state = 'running' AND alive_at < $1::timestamptz\n AND job_type = ANY($2)\n AND poller_instance_id IS DISTINCT FROM $3\n RETURNING id as id\n ", + "query": "\n UPDATE job_executions\n SET state = 'pending', execute_at = $4, attempt_index = attempt_index + 1, poller_instance_id = NULL\n WHERE state = 'running' AND alive_at < $1::timestamptz\n AND job_type = ANY($2)\n AND poller_instance_id IS DISTINCT FROM $3\n RETURNING id as id\n ", "describe": { "columns": [ { @@ -13,12 +13,13 @@ "Left": [ "Timestamptz", "TextArray", - "Uuid" + "Uuid", + "Timestamptz" ] }, "nullable": [ false ] }, - "hash": "8dfaa15816547fecb125c30444481590b22abd0ed2199ecf0a099991850db17a" + "hash": "03994377e116e70dfd472474dcea39c895bf0d6815c035c397abf1fc5b44c069" } diff --git a/cala-ledger/.sqlx/query-446db9f053f56473bb1bfc0a86b626c0bb2b31d058f247151439a3f656b9de4e.json b/cala-ledger/.sqlx/query-60c8da85d099dfdd26af552bfc109d715d477118083ddabf96aa88ae1cb65c7c.json similarity index 94% rename from cala-ledger/.sqlx/query-446db9f053f56473bb1bfc0a86b626c0bb2b31d058f247151439a3f656b9de4e.json rename to cala-ledger/.sqlx/query-60c8da85d099dfdd26af552bfc109d715d477118083ddabf96aa88ae1cb65c7c.json index 55b83c2d1..82b5c2a21 100644 --- a/cala-ledger/.sqlx/query-446db9f053f56473bb1bfc0a86b626c0bb2b31d058f247151439a3f656b9de4e.json +++ b/cala-ledger/.sqlx/query-60c8da85d099dfdd26af552bfc109d715d477118083ddabf96aa88ae1cb65c7c.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n WITH eligible AS (\n SELECT id, queue_id, execute_at, execution_state_json, attempt_index\n FROM job_executions\n WHERE state = 'pending'\n AND job_type = ANY($4)\n AND NOT EXISTS (\n SELECT 1 FROM job_executions AS running\n WHERE running.state = 'running'\n AND running.queue_id IS NOT NULL\n AND running.queue_id = job_executions.queue_id\n )\n ),\n min_wait AS (\n SELECT MIN(execute_at) - $2::timestamptz AS wait_time\n FROM eligible\n WHERE execute_at > $2::timestamptz\n ),\n candidates AS (\n SELECT id, execution_state_json AS data_json, attempt_index,\n ROW_NUMBER() OVER (\n PARTITION BY COALESCE(queue_id, id::text)\n ORDER BY execute_at\n ) AS rn\n FROM eligible\n WHERE execute_at <= $2::timestamptz\n ),\n selected_jobs AS (\n SELECT je.id, c.data_json, c.attempt_index\n FROM candidates c\n JOIN job_executions je ON je.id = c.id\n WHERE c.rn = 1\n ORDER BY je.execute_at ASC\n LIMIT $1\n FOR UPDATE OF je\n ),\n updated AS (\n UPDATE job_executions AS je\n SET state = 'running', alive_at = $2, execute_at = NULL, poller_instance_id = $3\n FROM selected_jobs\n WHERE je.id = selected_jobs.id\n AND je.state = 'pending'\n RETURNING je.id, selected_jobs.data_json, je.attempt_index\n )\n SELECT * FROM (\n SELECT\n u.id AS \"id?: JobId\",\n u.data_json AS \"data_json?: JsonValue\",\n u.attempt_index AS \"attempt_index?\",\n NULL::INTERVAL AS \"max_wait?: PgInterval\"\n FROM updated u\n UNION ALL\n SELECT\n NULL::UUID AS \"id?: JobId\",\n NULL::JSONB AS \"data_json?: JsonValue\",\n NULL::INT AS \"attempt_index?\",\n mw.wait_time AS \"max_wait?: PgInterval\"\n FROM min_wait mw\n WHERE NOT EXISTS (SELECT 1 FROM updated)\n ) AS result\n ", + "query": "\n WITH eligible AS (\n SELECT id, queue_id, execute_at, execution_state_json, attempt_index\n FROM job_executions\n WHERE state = 'pending'\n AND job_type = ANY($4)\n AND NOT EXISTS (\n SELECT 1 FROM job_executions AS running\n WHERE running.state = 'running'\n AND running.queue_id IS NOT NULL\n AND running.queue_id = job_executions.queue_id\n )\n ),\n min_wait AS (\n SELECT MIN(execute_at) - $2::timestamptz AS wait_time\n FROM eligible\n WHERE execute_at > $2::timestamptz\n ),\n candidates AS (\n SELECT id, execution_state_json AS data_json, attempt_index,\n ROW_NUMBER() OVER (\n PARTITION BY COALESCE(queue_id, id::text)\n ORDER BY execute_at\n ) AS rn\n FROM eligible\n WHERE execute_at <= $2::timestamptz\n ),\n selected_jobs AS (\n SELECT je.id, c.data_json, c.attempt_index\n FROM candidates c\n JOIN job_executions je ON je.id = c.id\n WHERE c.rn = 1\n ORDER BY je.execute_at ASC\n LIMIT $1\n FOR UPDATE OF je\n ),\n updated AS (\n UPDATE job_executions AS je\n SET state = 'running', alive_at = $5, execute_at = NULL, poller_instance_id = $3\n FROM selected_jobs\n WHERE je.id = selected_jobs.id\n AND je.state = 'pending'\n RETURNING je.id, selected_jobs.data_json, je.attempt_index\n )\n SELECT * FROM (\n SELECT\n u.id AS \"id?: JobId\",\n u.data_json AS \"data_json?: JsonValue\",\n u.attempt_index AS \"attempt_index?\",\n NULL::INTERVAL AS \"max_wait?: PgInterval\"\n FROM updated u\n UNION ALL\n SELECT\n NULL::UUID AS \"id?: JobId\",\n NULL::JSONB AS \"data_json?: JsonValue\",\n NULL::INT AS \"attempt_index?\",\n mw.wait_time AS \"max_wait?: PgInterval\"\n FROM min_wait mw\n WHERE NOT EXISTS (SELECT 1 FROM updated)\n ) AS result\n ", "describe": { "columns": [ { @@ -29,7 +29,8 @@ "Int8", "Timestamptz", "Uuid", - "TextArray" + "TextArray", + "Timestamptz" ] }, "nullable": [ @@ -39,5 +40,5 @@ null ] }, - "hash": "446db9f053f56473bb1bfc0a86b626c0bb2b31d058f247151439a3f656b9de4e" + "hash": "60c8da85d099dfdd26af552bfc109d715d477118083ddabf96aa88ae1cb65c7c" } diff --git a/cala-ledger/.sqlx/query-af56d9b7a5a837d6427edb0e25b40de901697ff77c90fabd863bb54acf5ec5b9.json b/cala-ledger/.sqlx/query-e750e171f2397f146989b156826656095cdae392dd9e347a9c2144784ec44c7d.json similarity index 63% rename from cala-ledger/.sqlx/query-af56d9b7a5a837d6427edb0e25b40de901697ff77c90fabd863bb54acf5ec5b9.json rename to cala-ledger/.sqlx/query-e750e171f2397f146989b156826656095cdae392dd9e347a9c2144784ec44c7d.json index 404e3483d..b3483e099 100644 --- a/cala-ledger/.sqlx/query-af56d9b7a5a837d6427edb0e25b40de901697ff77c90fabd863bb54acf5ec5b9.json +++ b/cala-ledger/.sqlx/query-e750e171f2397f146989b156826656095cdae392dd9e347a9c2144784ec44c7d.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT external_id, id FROM cala_account_sets WHERE ((external_id IS NOT DISTINCT FROM $3) AND COALESCE(id < $2, true) OR COALESCE(external_id < $3, external_id IS NOT NULL)) ORDER BY external_id DESC NULLS LAST, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN cala_account_set_events e ON i.id = e.id ORDER BY i.external_id desc nulls last, i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT external_id, id FROM cala_account_sets WHERE ((external_id IS NOT DISTINCT FROM $3) AND COALESCE(id < $2, true) OR COALESCE(external_id < $3, $2 IS NULL OR (external_id IS NULL AND $3 IS NOT NULL))) ORDER BY external_id DESC NULLS LAST, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN cala_account_set_events e ON i.id = e.id ORDER BY i.external_id desc nulls last, i.id desc, i.id, e.sequence", "describe": { "columns": [ { @@ -45,5 +45,5 @@ false ] }, - "hash": "af56d9b7a5a837d6427edb0e25b40de901697ff77c90fabd863bb54acf5ec5b9" + "hash": "e750e171f2397f146989b156826656095cdae392dd9e347a9c2144784ec44c7d" } diff --git a/cala-ledger/.sqlx/query-1d1a35bc0d3a02c26f776ab068e6185018b536cb9da4876057d2762ff6dc0605.json b/cala-ledger/.sqlx/query-f3883e5f7bd52bf7d7d053e38a14352e4b3f590c9124173f4c08f95428ccc21b.json similarity index 66% rename from cala-ledger/.sqlx/query-1d1a35bc0d3a02c26f776ab068e6185018b536cb9da4876057d2762ff6dc0605.json rename to cala-ledger/.sqlx/query-f3883e5f7bd52bf7d7d053e38a14352e4b3f590c9124173f4c08f95428ccc21b.json index 5fe4e5a6b..4c3244b9f 100644 --- a/cala-ledger/.sqlx/query-1d1a35bc0d3a02c26f776ab068e6185018b536cb9da4876057d2762ff6dc0605.json +++ b/cala-ledger/.sqlx/query-f3883e5f7bd52bf7d7d053e38a14352e4b3f590c9124173f4c08f95428ccc21b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT external_id, id FROM cala_account_sets WHERE COALESCE(name = $1, $1 IS NULL) AND ((external_id IS NOT DISTINCT FROM $4) AND COALESCE(id < $3, true) OR COALESCE(external_id < $4, external_id IS NOT NULL)) ORDER BY external_id DESC NULLS LAST, id DESC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN cala_account_set_events e ON i.id = e.id ORDER BY i.external_id desc nulls last, i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT external_id, id FROM cala_account_sets WHERE COALESCE(name = $1, $1 IS NULL) AND ((external_id IS NOT DISTINCT FROM $4) AND COALESCE(id < $3, true) OR COALESCE(external_id < $4, $3 IS NULL OR (external_id IS NULL AND $4 IS NOT NULL))) ORDER BY external_id DESC NULLS LAST, id DESC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN cala_account_set_events e ON i.id = e.id ORDER BY i.external_id desc nulls last, i.id desc, i.id, e.sequence", "describe": { "columns": [ { @@ -46,5 +46,5 @@ false ] }, - "hash": "1d1a35bc0d3a02c26f776ab068e6185018b536cb9da4876057d2762ff6dc0605" + "hash": "f3883e5f7bd52bf7d7d053e38a14352e4b3f590c9124173f4c08f95428ccc21b" } diff --git a/cala-ledger/.sqlx/query-6a6577f96ae0f098a4539fc36d267fcf8fa836ce7c6f54c42116256b6fc22735.json b/cala-ledger/.sqlx/query-fe49f46b26ce060e5a44a631dcc321f785e3f8b549a89cef5f5fd7cd17cdb5cd.json similarity index 63% rename from cala-ledger/.sqlx/query-6a6577f96ae0f098a4539fc36d267fcf8fa836ce7c6f54c42116256b6fc22735.json rename to cala-ledger/.sqlx/query-fe49f46b26ce060e5a44a631dcc321f785e3f8b549a89cef5f5fd7cd17cdb5cd.json index 96b22c976..850c5e50c 100644 --- a/cala-ledger/.sqlx/query-6a6577f96ae0f098a4539fc36d267fcf8fa836ce7c6f54c42116256b6fc22735.json +++ b/cala-ledger/.sqlx/query-fe49f46b26ce060e5a44a631dcc321f785e3f8b549a89cef5f5fd7cd17cdb5cd.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT external_id, id FROM cala_accounts WHERE ((external_id IS NOT DISTINCT FROM $3) AND COALESCE(id < $2, true) OR COALESCE(external_id < $3, external_id IS NOT NULL)) ORDER BY external_id DESC NULLS LAST, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN cala_account_events e ON i.id = e.id ORDER BY i.external_id desc nulls last, i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT external_id, id FROM cala_accounts WHERE ((external_id IS NOT DISTINCT FROM $3) AND COALESCE(id < $2, true) OR COALESCE(external_id < $3, $2 IS NULL OR (external_id IS NULL AND $3 IS NOT NULL))) ORDER BY external_id DESC NULLS LAST, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN cala_account_events e ON i.id = e.id ORDER BY i.external_id desc nulls last, i.id desc, i.id, e.sequence", "describe": { "columns": [ { @@ -45,5 +45,5 @@ false ] }, - "hash": "6a6577f96ae0f098a4539fc36d267fcf8fa836ce7c6f54c42116256b6fc22735" + "hash": "fe49f46b26ce060e5a44a631dcc321f785e3f8b549a89cef5f5fd7cd17cdb5cd" }