From 210fc499628f93d21df696a973ba68d52c9ca495 Mon Sep 17 00:00:00 2001 From: Julius Kreutz Date: Tue, 5 Sep 2023 18:51:55 +1000 Subject: [PATCH] A lot of optimization. Dk what else I changed tbh --- ...ea0ec71548fed4772575feaba1eda3d2a4657.json | 20 ---------- ...986b64e2693e57a2bd9ca83f857e9ba7a370.json} | 4 +- ...12e8191f26f1067ada3f57d0f4d9bbeab8e5c.json | 26 ------------- ...95231b7791da8cd2b0d2db5bf828a053f1f81.json | 26 ------------- ...6cf1dc3696ab0c2ad93b00040254c235c062.json} | 4 +- ...6d0bd88fe7989d73e8b689f4274cc15c18f1.json} | 4 +- ...f365cb8e4548a36c87ae265030d55e45cce1.json} | 4 +- ...c4147f1fb45d370f5eb06d48d32cebed1e056.json | 20 ---------- ...97e5b4b5f6f12dcd379323f9f7888e06270c.json} | 4 +- ...a854413cc4d1da167742d800a492dab30b8bf.json | 28 +++++++++++++ ...82f51d690785fe7354d27de980bfb47c5624.json} | 4 +- ...896f8297e269735438bca387e0b89e4eac00.json} | 4 +- ...b7e0e39518f5373fa3fc08b400f05b49717e.json} | 4 +- ...6f7ca1fe05eb0c33c2bcdc2aadb6b5aba1dc.json} | 4 +- ...1ae1d248eff419ec05490c181c8fe37aaf92.json} | 8 ++-- ...d39a526963c9e92c5b664f3075fbdd7eadba.json} | 4 +- ...0ee6ac09324328bf284b086aaa4b3b4e3788.json} | 4 +- ...af94d3ff910a1e8957f1bcfd39bcd4345972.json} | 4 +- ...dee2c7b3f4696a247f9247149dff2fa20105.json} | 4 +- ...911b5122882d767fb7d48b1c6b16cfecb313.json} | 4 +- ...e94258b923aa68d0d7b55973085fa101fd17.json} | 4 +- ...cb299a18216965539c2efa9fda8cdbc163ae.json} | 4 +- ...e08cf0f48977cc909fa5a18cb953f036d3a9.json} | 8 ++-- ...5bfc816107dd64dca4902421c40901b770650.json | 28 +++++++++++++ ...310c51413b5aad22b494bfb582b3da82deca.json} | 4 +- ...392e2d3c177ea3b7ffa2dc0e921e0698c4ee.json} | 4 +- src/database/achievements.rs | 9 ----- src/database/book_series.rs | 4 +- src/database/books.rs | 9 ----- src/database/users_achievements.rs | 39 ++++++++++++++----- src/database/users_books.rs | 37 ++++++++++++++---- src/database/warp_departure_characters.rs | 4 +- src/database/warp_departure_light_cones.rs | 4 +- src/database/warp_lc_characters.rs | 4 +- src/database/warp_lc_light_cones.rs | 4 +- src/database/warp_special_characters.rs | 4 +- src/database/warp_special_light_cones.rs | 4 +- src/database/warp_standard_characters.rs | 4 +- src/database/warp_standard_light_cones.rs | 4 +- src/update/achievements_percent.rs | 37 ++++-------------- src/update/books_percent.rs | 37 ++++-------------- 41 files changed, 194 insertions(+), 246 deletions(-) delete mode 100644 .sqlx/query-044061471f57af0a09632966f45ea0ec71548fed4772575feaba1eda3d2a4657.json rename .sqlx/{query-6080264be36dfddce8028607d2f4657237bf1ec46bf96d11e254a949c7bd64af.json => query-07dc7cfeb42ea885005a65cc3d65986b64e2693e57a2bd9ca83f857e9ba7a370.json} (84%) delete mode 100644 .sqlx/query-0e48fc6825dd5b11d873b4e96e112e8191f26f1067ada3f57d0f4d9bbeab8e5c.json delete mode 100644 .sqlx/query-0ec57854b5f4060f7b0330ed60c95231b7791da8cd2b0d2db5bf828a053f1f81.json rename .sqlx/{query-d77d31b8a89b0c4603ef76618492426374a29ea7df8ba8b231db8285d33d0943.json => query-17d21503a5f3ddc2c566bcf45dca6cf1dc3696ab0c2ad93b00040254c235c062.json} (85%) rename .sqlx/{query-0934fa34a7cd5204a84596c001c51dc565ebdee7a0a144a428dd1dfdf201df83.json => query-321a5e28338dd19f2e8b811dcbb76d0bd88fe7989d73e8b689f4274cc15c18f1.json} (71%) rename .sqlx/{query-7428340190caeb3753a2cb97ed46de09d769d7acc3acb4bad351620ef2d76098.json => query-358c407545f08857d7fd3573c76af365cb8e4548a36c87ae265030d55e45cce1.json} (71%) delete mode 100644 .sqlx/query-37271ab7a2fe52854669c795562c4147f1fb45d370f5eb06d48d32cebed1e056.json rename .sqlx/{query-e560a73645d4059abf079d6a240b388ecd4a9ff274841f6e53b4415616c453ee.json => query-3fc1bfc5eec0663cb418ecf1aab697e5b4b5f6f12dcd379323f9f7888e06270c.json} (71%) create mode 100644 .sqlx/query-48ea3aa12770157052c5015e68fa854413cc4d1da167742d800a492dab30b8bf.json rename .sqlx/{query-20086495f75618599d0285a5a7e10964b36dcbbf3330fd1e2be6cdd729e06b48.json => query-4a9d9afd70c99ae211d68a4c72b782f51d690785fe7354d27de980bfb47c5624.json} (71%) rename .sqlx/{query-5173e8c75c6182be86c0534b68bf146c569ae613801ad693a8e6ecbf867d5c5d.json => query-5617cec35a9f4787019dc474d345896f8297e269735438bca387e0b89e4eac00.json} (70%) rename .sqlx/{query-74bc8c275a5fc1e801c78f4e84c5b5da8ee67e6914f551a6a639ad7300f70627.json => query-59b39a6aed5db16f2fcd91c28711b7e0e39518f5373fa3fc08b400f05b49717e.json} (71%) rename .sqlx/{query-8a4ce6af61ab7cda8546cd48954f1d16c5647ab0f90f8ae4da2fab6064be9157.json => query-6486eb9aaf6f4cd5a5efb7462a6a6f7ca1fe05eb0c33c2bcdc2aadb6b5aba1dc.json} (71%) rename .sqlx/{query-db3c021557ab16c58095ceee4e0230f1dd32201f1818762abdd0e12a2bd1b900.json => query-7069884fe3da47d4654155cdd59f1ae1d248eff419ec05490c181c8fe37aaf92.json} (72%) rename .sqlx/{query-1bd9f0da63a4d5ab1dcd45011535ec4838f2aca469e4075493e03ad1ed5edeef.json => query-824dae72aa5ec31fcc58cd27e7efd39a526963c9e92c5b664f3075fbdd7eadba.json} (71%) rename .sqlx/{query-d0fd449155b1792aec58aa56a8283c923ff81a232554c3b2a7c001aa0fda6fd1.json => query-837d309b4882f2d9fb7673cbe5530ee6ac09324328bf284b086aaa4b3b4e3788.json} (70%) rename .sqlx/{query-f6776130feeb1e2176272aafd5d6ac47c6d13a59ffaf024e98c828cecf0bdf86.json => query-8b8eb93b6d709348a1e64b49f587af94d3ff910a1e8957f1bcfd39bcd4345972.json} (72%) rename .sqlx/{query-5999c9b18d01338d5032561fcecc19c32cd49b28b7524cc5505fc889a4bbaaa4.json => query-92d35f71d6160fc1509b5b2aa79fdee2c7b3f4696a247f9247149dff2fa20105.json} (70%) rename .sqlx/{query-58691e1cb58929a3501fa621199e9714aacaa5dfc78cd76e5f40203dc2525944.json => query-a6a614c93e338b3e4acfb8c949ae911b5122882d767fb7d48b1c6b16cfecb313.json} (71%) rename .sqlx/{query-fa0010bcd72dfeef6216e15082001a8b74ccd0171d547294410c4d27cc5eaa6e.json => query-bd86a7435e9a119062d87d537b90e94258b923aa68d0d7b55973085fa101fd17.json} (71%) rename .sqlx/{query-2b29e22cad5d1a65b0fab39ad65bcc492d87c53881882a8e06980738b4eedfef.json => query-bf3bd841cc3db181d4e4602f0403cb299a18216965539c2efa9fda8cdbc163ae.json} (70%) rename .sqlx/{query-e93525d1cec5804bc86ea51db1897db6572421cb06a46d2beacec55ea6f6424f.json => query-d54dc8f1d68f2549ef2c654d1ab6e08cf0f48977cc909fa5a18cb953f036d3a9.json} (61%) create mode 100644 .sqlx/query-e687f8eb574d07948df1d7131365bfc816107dd64dca4902421c40901b770650.json rename .sqlx/{query-1b2ac2bf24ef3161958094ec5270c98f65cd41f7080449ce4d7cf7b0b8843b16.json => query-ea7158526eac5fac6de2de7518c5310c51413b5aad22b494bfb582b3da82deca.json} (77%) rename .sqlx/{query-1b5e7b11bdfc5e8172491e50a72229f3adae4b68eb969f3faba1987ea9344a7d.json => query-ecea2a6e436e6072a3b218926806392e2d3c177ea3b7ffa2dc0e921e0698c4ee.json} (70%) diff --git a/.sqlx/query-044061471f57af0a09632966f45ea0ec71548fed4772575feaba1eda3d2a4657.json b/.sqlx/query-044061471f57af0a09632966f45ea0ec71548fed4772575feaba1eda3d2a4657.json deleted file mode 100644 index 38d23576..00000000 --- a/.sqlx/query-044061471f57af0a09632966f45ea0ec71548fed4772575feaba1eda3d2a4657.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT id FROM achievements", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false - ] - }, - "hash": "044061471f57af0a09632966f45ea0ec71548fed4772575feaba1eda3d2a4657" -} diff --git a/.sqlx/query-6080264be36dfddce8028607d2f4657237bf1ec46bf96d11e254a949c7bd64af.json b/.sqlx/query-07dc7cfeb42ea885005a65cc3d65986b64e2693e57a2bd9ca83f857e9ba7a370.json similarity index 84% rename from .sqlx/query-6080264be36dfddce8028607d2f4657237bf1ec46bf96d11e254a949c7bd64af.json rename to .sqlx/query-07dc7cfeb42ea885005a65cc3d65986b64e2693e57a2bd9ca83f857e9ba7a370.json index 55713524..e8e195f9 100644 --- a/.sqlx/query-6080264be36dfddce8028607d2f4657237bf1ec46bf96d11e254a949c7bd64af.json +++ b/.sqlx/query-07dc7cfeb42ea885005a65cc3d65986b64e2693e57a2bd9ca83f857e9ba7a370.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n book_series.*,\n book_series_text.name,\n book_series_worlds_text.name world_name\n FROM\n book_series\n INNER JOIN\n book_series_text\n ON\n book_series_text.id = book_series.id AND book_series_text.language = $2\n INNER JOIN\n book_series_worlds_text\n ON\n book_series_worlds_text.id = book_series.id AND book_series_worlds_text.language = $2\n WHERE\n book_series.id = $1\n ", + "query": "\n SELECT\n book_series.*,\n book_series_text.name,\n book_series_worlds_text.name world_name\n FROM\n book_series\n INNER JOIN\n book_series_text\n ON\n book_series_text.id = book_series.id AND book_series_text.language = $2\n INNER JOIN\n book_series_worlds_text\n ON\n book_series_worlds_text.id = book_series.world AND book_series_worlds_text.language = $2\n WHERE\n book_series.id = $1\n ", "describe": { "columns": [ { @@ -37,5 +37,5 @@ false ] }, - "hash": "6080264be36dfddce8028607d2f4657237bf1ec46bf96d11e254a949c7bd64af" + "hash": "07dc7cfeb42ea885005a65cc3d65986b64e2693e57a2bd9ca83f857e9ba7a370" } diff --git a/.sqlx/query-0e48fc6825dd5b11d873b4e96e112e8191f26f1067ada3f57d0f4d9bbeab8e5c.json b/.sqlx/query-0e48fc6825dd5b11d873b4e96e112e8191f26f1067ada3f57d0f4d9bbeab8e5c.json deleted file mode 100644 index 0ced1883..00000000 --- a/.sqlx/query-0e48fc6825dd5b11d873b4e96e112e8191f26f1067ada3f57d0f4d9bbeab8e5c.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT * FROM users_achievements", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "username", - "type_info": "Text" - }, - { - "ordinal": 1, - "name": "id", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false, - false - ] - }, - "hash": "0e48fc6825dd5b11d873b4e96e112e8191f26f1067ada3f57d0f4d9bbeab8e5c" -} diff --git a/.sqlx/query-0ec57854b5f4060f7b0330ed60c95231b7791da8cd2b0d2db5bf828a053f1f81.json b/.sqlx/query-0ec57854b5f4060f7b0330ed60c95231b7791da8cd2b0d2db5bf828a053f1f81.json deleted file mode 100644 index 2a01d43f..00000000 --- a/.sqlx/query-0ec57854b5f4060f7b0330ed60c95231b7791da8cd2b0d2db5bf828a053f1f81.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT * FROM users_books", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "username", - "type_info": "Text" - }, - { - "ordinal": 1, - "name": "id", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false, - false - ] - }, - "hash": "0ec57854b5f4060f7b0330ed60c95231b7791da8cd2b0d2db5bf828a053f1f81" -} diff --git a/.sqlx/query-d77d31b8a89b0c4603ef76618492426374a29ea7df8ba8b231db8285d33d0943.json b/.sqlx/query-17d21503a5f3ddc2c566bcf45dca6cf1dc3696ab0c2ad93b00040254c235c062.json similarity index 85% rename from .sqlx/query-d77d31b8a89b0c4603ef76618492426374a29ea7df8ba8b231db8285d33d0943.json rename to .sqlx/query-17d21503a5f3ddc2c566bcf45dca6cf1dc3696ab0c2ad93b00040254c235c062.json index 60d3b82f..91fd08ed 100644 --- a/.sqlx/query-d77d31b8a89b0c4603ef76618492426374a29ea7df8ba8b231db8285d33d0943.json +++ b/.sqlx/query-17d21503a5f3ddc2c566bcf45dca6cf1dc3696ab0c2ad93b00040254c235c062.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n book_series.*,\n book_series_text.name,\n book_series_worlds_text.name world_name\n FROM\n book_series\n INNER JOIN\n book_series_text\n ON\n book_series_text.id = book_series.id AND book_series_text.language = $1\n INNER JOIN\n book_series_worlds_text\n ON\n book_series_worlds_text.id = book_series.id AND book_series_worlds_text.language = $1\n ORDER BY\n id\n ", + "query": "\n SELECT\n book_series.*,\n book_series_text.name,\n book_series_worlds_text.name world_name\n FROM\n book_series\n INNER JOIN\n book_series_text\n ON\n book_series_text.id = book_series.id AND book_series_text.language = $1\n INNER JOIN\n book_series_worlds_text\n ON\n book_series_worlds_text.id = book_series.world AND book_series_worlds_text.language = $1\n ORDER BY\n id\n ", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "d77d31b8a89b0c4603ef76618492426374a29ea7df8ba8b231db8285d33d0943" + "hash": "17d21503a5f3ddc2c566bcf45dca6cf1dc3696ab0c2ad93b00040254c235c062" } diff --git a/.sqlx/query-0934fa34a7cd5204a84596c001c51dc565ebdee7a0a144a428dd1dfdf201df83.json b/.sqlx/query-321a5e28338dd19f2e8b811dcbb76d0bd88fe7989d73e8b689f4274cc15c18f1.json similarity index 71% rename from .sqlx/query-0934fa34a7cd5204a84596c001c51dc565ebdee7a0a144a428dd1dfdf201df83.json rename to .sqlx/query-321a5e28338dd19f2e8b811dcbb76d0bd88fe7989d73e8b689f4274cc15c18f1.json index 4ff0bda7..742b4a0f 100644 --- a/.sqlx/query-0934fa34a7cd5204a84596c001c51dc565ebdee7a0a144a428dd1dfdf201df83.json +++ b/.sqlx/query-321a5e28338dd19f2e8b811dcbb76d0bd88fe7989d73e8b689f4274cc15c18f1.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_special_characters.*,\n characters_text.name\n FROM\n warp_special_characters\n LEFT JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $3\n WHERE\n warp_special_characters.id = $1\n AND\n uid = $2\n ", + "query": "\n SELECT\n warp_special_characters.*,\n characters_text.name\n FROM\n warp_special_characters\n INNER JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $3\n WHERE\n warp_special_characters.id = $1\n AND\n uid = $2\n ", "describe": { "columns": [ { @@ -44,5 +44,5 @@ false ] }, - "hash": "0934fa34a7cd5204a84596c001c51dc565ebdee7a0a144a428dd1dfdf201df83" + "hash": "321a5e28338dd19f2e8b811dcbb76d0bd88fe7989d73e8b689f4274cc15c18f1" } diff --git a/.sqlx/query-7428340190caeb3753a2cb97ed46de09d769d7acc3acb4bad351620ef2d76098.json b/.sqlx/query-358c407545f08857d7fd3573c76af365cb8e4548a36c87ae265030d55e45cce1.json similarity index 71% rename from .sqlx/query-7428340190caeb3753a2cb97ed46de09d769d7acc3acb4bad351620ef2d76098.json rename to .sqlx/query-358c407545f08857d7fd3573c76af365cb8e4548a36c87ae265030d55e45cce1.json index 67007b5a..98ebb7df 100644 --- a/.sqlx/query-7428340190caeb3753a2cb97ed46de09d769d7acc3acb4bad351620ef2d76098.json +++ b/.sqlx/query-358c407545f08857d7fd3573c76af365cb8e4548a36c87ae265030d55e45cce1.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_departure_light_cones.*,\n light_cones_text.name\n FROM\n warp_departure_light_cones\n LEFT JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", + "query": "\n SELECT\n warp_departure_light_cones.*,\n light_cones_text.name\n FROM\n warp_departure_light_cones\n INNER JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ false ] }, - "hash": "7428340190caeb3753a2cb97ed46de09d769d7acc3acb4bad351620ef2d76098" + "hash": "358c407545f08857d7fd3573c76af365cb8e4548a36c87ae265030d55e45cce1" } diff --git a/.sqlx/query-37271ab7a2fe52854669c795562c4147f1fb45d370f5eb06d48d32cebed1e056.json b/.sqlx/query-37271ab7a2fe52854669c795562c4147f1fb45d370f5eb06d48d32cebed1e056.json deleted file mode 100644 index 9bfad096..00000000 --- a/.sqlx/query-37271ab7a2fe52854669c795562c4147f1fb45d370f5eb06d48d32cebed1e056.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT id FROM books", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false - ] - }, - "hash": "37271ab7a2fe52854669c795562c4147f1fb45d370f5eb06d48d32cebed1e056" -} diff --git a/.sqlx/query-e560a73645d4059abf079d6a240b388ecd4a9ff274841f6e53b4415616c453ee.json b/.sqlx/query-3fc1bfc5eec0663cb418ecf1aab697e5b4b5f6f12dcd379323f9f7888e06270c.json similarity index 71% rename from .sqlx/query-e560a73645d4059abf079d6a240b388ecd4a9ff274841f6e53b4415616c453ee.json rename to .sqlx/query-3fc1bfc5eec0663cb418ecf1aab697e5b4b5f6f12dcd379323f9f7888e06270c.json index 5a673269..3d973637 100644 --- a/.sqlx/query-e560a73645d4059abf079d6a240b388ecd4a9ff274841f6e53b4415616c453ee.json +++ b/.sqlx/query-3fc1bfc5eec0663cb418ecf1aab697e5b4b5f6f12dcd379323f9f7888e06270c.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_lc_characters.*,\n characters_text.name\n FROM\n warp_lc_characters\n LEFT JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $3\n WHERE\n warp_lc_characters.id = $1\n AND\n uid = $2\n ", + "query": "\n SELECT\n warp_lc_characters.*,\n characters_text.name\n FROM\n warp_lc_characters\n INNER JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $3\n WHERE\n warp_lc_characters.id = $1\n AND\n uid = $2\n ", "describe": { "columns": [ { @@ -44,5 +44,5 @@ false ] }, - "hash": "e560a73645d4059abf079d6a240b388ecd4a9ff274841f6e53b4415616c453ee" + "hash": "3fc1bfc5eec0663cb418ecf1aab697e5b4b5f6f12dcd379323f9f7888e06270c" } diff --git a/.sqlx/query-48ea3aa12770157052c5015e68fa854413cc4d1da167742d800a492dab30b8bf.json b/.sqlx/query-48ea3aa12770157052c5015e68fa854413cc4d1da167742d800a492dab30b8bf.json new file mode 100644 index 00000000..33f957c3 --- /dev/null +++ b/.sqlx/query-48ea3aa12770157052c5015e68fa854413cc4d1da167742d800a492dab30b8bf.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id,\n COUNT(*)\n FROM\n users_achievements\n JOIN\n (SELECT username FROM users_achievements GROUP BY username HAVING count(*) >= $1) counted_users\n ON\n users_achievements.username = counted_users.username\n GROUP BY\n id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + false, + null + ] + }, + "hash": "48ea3aa12770157052c5015e68fa854413cc4d1da167742d800a492dab30b8bf" +} diff --git a/.sqlx/query-20086495f75618599d0285a5a7e10964b36dcbbf3330fd1e2be6cdd729e06b48.json b/.sqlx/query-4a9d9afd70c99ae211d68a4c72b782f51d690785fe7354d27de980bfb47c5624.json similarity index 71% rename from .sqlx/query-20086495f75618599d0285a5a7e10964b36dcbbf3330fd1e2be6cdd729e06b48.json rename to .sqlx/query-4a9d9afd70c99ae211d68a4c72b782f51d690785fe7354d27de980bfb47c5624.json index 2c81f676..5e17ca89 100644 --- a/.sqlx/query-20086495f75618599d0285a5a7e10964b36dcbbf3330fd1e2be6cdd729e06b48.json +++ b/.sqlx/query-4a9d9afd70c99ae211d68a4c72b782f51d690785fe7354d27de980bfb47c5624.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_departure_characters.*,\n characters_text.name\n FROM\n warp_departure_characters\n LEFT JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", + "query": "\n SELECT\n warp_departure_characters.*,\n characters_text.name\n FROM\n warp_departure_characters\n INNER JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ false ] }, - "hash": "20086495f75618599d0285a5a7e10964b36dcbbf3330fd1e2be6cdd729e06b48" + "hash": "4a9d9afd70c99ae211d68a4c72b782f51d690785fe7354d27de980bfb47c5624" } diff --git a/.sqlx/query-5173e8c75c6182be86c0534b68bf146c569ae613801ad693a8e6ecbf867d5c5d.json b/.sqlx/query-5617cec35a9f4787019dc474d345896f8297e269735438bca387e0b89e4eac00.json similarity index 70% rename from .sqlx/query-5173e8c75c6182be86c0534b68bf146c569ae613801ad693a8e6ecbf867d5c5d.json rename to .sqlx/query-5617cec35a9f4787019dc474d345896f8297e269735438bca387e0b89e4eac00.json index 7e3c4fd7..852f8fff 100644 --- a/.sqlx/query-5173e8c75c6182be86c0534b68bf146c569ae613801ad693a8e6ecbf867d5c5d.json +++ b/.sqlx/query-5617cec35a9f4787019dc474d345896f8297e269735438bca387e0b89e4eac00.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_special_light_cones.*,\n light_cones_text.name\n FROM\n warp_special_light_cones\n LEFT JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $3\n WHERE\n warp_special_light_cones.id = $1\n AND\n uid = $2\n ", + "query": "\n SELECT\n warp_special_light_cones.*,\n light_cones_text.name\n FROM\n warp_special_light_cones\n INNER JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $3\n WHERE\n warp_special_light_cones.id = $1\n AND\n uid = $2\n ", "describe": { "columns": [ { @@ -44,5 +44,5 @@ false ] }, - "hash": "5173e8c75c6182be86c0534b68bf146c569ae613801ad693a8e6ecbf867d5c5d" + "hash": "5617cec35a9f4787019dc474d345896f8297e269735438bca387e0b89e4eac00" } diff --git a/.sqlx/query-74bc8c275a5fc1e801c78f4e84c5b5da8ee67e6914f551a6a639ad7300f70627.json b/.sqlx/query-59b39a6aed5db16f2fcd91c28711b7e0e39518f5373fa3fc08b400f05b49717e.json similarity index 71% rename from .sqlx/query-74bc8c275a5fc1e801c78f4e84c5b5da8ee67e6914f551a6a639ad7300f70627.json rename to .sqlx/query-59b39a6aed5db16f2fcd91c28711b7e0e39518f5373fa3fc08b400f05b49717e.json index 8ca5716b..3e6908fb 100644 --- a/.sqlx/query-74bc8c275a5fc1e801c78f4e84c5b5da8ee67e6914f551a6a639ad7300f70627.json +++ b/.sqlx/query-59b39a6aed5db16f2fcd91c28711b7e0e39518f5373fa3fc08b400f05b49717e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_lc_light_cones.*,\n light_cones_text.name\n FROM\n warp_lc_light_cones\n LEFT JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", + "query": "\n SELECT\n warp_lc_light_cones.*,\n light_cones_text.name\n FROM\n warp_lc_light_cones\n INNER JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ false ] }, - "hash": "74bc8c275a5fc1e801c78f4e84c5b5da8ee67e6914f551a6a639ad7300f70627" + "hash": "59b39a6aed5db16f2fcd91c28711b7e0e39518f5373fa3fc08b400f05b49717e" } diff --git a/.sqlx/query-8a4ce6af61ab7cda8546cd48954f1d16c5647ab0f90f8ae4da2fab6064be9157.json b/.sqlx/query-6486eb9aaf6f4cd5a5efb7462a6a6f7ca1fe05eb0c33c2bcdc2aadb6b5aba1dc.json similarity index 71% rename from .sqlx/query-8a4ce6af61ab7cda8546cd48954f1d16c5647ab0f90f8ae4da2fab6064be9157.json rename to .sqlx/query-6486eb9aaf6f4cd5a5efb7462a6a6f7ca1fe05eb0c33c2bcdc2aadb6b5aba1dc.json index 776c55ba..ed1b1c1a 100644 --- a/.sqlx/query-8a4ce6af61ab7cda8546cd48954f1d16c5647ab0f90f8ae4da2fab6064be9157.json +++ b/.sqlx/query-6486eb9aaf6f4cd5a5efb7462a6a6f7ca1fe05eb0c33c2bcdc2aadb6b5aba1dc.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_special_characters.*,\n characters_text.name\n FROM\n warp_special_characters\n LEFT JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", + "query": "\n SELECT\n warp_special_characters.*,\n characters_text.name\n FROM\n warp_special_characters\n INNER JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ false ] }, - "hash": "8a4ce6af61ab7cda8546cd48954f1d16c5647ab0f90f8ae4da2fab6064be9157" + "hash": "6486eb9aaf6f4cd5a5efb7462a6a6f7ca1fe05eb0c33c2bcdc2aadb6b5aba1dc" } diff --git a/.sqlx/query-db3c021557ab16c58095ceee4e0230f1dd32201f1818762abdd0e12a2bd1b900.json b/.sqlx/query-7069884fe3da47d4654155cdd59f1ae1d248eff419ec05490c181c8fe37aaf92.json similarity index 72% rename from .sqlx/query-db3c021557ab16c58095ceee4e0230f1dd32201f1818762abdd0e12a2bd1b900.json rename to .sqlx/query-7069884fe3da47d4654155cdd59f1ae1d248eff419ec05490c181c8fe37aaf92.json index 1b767fc4..9989d3f7 100644 --- a/.sqlx/query-db3c021557ab16c58095ceee4e0230f1dd32201f1818762abdd0e12a2bd1b900.json +++ b/.sqlx/query-7069884fe3da47d4654155cdd59f1ae1d248eff419ec05490c181c8fe37aaf92.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT COUNT(*) FROM users WHERE (SELECT COUNT(*) FROM users_achievements WHERE users_achievements.username = users.username) >= 50", + "query": "SELECT COUNT(*) FROM users WHERE (SELECT COUNT(*) FROM users_achievements WHERE users_achievements.username = users.username) >= $1", "describe": { "columns": [ { @@ -10,11 +10,13 @@ } ], "parameters": { - "Left": [] + "Left": [ + "Int8" + ] }, "nullable": [ null ] }, - "hash": "db3c021557ab16c58095ceee4e0230f1dd32201f1818762abdd0e12a2bd1b900" + "hash": "7069884fe3da47d4654155cdd59f1ae1d248eff419ec05490c181c8fe37aaf92" } diff --git a/.sqlx/query-1bd9f0da63a4d5ab1dcd45011535ec4838f2aca469e4075493e03ad1ed5edeef.json b/.sqlx/query-824dae72aa5ec31fcc58cd27e7efd39a526963c9e92c5b664f3075fbdd7eadba.json similarity index 71% rename from .sqlx/query-1bd9f0da63a4d5ab1dcd45011535ec4838f2aca469e4075493e03ad1ed5edeef.json rename to .sqlx/query-824dae72aa5ec31fcc58cd27e7efd39a526963c9e92c5b664f3075fbdd7eadba.json index 3ad0c596..656e90ae 100644 --- a/.sqlx/query-1bd9f0da63a4d5ab1dcd45011535ec4838f2aca469e4075493e03ad1ed5edeef.json +++ b/.sqlx/query-824dae72aa5ec31fcc58cd27e7efd39a526963c9e92c5b664f3075fbdd7eadba.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_special_light_cones.*,\n light_cones_text.name\n FROM\n warp_special_light_cones\n LEFT JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", + "query": "\n SELECT\n warp_special_light_cones.*,\n light_cones_text.name\n FROM\n warp_special_light_cones\n INNER JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ false ] }, - "hash": "1bd9f0da63a4d5ab1dcd45011535ec4838f2aca469e4075493e03ad1ed5edeef" + "hash": "824dae72aa5ec31fcc58cd27e7efd39a526963c9e92c5b664f3075fbdd7eadba" } diff --git a/.sqlx/query-d0fd449155b1792aec58aa56a8283c923ff81a232554c3b2a7c001aa0fda6fd1.json b/.sqlx/query-837d309b4882f2d9fb7673cbe5530ee6ac09324328bf284b086aaa4b3b4e3788.json similarity index 70% rename from .sqlx/query-d0fd449155b1792aec58aa56a8283c923ff81a232554c3b2a7c001aa0fda6fd1.json rename to .sqlx/query-837d309b4882f2d9fb7673cbe5530ee6ac09324328bf284b086aaa4b3b4e3788.json index c03ebc57..8e3db09b 100644 --- a/.sqlx/query-d0fd449155b1792aec58aa56a8283c923ff81a232554c3b2a7c001aa0fda6fd1.json +++ b/.sqlx/query-837d309b4882f2d9fb7673cbe5530ee6ac09324328bf284b086aaa4b3b4e3788.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_standard_light_cones.*,\n light_cones_text.name\n FROM\n warp_standard_light_cones\n LEFT JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $3\n WHERE\n warp_standard_light_cones.id = $1\n AND\n uid = $2\n ", + "query": "\n SELECT\n warp_standard_light_cones.*,\n light_cones_text.name\n FROM\n warp_standard_light_cones\n INNER JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $3\n WHERE\n warp_standard_light_cones.id = $1\n AND\n uid = $2\n ", "describe": { "columns": [ { @@ -44,5 +44,5 @@ false ] }, - "hash": "d0fd449155b1792aec58aa56a8283c923ff81a232554c3b2a7c001aa0fda6fd1" + "hash": "837d309b4882f2d9fb7673cbe5530ee6ac09324328bf284b086aaa4b3b4e3788" } diff --git a/.sqlx/query-f6776130feeb1e2176272aafd5d6ac47c6d13a59ffaf024e98c828cecf0bdf86.json b/.sqlx/query-8b8eb93b6d709348a1e64b49f587af94d3ff910a1e8957f1bcfd39bcd4345972.json similarity index 72% rename from .sqlx/query-f6776130feeb1e2176272aafd5d6ac47c6d13a59ffaf024e98c828cecf0bdf86.json rename to .sqlx/query-8b8eb93b6d709348a1e64b49f587af94d3ff910a1e8957f1bcfd39bcd4345972.json index a31bed7f..97d3495b 100644 --- a/.sqlx/query-f6776130feeb1e2176272aafd5d6ac47c6d13a59ffaf024e98c828cecf0bdf86.json +++ b/.sqlx/query-8b8eb93b6d709348a1e64b49f587af94d3ff910a1e8957f1bcfd39bcd4345972.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_lc_characters.*,\n characters_text.name\n FROM\n warp_lc_characters\n LEFT JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", + "query": "\n SELECT\n warp_lc_characters.*,\n characters_text.name\n FROM\n warp_lc_characters\n INNER JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ false ] }, - "hash": "f6776130feeb1e2176272aafd5d6ac47c6d13a59ffaf024e98c828cecf0bdf86" + "hash": "8b8eb93b6d709348a1e64b49f587af94d3ff910a1e8957f1bcfd39bcd4345972" } diff --git a/.sqlx/query-5999c9b18d01338d5032561fcecc19c32cd49b28b7524cc5505fc889a4bbaaa4.json b/.sqlx/query-92d35f71d6160fc1509b5b2aa79fdee2c7b3f4696a247f9247149dff2fa20105.json similarity index 70% rename from .sqlx/query-5999c9b18d01338d5032561fcecc19c32cd49b28b7524cc5505fc889a4bbaaa4.json rename to .sqlx/query-92d35f71d6160fc1509b5b2aa79fdee2c7b3f4696a247f9247149dff2fa20105.json index e06dc3e4..26b3f9d2 100644 --- a/.sqlx/query-5999c9b18d01338d5032561fcecc19c32cd49b28b7524cc5505fc889a4bbaaa4.json +++ b/.sqlx/query-92d35f71d6160fc1509b5b2aa79fdee2c7b3f4696a247f9247149dff2fa20105.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_departure_light_cones.*,\n light_cones_text.name\n FROM\n warp_departure_light_cones\n LEFT JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $3\n WHERE\n warp_departure_light_cones.id = $1\n AND\n uid = $2\n ", + "query": "\n SELECT\n warp_departure_light_cones.*,\n light_cones_text.name\n FROM\n warp_departure_light_cones\n INNER JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $3\n WHERE\n warp_departure_light_cones.id = $1\n AND\n uid = $2\n ", "describe": { "columns": [ { @@ -44,5 +44,5 @@ false ] }, - "hash": "5999c9b18d01338d5032561fcecc19c32cd49b28b7524cc5505fc889a4bbaaa4" + "hash": "92d35f71d6160fc1509b5b2aa79fdee2c7b3f4696a247f9247149dff2fa20105" } diff --git a/.sqlx/query-58691e1cb58929a3501fa621199e9714aacaa5dfc78cd76e5f40203dc2525944.json b/.sqlx/query-a6a614c93e338b3e4acfb8c949ae911b5122882d767fb7d48b1c6b16cfecb313.json similarity index 71% rename from .sqlx/query-58691e1cb58929a3501fa621199e9714aacaa5dfc78cd76e5f40203dc2525944.json rename to .sqlx/query-a6a614c93e338b3e4acfb8c949ae911b5122882d767fb7d48b1c6b16cfecb313.json index af484e4b..64bdb925 100644 --- a/.sqlx/query-58691e1cb58929a3501fa621199e9714aacaa5dfc78cd76e5f40203dc2525944.json +++ b/.sqlx/query-a6a614c93e338b3e4acfb8c949ae911b5122882d767fb7d48b1c6b16cfecb313.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_standard_light_cones.*,\n light_cones_text.name\n FROM\n warp_standard_light_cones\n LEFT JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", + "query": "\n SELECT\n warp_standard_light_cones.*,\n light_cones_text.name\n FROM\n warp_standard_light_cones\n INNER JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ false ] }, - "hash": "58691e1cb58929a3501fa621199e9714aacaa5dfc78cd76e5f40203dc2525944" + "hash": "a6a614c93e338b3e4acfb8c949ae911b5122882d767fb7d48b1c6b16cfecb313" } diff --git a/.sqlx/query-fa0010bcd72dfeef6216e15082001a8b74ccd0171d547294410c4d27cc5eaa6e.json b/.sqlx/query-bd86a7435e9a119062d87d537b90e94258b923aa68d0d7b55973085fa101fd17.json similarity index 71% rename from .sqlx/query-fa0010bcd72dfeef6216e15082001a8b74ccd0171d547294410c4d27cc5eaa6e.json rename to .sqlx/query-bd86a7435e9a119062d87d537b90e94258b923aa68d0d7b55973085fa101fd17.json index 9416aa1c..9cd8e6c8 100644 --- a/.sqlx/query-fa0010bcd72dfeef6216e15082001a8b74ccd0171d547294410c4d27cc5eaa6e.json +++ b/.sqlx/query-bd86a7435e9a119062d87d537b90e94258b923aa68d0d7b55973085fa101fd17.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_lc_light_cones.*,\n light_cones_text.name\n FROM\n warp_lc_light_cones\n LEFT JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $3\n WHERE\n warp_lc_light_cones.id = $1\n AND\n uid = $2\n ", + "query": "\n SELECT\n warp_lc_light_cones.*,\n light_cones_text.name\n FROM\n warp_lc_light_cones\n INNER JOIN\n light_cones_text\n ON\n light_cones_text.id = light_cone AND light_cones_text.language = $3\n WHERE\n warp_lc_light_cones.id = $1\n AND\n uid = $2\n ", "describe": { "columns": [ { @@ -44,5 +44,5 @@ false ] }, - "hash": "fa0010bcd72dfeef6216e15082001a8b74ccd0171d547294410c4d27cc5eaa6e" + "hash": "bd86a7435e9a119062d87d537b90e94258b923aa68d0d7b55973085fa101fd17" } diff --git a/.sqlx/query-2b29e22cad5d1a65b0fab39ad65bcc492d87c53881882a8e06980738b4eedfef.json b/.sqlx/query-bf3bd841cc3db181d4e4602f0403cb299a18216965539c2efa9fda8cdbc163ae.json similarity index 70% rename from .sqlx/query-2b29e22cad5d1a65b0fab39ad65bcc492d87c53881882a8e06980738b4eedfef.json rename to .sqlx/query-bf3bd841cc3db181d4e4602f0403cb299a18216965539c2efa9fda8cdbc163ae.json index 45d6e6a6..d744d01f 100644 --- a/.sqlx/query-2b29e22cad5d1a65b0fab39ad65bcc492d87c53881882a8e06980738b4eedfef.json +++ b/.sqlx/query-bf3bd841cc3db181d4e4602f0403cb299a18216965539c2efa9fda8cdbc163ae.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_standard_characters.*,\n characters_text.name\n FROM\n warp_standard_characters\n LEFT JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $3\n WHERE\n warp_standard_characters.id = $1\n AND\n uid = $2\n ", + "query": "\n SELECT\n warp_standard_characters.*,\n characters_text.name\n FROM\n warp_standard_characters\n INNER JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $3\n WHERE\n warp_standard_characters.id = $1\n AND\n uid = $2\n ", "describe": { "columns": [ { @@ -44,5 +44,5 @@ false ] }, - "hash": "2b29e22cad5d1a65b0fab39ad65bcc492d87c53881882a8e06980738b4eedfef" + "hash": "bf3bd841cc3db181d4e4602f0403cb299a18216965539c2efa9fda8cdbc163ae" } diff --git a/.sqlx/query-e93525d1cec5804bc86ea51db1897db6572421cb06a46d2beacec55ea6f6424f.json b/.sqlx/query-d54dc8f1d68f2549ef2c654d1ab6e08cf0f48977cc909fa5a18cb953f036d3a9.json similarity index 61% rename from .sqlx/query-e93525d1cec5804bc86ea51db1897db6572421cb06a46d2beacec55ea6f6424f.json rename to .sqlx/query-d54dc8f1d68f2549ef2c654d1ab6e08cf0f48977cc909fa5a18cb953f036d3a9.json index 6f87ec3a..bb3c2628 100644 --- a/.sqlx/query-e93525d1cec5804bc86ea51db1897db6572421cb06a46d2beacec55ea6f6424f.json +++ b/.sqlx/query-d54dc8f1d68f2549ef2c654d1ab6e08cf0f48977cc909fa5a18cb953f036d3a9.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT COUNT(*) FROM users WHERE (SELECT COUNT(*) FROM users_books WHERE users_books.username = users.username) >= 50", + "query": "SELECT COUNT(*) FROM users WHERE (SELECT COUNT(*) FROM users_books WHERE users_books.username = users.username) >= $1", "describe": { "columns": [ { @@ -10,11 +10,13 @@ } ], "parameters": { - "Left": [] + "Left": [ + "Int8" + ] }, "nullable": [ null ] }, - "hash": "e93525d1cec5804bc86ea51db1897db6572421cb06a46d2beacec55ea6f6424f" + "hash": "d54dc8f1d68f2549ef2c654d1ab6e08cf0f48977cc909fa5a18cb953f036d3a9" } diff --git a/.sqlx/query-e687f8eb574d07948df1d7131365bfc816107dd64dca4902421c40901b770650.json b/.sqlx/query-e687f8eb574d07948df1d7131365bfc816107dd64dca4902421c40901b770650.json new file mode 100644 index 00000000..51081abd --- /dev/null +++ b/.sqlx/query-e687f8eb574d07948df1d7131365bfc816107dd64dca4902421c40901b770650.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id,\n COUNT(*)\n FROM\n users_books\n JOIN\n (SELECT username FROM users_books GROUP BY username HAVING count(*) >= $1) counted_users\n ON\n users_books.username = counted_users.username\n GROUP BY\n id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + false, + null + ] + }, + "hash": "e687f8eb574d07948df1d7131365bfc816107dd64dca4902421c40901b770650" +} diff --git a/.sqlx/query-1b2ac2bf24ef3161958094ec5270c98f65cd41f7080449ce4d7cf7b0b8843b16.json b/.sqlx/query-ea7158526eac5fac6de2de7518c5310c51413b5aad22b494bfb582b3da82deca.json similarity index 77% rename from .sqlx/query-1b2ac2bf24ef3161958094ec5270c98f65cd41f7080449ce4d7cf7b0b8843b16.json rename to .sqlx/query-ea7158526eac5fac6de2de7518c5310c51413b5aad22b494bfb582b3da82deca.json index 65551752..df9ae030 100644 --- a/.sqlx/query-1b2ac2bf24ef3161958094ec5270c98f65cd41f7080449ce4d7cf7b0b8843b16.json +++ b/.sqlx/query-ea7158526eac5fac6de2de7518c5310c51413b5aad22b494bfb582b3da82deca.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_standard_characters.*,\n characters_text.name\n FROM\n warp_standard_characters\n LEFT JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", + "query": "\n SELECT\n warp_standard_characters.*,\n characters_text.name\n FROM\n warp_standard_characters\n INNER JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $2\n WHERE\n uid = $1\n ORDER BY\n timestamp\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ false ] }, - "hash": "1b2ac2bf24ef3161958094ec5270c98f65cd41f7080449ce4d7cf7b0b8843b16" + "hash": "ea7158526eac5fac6de2de7518c5310c51413b5aad22b494bfb582b3da82deca" } diff --git a/.sqlx/query-1b5e7b11bdfc5e8172491e50a72229f3adae4b68eb969f3faba1987ea9344a7d.json b/.sqlx/query-ecea2a6e436e6072a3b218926806392e2d3c177ea3b7ffa2dc0e921e0698c4ee.json similarity index 70% rename from .sqlx/query-1b5e7b11bdfc5e8172491e50a72229f3adae4b68eb969f3faba1987ea9344a7d.json rename to .sqlx/query-ecea2a6e436e6072a3b218926806392e2d3c177ea3b7ffa2dc0e921e0698c4ee.json index 807b7157..ed881648 100644 --- a/.sqlx/query-1b5e7b11bdfc5e8172491e50a72229f3adae4b68eb969f3faba1987ea9344a7d.json +++ b/.sqlx/query-ecea2a6e436e6072a3b218926806392e2d3c177ea3b7ffa2dc0e921e0698c4ee.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n warp_departure_characters.*,\n characters_text.name\n FROM\n warp_departure_characters\n LEFT JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $3\n WHERE\n warp_departure_characters.id = $1\n AND\n uid = $2\n ", + "query": "\n SELECT\n warp_departure_characters.*,\n characters_text.name\n FROM\n warp_departure_characters\n INNER JOIN\n characters_text\n ON\n characters_text.id = character AND characters_text.language = $3\n WHERE\n warp_departure_characters.id = $1\n AND\n uid = $2\n ", "describe": { "columns": [ { @@ -44,5 +44,5 @@ false ] }, - "hash": "1b5e7b11bdfc5e8172491e50a72229f3adae4b68eb969f3faba1987ea9344a7d" + "hash": "ecea2a6e436e6072a3b218926806392e2d3c177ea3b7ffa2dc0e921e0698c4ee" } diff --git a/src/database/achievements.rs b/src/database/achievements.rs index af63fed3..79dea121 100644 --- a/src/database/achievements.rs +++ b/src/database/achievements.rs @@ -111,15 +111,6 @@ pub async fn get_achievements(language: &str, pool: &PgPool) -> Result Result> { - Ok(sqlx::query!("SELECT id FROM achievements") - .fetch_all(pool) - .await? - .into_iter() - .map(|r| r.id) - .collect()) -} - pub async fn get_related(id: i64, set: i32, pool: &PgPool) -> Result> { Ok(sqlx::query!( " diff --git a/src/database/book_series.rs b/src/database/book_series.rs index eafdd64e..0cab48ae 100644 --- a/src/database/book_series.rs +++ b/src/database/book_series.rs @@ -46,7 +46,7 @@ pub async fn get_book_series(language: &str, pool: &PgPool) -> Result Re INNER JOIN book_series_worlds_text ON - book_series_worlds_text.id = book_series.id AND book_series_worlds_text.language = $2 + book_series_worlds_text.id = book_series.world AND book_series_worlds_text.language = $2 WHERE book_series.id = $1 ", diff --git a/src/database/books.rs b/src/database/books.rs index 955ed2ca..4bb21d9f 100644 --- a/src/database/books.rs +++ b/src/database/books.rs @@ -116,12 +116,3 @@ pub async fn get_book_by_id(id: i64, language: &str, pool: &PgPool) -> Result Result> { - Ok(sqlx::query!("SELECT id FROM books") - .fetch_all(pool) - .await? - .into_iter() - .map(|r| r.id) - .collect()) -} diff --git a/src/database/users_achievements.rs b/src/database/users_achievements.rs index a15d5956..2c44cce7 100644 --- a/src/database/users_achievements.rs +++ b/src/database/users_achievements.rs @@ -1,6 +1,8 @@ use anyhow::Result; use sqlx::PgPool; +const THRESHOLD: i64 = 50; + pub struct DbUserAchievement { pub username: String, pub id: i64, @@ -55,14 +57,6 @@ pub async fn delete_user_achievement( Ok(()) } -pub async fn get_users_achievements(pool: &PgPool) -> Result> { - Ok( - sqlx::query_as!(DbUserAchievement, "SELECT * FROM users_achievements") - .fetch_all(pool) - .await?, - ) -} - pub async fn get_user_achievements_by_username( username: &str, pool: &PgPool, @@ -78,10 +72,37 @@ pub async fn get_user_achievements_by_username( pub async fn get_users_achievements_user_count(pool: &PgPool) -> Result { Ok( - sqlx::query!("SELECT COUNT(*) FROM users WHERE (SELECT COUNT(*) FROM users_achievements WHERE users_achievements.username = users.username) >= 50") + sqlx::query!("SELECT COUNT(*) FROM users WHERE (SELECT COUNT(*) FROM users_achievements WHERE users_achievements.username = users.username) >= $1", THRESHOLD) .fetch_one(pool) .await? .count .unwrap_or_default(), ) } + +pub struct DbAchievementUsersCount { + pub id: i64, + pub count: Option, +} + +pub async fn get_achievements_users_count(pool: &PgPool) -> Result> { + Ok(sqlx::query_as!( + DbAchievementUsersCount, + " + SELECT + id, + COUNT(*) + FROM + users_achievements + JOIN + (SELECT username FROM users_achievements GROUP BY username HAVING count(*) >= $1) counted_users + ON + users_achievements.username = counted_users.username + GROUP BY + id + ", + THRESHOLD, + ) + .fetch_all(pool) + .await?) +} diff --git a/src/database/users_books.rs b/src/database/users_books.rs index ef77cb77..1852c533 100644 --- a/src/database/users_books.rs +++ b/src/database/users_books.rs @@ -1,6 +1,8 @@ use anyhow::Result; use sqlx::PgPool; +const THRESHOLD: i64 = 50; + pub struct DbUserBook { pub username: String, pub id: i64, @@ -30,12 +32,6 @@ pub async fn delete_user_book(user_book: &DbUserBook, pool: &PgPool) -> Result<( Ok(()) } -pub async fn get_users_books(pool: &PgPool) -> Result> { - Ok(sqlx::query_as!(DbUserBook, "SELECT * FROM users_books") - .fetch_all(pool) - .await?) -} - pub async fn get_user_books_by_username(username: &str, pool: &PgPool) -> Result> { Ok(sqlx::query_as!( DbUserBook, @@ -48,10 +44,37 @@ pub async fn get_user_books_by_username(username: &str, pool: &PgPool) -> Result pub async fn get_users_books_user_count(pool: &PgPool) -> Result { Ok( - sqlx::query!("SELECT COUNT(*) FROM users WHERE (SELECT COUNT(*) FROM users_books WHERE users_books.username = users.username) >= 50") + sqlx::query!("SELECT COUNT(*) FROM users WHERE (SELECT COUNT(*) FROM users_books WHERE users_books.username = users.username) >= $1", THRESHOLD) .fetch_one(pool) .await? .count .unwrap_or_default(), ) } + +pub struct DbBookUsersCount { + pub id: i64, + pub count: Option, +} + +pub async fn get_books_users_count(pool: &PgPool) -> Result> { + Ok(sqlx::query_as!( + DbBookUsersCount, + " + SELECT + id, + COUNT(*) + FROM + users_books + JOIN + (SELECT username FROM users_books GROUP BY username HAVING count(*) >= $1) counted_users + ON + users_books.username = counted_users.username + GROUP BY + id + ", + THRESHOLD, + ) + .fetch_all(pool) + .await?) +} diff --git a/src/database/warp_departure_characters.rs b/src/database/warp_departure_characters.rs index d2a166a2..77e60ffa 100644 --- a/src/database/warp_departure_characters.rs +++ b/src/database/warp_departure_characters.rs @@ -50,7 +50,7 @@ pub async fn get_warp_departure_characters_by_uid( characters_text.name FROM warp_departure_characters - LEFT JOIN + INNER JOIN characters_text ON characters_text.id = character AND characters_text.language = $2 @@ -80,7 +80,7 @@ pub async fn get_warp_departure_character_by_id_and_uid( characters_text.name FROM warp_departure_characters - LEFT JOIN + INNER JOIN characters_text ON characters_text.id = character AND characters_text.language = $3 diff --git a/src/database/warp_departure_light_cones.rs b/src/database/warp_departure_light_cones.rs index cd5317ff..d1976f88 100644 --- a/src/database/warp_departure_light_cones.rs +++ b/src/database/warp_departure_light_cones.rs @@ -50,7 +50,7 @@ pub async fn get_warp_departure_light_cones_by_uid( light_cones_text.name FROM warp_departure_light_cones - LEFT JOIN + INNER JOIN light_cones_text ON light_cones_text.id = light_cone AND light_cones_text.language = $2 @@ -80,7 +80,7 @@ pub async fn get_warp_departure_light_cone_by_id_and_uid( light_cones_text.name FROM warp_departure_light_cones - LEFT JOIN + INNER JOIN light_cones_text ON light_cones_text.id = light_cone AND light_cones_text.language = $3 diff --git a/src/database/warp_lc_characters.rs b/src/database/warp_lc_characters.rs index dcea5e0c..f3e6f36c 100644 --- a/src/database/warp_lc_characters.rs +++ b/src/database/warp_lc_characters.rs @@ -50,7 +50,7 @@ pub async fn get_warp_lc_characters_by_uid( characters_text.name FROM warp_lc_characters - LEFT JOIN + INNER JOIN characters_text ON characters_text.id = character AND characters_text.language = $2 @@ -80,7 +80,7 @@ pub async fn get_warp_lc_character_by_id_and_uid( characters_text.name FROM warp_lc_characters - LEFT JOIN + INNER JOIN characters_text ON characters_text.id = character AND characters_text.language = $3 diff --git a/src/database/warp_lc_light_cones.rs b/src/database/warp_lc_light_cones.rs index 0413dc99..ed701faf 100644 --- a/src/database/warp_lc_light_cones.rs +++ b/src/database/warp_lc_light_cones.rs @@ -50,7 +50,7 @@ pub async fn get_warp_lc_light_cones_by_uid( light_cones_text.name FROM warp_lc_light_cones - LEFT JOIN + INNER JOIN light_cones_text ON light_cones_text.id = light_cone AND light_cones_text.language = $2 @@ -80,7 +80,7 @@ pub async fn get_warp_lc_light_cone_by_id_and_uid( light_cones_text.name FROM warp_lc_light_cones - LEFT JOIN + INNER JOIN light_cones_text ON light_cones_text.id = light_cone AND light_cones_text.language = $3 diff --git a/src/database/warp_special_characters.rs b/src/database/warp_special_characters.rs index fecd1037..cf0745f6 100644 --- a/src/database/warp_special_characters.rs +++ b/src/database/warp_special_characters.rs @@ -50,7 +50,7 @@ pub async fn get_warp_special_characters_by_uid( characters_text.name FROM warp_special_characters - LEFT JOIN + INNER JOIN characters_text ON characters_text.id = character AND characters_text.language = $2 @@ -80,7 +80,7 @@ pub async fn get_warp_special_character_by_id_and_uid( characters_text.name FROM warp_special_characters - LEFT JOIN + INNER JOIN characters_text ON characters_text.id = character AND characters_text.language = $3 diff --git a/src/database/warp_special_light_cones.rs b/src/database/warp_special_light_cones.rs index 7702cec8..1e7d73b1 100644 --- a/src/database/warp_special_light_cones.rs +++ b/src/database/warp_special_light_cones.rs @@ -50,7 +50,7 @@ pub async fn get_warp_special_light_cones_by_uid( light_cones_text.name FROM warp_special_light_cones - LEFT JOIN + INNER JOIN light_cones_text ON light_cones_text.id = light_cone AND light_cones_text.language = $2 @@ -80,7 +80,7 @@ pub async fn get_warp_special_light_cone_by_id_and_uid( light_cones_text.name FROM warp_special_light_cones - LEFT JOIN + INNER JOIN light_cones_text ON light_cones_text.id = light_cone AND light_cones_text.language = $3 diff --git a/src/database/warp_standard_characters.rs b/src/database/warp_standard_characters.rs index c0921e8a..8b88ce50 100644 --- a/src/database/warp_standard_characters.rs +++ b/src/database/warp_standard_characters.rs @@ -50,7 +50,7 @@ pub async fn get_warp_standard_characters_by_uid( characters_text.name FROM warp_standard_characters - LEFT JOIN + INNER JOIN characters_text ON characters_text.id = character AND characters_text.language = $2 @@ -80,7 +80,7 @@ pub async fn get_warp_standard_character_by_id_and_uid( characters_text.name FROM warp_standard_characters - LEFT JOIN + INNER JOIN characters_text ON characters_text.id = character AND characters_text.language = $3 diff --git a/src/database/warp_standard_light_cones.rs b/src/database/warp_standard_light_cones.rs index d6986b01..6807102b 100644 --- a/src/database/warp_standard_light_cones.rs +++ b/src/database/warp_standard_light_cones.rs @@ -50,7 +50,7 @@ pub async fn get_warp_standard_light_cones_by_uid( light_cones_text.name FROM warp_standard_light_cones - LEFT JOIN + INNER JOIN light_cones_text ON light_cones_text.id = light_cone AND light_cones_text.language = $2 @@ -80,7 +80,7 @@ pub async fn get_warp_standard_light_cone_by_id_and_uid( light_cones_text.name FROM warp_standard_light_cones - LEFT JOIN + INNER JOIN light_cones_text ON light_cones_text.id = light_cone AND light_cones_text.language = $3 diff --git a/src/update/achievements_percent.rs b/src/update/achievements_percent.rs index 3166973c..99680a73 100644 --- a/src/update/achievements_percent.rs +++ b/src/update/achievements_percent.rs @@ -1,7 +1,4 @@ -use std::{ - collections::HashMap, - time::{Duration, Instant}, -}; +use std::time::{Duration, Instant}; use anyhow::Result; use sqlx::PgPool; @@ -10,7 +7,7 @@ use crate::database; pub async fn achievements_percent(pool: PgPool) { tokio::spawn(async move { - let mut interval = tokio::time::interval(Duration::from_secs(60)); + let mut interval = tokio::time::interval(Duration::from_secs(5 * 60)); loop { interval.tick().await; @@ -33,33 +30,13 @@ pub async fn achievements_percent(pool: PgPool) { } async fn update(pool: &PgPool) -> Result<()> { - let completed = database::get_users_achievements(pool).await?; + let total_count = database::get_users_achievements_user_count(pool).await? as f64; - let mut usernames_achievements: HashMap> = HashMap::new(); + let achievements_users_count = database::get_achievements_users_count(pool).await?; - for completed in &completed { - usernames_achievements - .entry(completed.username.clone()) - .or_default() - .push(completed.id) - } - - let mut achievements_count: HashMap = HashMap::new(); - - for achievements in usernames_achievements.values().filter(|v| v.len() >= 50) { - for &achievement in achievements { - *achievements_count.entry(achievement).or_default() += 1; - } - } - - let achievements_id = database::get_achievements_id(pool).await?; - - for id in achievements_id { - let percent = if let Some(&count) = achievements_count.get(&id) { - count as f64 / usernames_achievements.len() as f64 - } else { - 0.0 - }; + for achievement_users_count in achievements_users_count { + let id = achievement_users_count.id; + let percent = achievement_users_count.count.unwrap_or_default() as f64 / total_count; let achievement_percent = database::DbAchievementPercent { id, percent }; diff --git a/src/update/books_percent.rs b/src/update/books_percent.rs index b1e1c80e..b0bfe438 100644 --- a/src/update/books_percent.rs +++ b/src/update/books_percent.rs @@ -1,7 +1,4 @@ -use std::{ - collections::HashMap, - time::{Duration, Instant}, -}; +use std::time::{Duration, Instant}; use anyhow::Result; use sqlx::PgPool; @@ -10,7 +7,7 @@ use crate::database; pub async fn books_percent(pool: PgPool) { tokio::spawn(async move { - let mut interval = tokio::time::interval(Duration::from_secs(60)); + let mut interval = tokio::time::interval(Duration::from_secs(5 * 60)); loop { interval.tick().await; @@ -33,33 +30,13 @@ pub async fn books_percent(pool: PgPool) { } async fn update(pool: &PgPool) -> Result<()> { - let completed = database::get_users_books(pool).await?; + let total_count = database::get_users_books_user_count(pool).await? as f64; - let mut usernames_books: HashMap> = HashMap::new(); + let books_users_count = database::get_books_users_count(pool).await?; - for completed in &completed { - usernames_books - .entry(completed.username.clone()) - .or_default() - .push(completed.id) - } - - let mut books_count: HashMap = HashMap::new(); - - for books in usernames_books.values().filter(|v| v.len() >= 50) { - for &book in books { - *books_count.entry(book).or_default() += 1; - } - } - - let books_id = database::get_books_id(pool).await?; - - for id in books_id { - let percent = if let Some(&count) = books_count.get(&id) { - count as f64 / usernames_books.len() as f64 - } else { - 0.0 - }; + for book_users_count in books_users_count { + let id = book_users_count.id; + let percent = book_users_count.count.unwrap_or_default() as f64 / total_count; let book_percent = database::DbBookPercent { id, percent };