From 7e1da952166cfed0604d4f8661548b040aac1110 Mon Sep 17 00:00:00 2001 From: Brian Donovan <1938+eventualbuddha@users.noreply.github.com> Date: Mon, 1 Apr 2024 11:03:15 -0700 Subject: [PATCH] Misc. Minor Changes (#98) * chore: update `.sqlx` query metadata * refactor(mark): use object type constants --- ...38b700b8b1f4f514b022f6c45380d1e5cf73c.json | 52 ++++++++++++++++++ ...4e8c11a67450d556ff1afd9d3a906dc9d0fbf.json | 26 --------- ...9bff40dd8d75915e233c7f16d948c929e9cde.json | 53 +++++++++++++++++++ ...dd33a21b6fcbea8babb886d3584a5c4ea715f.json | 19 +++++++ ...9bc7274841d54fb878d2dbcda8db1bf5f79b1.json | 14 +++++ ...d0f499639be038b1713fb3c770674f49a9004.json | 38 +++++++++++++ ...497590718e5f76e327d7b99ba7214c4bd34c1.json | 19 +++++++ ...830eca644979829d636eac5c7538091aa097a.json | 38 +++++++++++++ ...e6d1be327c232364856c4ce32296aec960db1.json | 50 +++++++++++++++++ ...267941e85d301dffd1434aa8a4d997df9845.json} | 6 +-- .../backend/src/cacvote-server/sync.test.ts | 2 +- apps/cacvote-mark/backend/src/store.ts | 5 +- 12 files changed, 290 insertions(+), 32 deletions(-) create mode 100644 .sqlx/query-1b9228bc0c3c35aa800648da94038b700b8b1f4f514b022f6c45380d1e5cf73c.json delete mode 100644 .sqlx/query-360ff03817c2817cb4e8254b87b4e8c11a67450d556ff1afd9d3a906dc9d0fbf.json create mode 100644 .sqlx/query-37db1b0292c2b8dcd7d0616aed49bff40dd8d75915e233c7f16d948c929e9cde.json create mode 100644 .sqlx/query-6cacb3ffd288bfd7256ee1aad25dd33a21b6fcbea8babb886d3584a5c4ea715f.json create mode 100644 .sqlx/query-8af0f75909f94fd520555bad4ce9bc7274841d54fb878d2dbcda8db1bf5f79b1.json create mode 100644 .sqlx/query-9912b4be8a1e96c61274a49fe83d0f499639be038b1713fb3c770674f49a9004.json create mode 100644 .sqlx/query-aad90d35068edd98b5fbec2efa8497590718e5f76e327d7b99ba7214c4bd34c1.json create mode 100644 .sqlx/query-e6b22ea6a43f9fa2d1cee23a40a830eca644979829d636eac5c7538091aa097a.json create mode 100644 .sqlx/query-f3bea3cd380dffea913274cd686e6d1be327c232364856c4ce32296aec960db1.json rename .sqlx/{query-9a47bcd3a79ee448a5dbb8c2583c95868aca3dac148a9b7e4824b6d7be2bce3d.json => query-fe371a75d4ee9d884b1520869195267941e85d301dffd1434aa8a4d997df9845.json} (69%) diff --git a/.sqlx/query-1b9228bc0c3c35aa800648da94038b700b8b1f4f514b022f6c45380d1e5cf73c.json b/.sqlx/query-1b9228bc0c3c35aa800648da94038b700b8b1f4f514b022f6c45380d1e5cf73c.json new file mode 100644 index 000000000..04965330d --- /dev/null +++ b/.sqlx/query-1b9228bc0c3c35aa800648da94038b700b8b1f4f514b022f6c45380d1e5cf73c.json @@ -0,0 +1,52 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id,\n object_id,\n jurisdiction,\n object_type,\n action as \"action: JournalEntryAction\",\n created_at\n FROM journal_entries\n WHERE jurisdiction = $1\n ORDER BY created_at\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "object_id", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "jurisdiction", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "object_type", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "action: JournalEntryAction", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "created_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false + ] + }, + "hash": "1b9228bc0c3c35aa800648da94038b700b8b1f4f514b022f6c45380d1e5cf73c" +} diff --git a/.sqlx/query-360ff03817c2817cb4e8254b87b4e8c11a67450d556ff1afd9d3a906dc9d0fbf.json b/.sqlx/query-360ff03817c2817cb4e8254b87b4e8c11a67450d556ff1afd9d3a906dc9d0fbf.json deleted file mode 100644 index 7a8718243..000000000 --- a/.sqlx/query-360ff03817c2817cb4e8254b87b4e8c11a67450d556ff1afd9d3a906dc9d0fbf.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO objects (jurisdiction, object_type, payload, certificates, signature)\n VALUES ($1, $2, $3, $4, $5)\n RETURNING id\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - } - ], - "parameters": { - "Left": [ - "Varchar", - "Varchar", - "Bytea", - "Bytea", - "Bytea" - ] - }, - "nullable": [ - false - ] - }, - "hash": "360ff03817c2817cb4e8254b87b4e8c11a67450d556ff1afd9d3a906dc9d0fbf" -} diff --git a/.sqlx/query-37db1b0292c2b8dcd7d0616aed49bff40dd8d75915e233c7f16d948c929e9cde.json b/.sqlx/query-37db1b0292c2b8dcd7d0616aed49bff40dd8d75915e233c7f16d948c929e9cde.json new file mode 100644 index 000000000..35811d333 --- /dev/null +++ b/.sqlx/query-37db1b0292c2b8dcd7d0616aed49bff40dd8d75915e233c7f16d948c929e9cde.json @@ -0,0 +1,53 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id,\n object_id,\n jurisdiction,\n object_type,\n action as \"action: JournalEntryAction\",\n created_at\n FROM journal_entries\n WHERE created_at > (SELECT created_at FROM journal_entries WHERE id = $1)\n AND jurisdiction = $2\n ORDER BY created_at\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "object_id", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "jurisdiction", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "object_type", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "action: JournalEntryAction", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "created_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false + ] + }, + "hash": "37db1b0292c2b8dcd7d0616aed49bff40dd8d75915e233c7f16d948c929e9cde" +} diff --git a/.sqlx/query-6cacb3ffd288bfd7256ee1aad25dd33a21b6fcbea8babb886d3584a5c4ea715f.json b/.sqlx/query-6cacb3ffd288bfd7256ee1aad25dd33a21b6fcbea8babb886d3584a5c4ea715f.json new file mode 100644 index 000000000..05e4bd864 --- /dev/null +++ b/.sqlx/query-6cacb3ffd288bfd7256ee1aad25dd33a21b6fcbea8babb886d3584a5c4ea715f.json @@ -0,0 +1,19 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO objects (id, jurisdiction, object_type, payload, certificates, signature)\n VALUES ($1, $2, $3, $4, $5, $6)\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Varchar", + "Bytea", + "Bytea", + "Bytea" + ] + }, + "nullable": [] + }, + "hash": "6cacb3ffd288bfd7256ee1aad25dd33a21b6fcbea8babb886d3584a5c4ea715f" +} diff --git a/.sqlx/query-8af0f75909f94fd520555bad4ce9bc7274841d54fb878d2dbcda8db1bf5f79b1.json b/.sqlx/query-8af0f75909f94fd520555bad4ce9bc7274841d54fb878d2dbcda8db1bf5f79b1.json new file mode 100644 index 000000000..898a20bdc --- /dev/null +++ b/.sqlx/query-8af0f75909f94fd520555bad4ce9bc7274841d54fb878d2dbcda8db1bf5f79b1.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE objects\n SET server_synced_at = now()\n WHERE id = $1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "8af0f75909f94fd520555bad4ce9bc7274841d54fb878d2dbcda8db1bf5f79b1" +} diff --git a/.sqlx/query-9912b4be8a1e96c61274a49fe83d0f499639be038b1713fb3c770674f49a9004.json b/.sqlx/query-9912b4be8a1e96c61274a49fe83d0f499639be038b1713fb3c770674f49a9004.json new file mode 100644 index 000000000..f847bdca7 --- /dev/null +++ b/.sqlx/query-9912b4be8a1e96c61274a49fe83d0f499639be038b1713fb3c770674f49a9004.json @@ -0,0 +1,38 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id,\n payload,\n certificates,\n signature\n FROM objects\n WHERE server_synced_at IS NULL\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "payload", + "type_info": "Bytea" + }, + { + "ordinal": 2, + "name": "certificates", + "type_info": "Bytea" + }, + { + "ordinal": 3, + "name": "signature", + "type_info": "Bytea" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "9912b4be8a1e96c61274a49fe83d0f499639be038b1713fb3c770674f49a9004" +} diff --git a/.sqlx/query-aad90d35068edd98b5fbec2efa8497590718e5f76e327d7b99ba7214c4bd34c1.json b/.sqlx/query-aad90d35068edd98b5fbec2efa8497590718e5f76e327d7b99ba7214c4bd34c1.json new file mode 100644 index 000000000..27ba14bdd --- /dev/null +++ b/.sqlx/query-aad90d35068edd98b5fbec2efa8497590718e5f76e327d7b99ba7214c4bd34c1.json @@ -0,0 +1,19 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO objects (id, jurisdiction, object_type, payload, certificates, signature, server_synced_at)\n VALUES ($1, $2, $3, $4, $5, $6, now())\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Varchar", + "Bytea", + "Bytea", + "Bytea" + ] + }, + "nullable": [] + }, + "hash": "aad90d35068edd98b5fbec2efa8497590718e5f76e327d7b99ba7214c4bd34c1" +} diff --git a/.sqlx/query-e6b22ea6a43f9fa2d1cee23a40a830eca644979829d636eac5c7538091aa097a.json b/.sqlx/query-e6b22ea6a43f9fa2d1cee23a40a830eca644979829d636eac5c7538091aa097a.json new file mode 100644 index 000000000..d16175781 --- /dev/null +++ b/.sqlx/query-e6b22ea6a43f9fa2d1cee23a40a830eca644979829d636eac5c7538091aa097a.json @@ -0,0 +1,38 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id,\n payload,\n certificates,\n signature\n FROM objects\n WHERE object_type = 'Election'\n ORDER BY created_at DESC\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "payload", + "type_info": "Bytea" + }, + { + "ordinal": 2, + "name": "certificates", + "type_info": "Bytea" + }, + { + "ordinal": 3, + "name": "signature", + "type_info": "Bytea" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "e6b22ea6a43f9fa2d1cee23a40a830eca644979829d636eac5c7538091aa097a" +} diff --git a/.sqlx/query-f3bea3cd380dffea913274cd686e6d1be327c232364856c4ce32296aec960db1.json b/.sqlx/query-f3bea3cd380dffea913274cd686e6d1be327c232364856c4ce32296aec960db1.json new file mode 100644 index 000000000..946cfc313 --- /dev/null +++ b/.sqlx/query-f3bea3cd380dffea913274cd686e6d1be327c232364856c4ce32296aec960db1.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id,\n object_id,\n jurisdiction as \"jurisdiction_code: JurisdictionCode\",\n object_type,\n action,\n created_at\n FROM journal_entries\n WHERE object_id IS NOT NULL\n AND object_type IN ('RegistrationRequest')\n AND object_id NOT IN (SELECT id FROM objects)\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "object_id", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "jurisdiction_code: JurisdictionCode", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "object_type", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "action", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "created_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + false, + false, + false, + false, + false + ] + }, + "hash": "f3bea3cd380dffea913274cd686e6d1be327c232364856c4ce32296aec960db1" +} diff --git a/.sqlx/query-9a47bcd3a79ee448a5dbb8c2583c95868aca3dac148a9b7e4824b6d7be2bce3d.json b/.sqlx/query-fe371a75d4ee9d884b1520869195267941e85d301dffd1434aa8a4d997df9845.json similarity index 69% rename from .sqlx/query-9a47bcd3a79ee448a5dbb8c2583c95868aca3dac148a9b7e4824b6d7be2bce3d.json rename to .sqlx/query-fe371a75d4ee9d884b1520869195267941e85d301dffd1434aa8a4d997df9845.json index fe8f50b22..c74f31803 100644 --- a/.sqlx/query-9a47bcd3a79ee448a5dbb8c2583c95868aca3dac148a9b7e4824b6d7be2bce3d.json +++ b/.sqlx/query-fe371a75d4ee9d884b1520869195267941e85d301dffd1434aa8a4d997df9845.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n id,\n object_id,\n jurisdiction as \"jurisdiction: JurisdictionCode\",\n object_type,\n action,\n created_at\n FROM journal_entries\n ORDER BY created_at DESC\n LIMIT 1\n ", + "query": "\n SELECT\n id,\n object_id,\n jurisdiction as \"jurisdiction_code: JurisdictionCode\",\n object_type,\n action,\n created_at\n FROM journal_entries\n ORDER BY created_at DESC\n LIMIT 1\n ", "describe": { "columns": [ { @@ -15,7 +15,7 @@ }, { "ordinal": 2, - "name": "jurisdiction: JurisdictionCode", + "name": "jurisdiction_code: JurisdictionCode", "type_info": "Varchar" }, { @@ -46,5 +46,5 @@ false ] }, - "hash": "9a47bcd3a79ee448a5dbb8c2583c95868aca3dac148a9b7e4824b6d7be2bce3d" + "hash": "fe371a75d4ee9d884b1520869195267941e85d301dffd1434aa8a4d997df9845" } diff --git a/apps/cacvote-mark/backend/src/cacvote-server/sync.test.ts b/apps/cacvote-mark/backend/src/cacvote-server/sync.test.ts index 36a236cee..6e2aef284 100644 --- a/apps/cacvote-mark/backend/src/cacvote-server/sync.test.ts +++ b/apps/cacvote-mark/backend/src/cacvote-server/sync.test.ts @@ -505,7 +505,7 @@ test('sync / fetch object but cannot add to store', async () => { Uuid(), object.getId(), unsafeParse(JurisdictionCodeSchema, 'st.test-jurisdiction'), - 'RegistrationRequest', + RegistrationRequestObjectType, 'create', DateTime.now() ); diff --git a/apps/cacvote-mark/backend/src/store.ts b/apps/cacvote-mark/backend/src/store.ts index 44aad2188..c47ba64ec 100644 --- a/apps/cacvote-mark/backend/src/store.ts +++ b/apps/cacvote-mark/backend/src/store.ts @@ -19,6 +19,7 @@ import { join } from 'path'; import { ZodError } from 'zod'; import { Election, + ElectionObjectType, JournalEntry, JurisdictionCode, JurisdictionCodeSchema, @@ -255,8 +256,8 @@ export class Store { getJournalEntriesForObjectsToPull(): JournalEntry[] { const objectTypesToPull = [ RegistrationRequestObjectType, - 'Registration', - 'Election', + RegistrationObjectType, + ElectionObjectType, ]; const action = 'create';