From 65c380f3a856a42560fcd394af47071cbdc5ee44 Mon Sep 17 00:00:00 2001 From: Wyatt Verchere Date: Mon, 6 Nov 2023 17:37:52 -0800 Subject: [PATCH] fmt, clippy, prepare, etc --- ...ab462fa4e716f92c8700c436dee9472101aa4.json | 130 ------------- ...78905a8439a12c9ec94042016e607c9788c98.json | 174 ----------------- ...7f825f9f5fe2d538b06337ef182ab1a553398.json | 22 --- ...cb33806e14c33bb76d63c2711f822c44261f6.json | 22 --- ...f400c06f9c8a8132fd7a05dcc55c6eab5d2e7.json | 126 ++++++++++++ ...fcee16c613fb93ea74d6eb0da684363ca7b13.json | 28 +++ ...9e7e5ebfd8d34985a1a8209d6628e66490f37.json | 22 --- ...2df15841d35b96fbdcadc7d5af8d6b4671f9e.json | 44 +++++ ...a6de53aeadacb33bd3134dae2d9c8f8a18651.json | 142 ++++++++++++++ ...bf9633f160dfb783cefa751ff400655e8660f.json | 114 ----------- ...dbd027fc0bd427bfba5e6eb99c989af53b680.json | 180 ++++++++++++++++++ ...a2134e2f26eed002ff9ea5626ea3e23518594.json | 22 --- ...cde031df280039cd8e435cfca5e15ed3d1c4.json} | 98 +++++----- ...c3b0d629c470f654f1e30250bd8773ed04f5b.json | 40 ---- ...707d698fc8b4dbb66d2830f4ec0229bc1019.json} | 5 +- src/database/models/categories.rs | 7 +- src/database/models/loader_fields.rs | 6 +- src/database/models/project_item.rs | 6 +- src/models/mod.rs | 2 +- src/models/v3/mod.rs | 2 +- src/routes/maven.rs | 2 +- src/routes/v2/analytics_get.rs | 27 +-- src/routes/v2/collections.rs | 48 ++--- src/routes/v2/images.rs | 27 ++- src/routes/v2/moderation.rs | 11 +- src/routes/v2/notifications.rs | 35 +--- src/routes/v2/organizations.rs | 40 ++-- src/routes/v2/project_creation.rs | 88 +++++---- src/routes/v2/projects.rs | 40 ++-- src/routes/v2/reports.rs | 36 +--- src/routes/v2/statistics.rs | 2 +- src/routes/v2/tags.rs | 33 +--- src/routes/v2/teams.rs | 73 ++++--- src/routes/v2/threads.rs | 31 +-- src/routes/v2/users.rs | 50 +++-- src/routes/v2/version_file.rs | 3 +- src/routes/v2/versions.rs | 3 +- src/routes/v3/analytics_get.rs | 5 +- src/routes/v3/mod.rs | 2 +- src/routes/v3/notifications.rs | 12 +- src/routes/v3/organizations.rs | 28 +-- src/routes/v3/project_creation.rs | 36 ++-- src/routes/v3/projects.rs | 45 +++-- src/routes/v3/tags.rs | 25 ++- src/routes/v3/teams.rs | 15 +- src/routes/v3/threads.rs | 6 +- src/routes/v3/users.rs | 53 +++--- src/routes/v3/version_creation.rs | 85 +++++---- src/routes/v3/version_file.rs | 1 - src/routes/v3/versions.rs | 48 +++-- src/validate/mod.rs | 4 +- tests/common/dummy_data.rs | 13 +- tests/tags.rs | 5 +- 53 files changed, 1063 insertions(+), 1061 deletions(-) delete mode 100644 .sqlx/query-168b16d302b780700c2ad909aecab462fa4e716f92c8700c436dee9472101aa4.json delete mode 100644 .sqlx/query-1cd4d592f7c230b3587a9f6d0ec78905a8439a12c9ec94042016e607c9788c98.json delete mode 100644 .sqlx/query-1d6f3e926fc4a27c5af172f672b7f825f9f5fe2d538b06337ef182ab1a553398.json delete mode 100644 .sqlx/query-21ef50f46b7b3e62b91e7d067c1cb33806e14c33bb76d63c2711f822c44261f6.json create mode 100644 .sqlx/query-3afbc93a8945e7ae07e39a88752f400c06f9c8a8132fd7a05dcc55c6eab5d2e7.json create mode 100644 .sqlx/query-683e186dc086ef21d2f82c0d427fcee16c613fb93ea74d6eb0da684363ca7b13.json delete mode 100644 .sqlx/query-72d6b5f2f11d88981db82c7247c9e7e5ebfd8d34985a1a8209d6628e66490f37.json create mode 100644 .sqlx/query-923d1d1e5e9b879479a244479952df15841d35b96fbdcadc7d5af8d6b4671f9e.json create mode 100644 .sqlx/query-a377a9953cc222848dcad095cf4a6de53aeadacb33bd3134dae2d9c8f8a18651.json delete mode 100644 .sqlx/query-bc662b93312190ce868135248dfbf9633f160dfb783cefa751ff400655e8660f.json create mode 100644 .sqlx/query-cab90ea34929643f9e9814150c4dbd027fc0bd427bfba5e6eb99c989af53b680.json delete mode 100644 .sqlx/query-ef59f99fc0ab66ff5779d0e71c4a2134e2f26eed002ff9ea5626ea3e23518594.json rename .sqlx/{query-baa0615e8abc97e5529cff39ffed4e740b51b303aaf533662285061e7f5c0bca.json => query-f73ffab12a96eb9480615e333d40cde031df280039cd8e435cfca5e15ed3d1c4.json} (58%) delete mode 100644 .sqlx/query-fd6c1accdafbeab3142b7fab397c3b0d629c470f654f1e30250bd8773ed04f5b.json rename .sqlx/{query-b26c1b47aefa6df4a0daf39a83151e7168f7cc483d219813e4c70f5f805e84a3.json => query-fefb4f07a0f0c0cf74e554d120f8707d698fc8b4dbb66d2830f4ec0229bc1019.json} (63%) diff --git a/.sqlx/query-168b16d302b780700c2ad909aecab462fa4e716f92c8700c436dee9472101aa4.json b/.sqlx/query-168b16d302b780700c2ad909aecab462fa4e716f92c8700c436dee9472101aa4.json deleted file mode 100644 index ddbe02ed..00000000 --- a/.sqlx/query-168b16d302b780700c2ad909aecab462fa4e716f92c8700c436dee9472101aa4.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT v.id id, v.mod_id mod_id, v.author_id author_id, v.name version_name, v.version_number version_number,\n v.changelog changelog, v.date_published date_published, v.downloads downloads,\n v.version_type version_type, v.featured featured, v.status status, v.requested_status requested_status,\n ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null) loaders,\n JSONB_AGG(DISTINCT jsonb_build_object('id', f.id, 'url', f.url, 'filename', f.filename, 'primary', f.is_primary, 'size', f.size, 'file_type', f.file_type)) filter (where f.id is not null) files,\n JSONB_AGG(DISTINCT jsonb_build_object('algorithm', h.algorithm, 'hash', encode(h.hash, 'escape'), 'file_id', h.file_id)) filter (where h.hash is not null) hashes,\n JSONB_AGG(DISTINCT jsonb_build_object('project_id', d.mod_dependency_id, 'version_id', d.dependency_id, 'dependency_type', d.dependency_type,'file_name', dependency_file_name)) filter (where d.dependency_type is not null) dependencies,\n \n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'field_id', vf.field_id,\n 'int_value', vf.int_value,\n 'enum_value', vf.enum_value,\n 'string_value', vf.string_value\n )\n ) filter (where vf.field_id is not null) version_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'lf_id', lf.id,\n 'loader_name', l.loader,\n 'field', lf.field,\n 'field_type', lf.field_type,\n 'enum_type', lf.enum_type,\n 'min_val', lf.min_val,\n 'max_val', lf.max_val,\n 'optional', lf.optional\n )\n ) filter (where lf.id is not null) loader_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'id', lfev.id,\n 'enum_id', lfev.enum_id,\n 'value', lfev.value,\n 'ordering', lfev.ordering,\n 'created', lfev.created,\n 'metadata', lfev.metadata\n ) \n ) filter (where lfev.id is not null) loader_field_enum_values\n \n FROM versions v\n LEFT OUTER JOIN loaders_versions lv on v.id = lv.version_id\n LEFT OUTER JOIN loaders l on lv.loader_id = l.id\n LEFT OUTER JOIN files f on v.id = f.version_id\n LEFT OUTER JOIN hashes h on f.id = h.file_id\n LEFT OUTER JOIN dependencies d on v.id = d.dependent_id\n LEFT OUTER JOIN version_fields vf on v.id = vf.version_id\n LEFT OUTER JOIN loader_fields lf on vf.field_id = lf.id\n LEFT OUTER JOIN loader_field_enums lfe on lf.enum_type = lfe.id\n LEFT OUTER JOIN loader_field_enum_values lfev on lfe.id = lfev.enum_id\n\n WHERE v.id = ANY($1)\n GROUP BY v.id\n ORDER BY v.date_published ASC;\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int8" - }, - { - "ordinal": 1, - "name": "mod_id", - "type_info": "Int8" - }, - { - "ordinal": 2, - "name": "author_id", - "type_info": "Int8" - }, - { - "ordinal": 3, - "name": "version_name", - "type_info": "Varchar" - }, - { - "ordinal": 4, - "name": "version_number", - "type_info": "Varchar" - }, - { - "ordinal": 5, - "name": "changelog", - "type_info": "Varchar" - }, - { - "ordinal": 6, - "name": "date_published", - "type_info": "Timestamptz" - }, - { - "ordinal": 7, - "name": "downloads", - "type_info": "Int4" - }, - { - "ordinal": 8, - "name": "version_type", - "type_info": "Varchar" - }, - { - "ordinal": 9, - "name": "featured", - "type_info": "Bool" - }, - { - "ordinal": 10, - "name": "status", - "type_info": "Varchar" - }, - { - "ordinal": 11, - "name": "requested_status", - "type_info": "Varchar" - }, - { - "ordinal": 12, - "name": "loaders", - "type_info": "VarcharArray" - }, - { - "ordinal": 13, - "name": "files", - "type_info": "Jsonb" - }, - { - "ordinal": 14, - "name": "hashes", - "type_info": "Jsonb" - }, - { - "ordinal": 15, - "name": "dependencies", - "type_info": "Jsonb" - }, - { - "ordinal": 16, - "name": "version_fields", - "type_info": "Jsonb" - }, - { - "ordinal": 17, - "name": "loader_fields", - "type_info": "Jsonb" - }, - { - "ordinal": 18, - "name": "loader_field_enum_values", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Int8Array" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - true, - null, - null, - null, - null, - null, - null, - null - ] - }, - "hash": "168b16d302b780700c2ad909aecab462fa4e716f92c8700c436dee9472101aa4" -} diff --git a/.sqlx/query-1cd4d592f7c230b3587a9f6d0ec78905a8439a12c9ec94042016e607c9788c98.json b/.sqlx/query-1cd4d592f7c230b3587a9f6d0ec78905a8439a12c9ec94042016e607c9788c98.json deleted file mode 100644 index 413d087f..00000000 --- a/.sqlx/query-1cd4d592f7c230b3587a9f6d0ec78905a8439a12c9ec94042016e607c9788c98.json +++ /dev/null @@ -1,174 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT m.id id, v.id version_id, m.project_type project_type, m.title title, m.description description, m.downloads downloads, m.follows follows,\n m.icon_url icon_url, m.published published, m.approved approved, m.updated updated,\n m.team_id team_id, m.license license, m.slug slug, m.status status_name, m.color color,\n pt.name project_type_name, u.username username,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,\n ARRAY_AGG(DISTINCT lo.loader) filter (where lo.loader is not null) loaders,\n ARRAY_AGG(DISTINCT mg.image_url) filter (where mg.image_url is not null and mg.featured is false) gallery,\n ARRAY_AGG(DISTINCT mg.image_url) filter (where mg.image_url is not null and mg.featured is true) featured_gallery,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'field_id', vf.field_id,\n 'int_value', vf.int_value,\n 'enum_value', vf.enum_value,\n 'string_value', vf.string_value\n )\n ) filter (where vf.field_id is not null) version_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'lf_id', lf.id,\n 'loader_name', lo.loader,\n 'field', lf.field,\n 'field_type', lf.field_type,\n 'enum_type', lf.enum_type,\n 'min_val', lf.min_val,\n 'max_val', lf.max_val,\n 'optional', lf.optional\n )\n ) filter (where lf.id is not null) loader_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'id', lfev.id,\n 'enum_id', lfev.enum_id,\n 'value', lfev.value,\n 'ordering', lfev.ordering,\n 'created', lfev.created,\n 'metadata', lfev.metadata\n ) \n ) filter (where lfev.id is not null) loader_field_enum_values\n\n \n FROM versions v\n INNER JOIN mods m ON v.mod_id = m.id AND m.status = ANY($2)\n LEFT OUTER JOIN mods_categories mc ON joining_mod_id = m.id\n LEFT OUTER JOIN categories c ON mc.joining_category_id = c.id\n LEFT OUTER JOIN loaders_versions lv ON lv.version_id = v.id\n LEFT OUTER JOIN loaders lo ON lo.id = lv.loader_id\n LEFT OUTER JOIN mods_gallery mg ON mg.mod_id = m.id\n INNER JOIN project_types pt ON pt.id = m.project_type\n INNER JOIN team_members tm ON tm.team_id = m.team_id AND tm.role = $3 AND tm.accepted = TRUE\n INNER JOIN users u ON tm.user_id = u.id\n LEFT OUTER JOIN version_fields vf on v.id = vf.version_id\n LEFT OUTER JOIN loader_fields lf on vf.field_id = lf.id\n LEFT OUTER JOIN loader_field_enums lfe on lf.enum_type = lfe.id\n LEFT OUTER JOIN loader_field_enum_values lfev on lfev.enum_id = lfe.id\n WHERE v.status != ANY($1)\n GROUP BY v.id, m.id, pt.id, u.id;\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int8" - }, - { - "ordinal": 1, - "name": "version_id", - "type_info": "Int8" - }, - { - "ordinal": 2, - "name": "project_type", - "type_info": "Int4" - }, - { - "ordinal": 3, - "name": "title", - "type_info": "Varchar" - }, - { - "ordinal": 4, - "name": "description", - "type_info": "Varchar" - }, - { - "ordinal": 5, - "name": "downloads", - "type_info": "Int4" - }, - { - "ordinal": 6, - "name": "follows", - "type_info": "Int4" - }, - { - "ordinal": 7, - "name": "icon_url", - "type_info": "Varchar" - }, - { - "ordinal": 8, - "name": "published", - "type_info": "Timestamptz" - }, - { - "ordinal": 9, - "name": "approved", - "type_info": "Timestamptz" - }, - { - "ordinal": 10, - "name": "updated", - "type_info": "Timestamptz" - }, - { - "ordinal": 11, - "name": "team_id", - "type_info": "Int8" - }, - { - "ordinal": 12, - "name": "license", - "type_info": "Varchar" - }, - { - "ordinal": 13, - "name": "slug", - "type_info": "Varchar" - }, - { - "ordinal": 14, - "name": "status_name", - "type_info": "Varchar" - }, - { - "ordinal": 15, - "name": "color", - "type_info": "Int4" - }, - { - "ordinal": 16, - "name": "project_type_name", - "type_info": "Varchar" - }, - { - "ordinal": 17, - "name": "username", - "type_info": "Varchar" - }, - { - "ordinal": 18, - "name": "categories", - "type_info": "VarcharArray" - }, - { - "ordinal": 19, - "name": "additional_categories", - "type_info": "VarcharArray" - }, - { - "ordinal": 20, - "name": "loaders", - "type_info": "VarcharArray" - }, - { - "ordinal": 21, - "name": "gallery", - "type_info": "VarcharArray" - }, - { - "ordinal": 22, - "name": "featured_gallery", - "type_info": "VarcharArray" - }, - { - "ordinal": 23, - "name": "version_fields", - "type_info": "Jsonb" - }, - { - "ordinal": 24, - "name": "loader_fields", - "type_info": "Jsonb" - }, - { - "ordinal": 25, - "name": "loader_field_enum_values", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "TextArray", - "TextArray", - "Text" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - false, - false, - true, - false, - true, - false, - false, - false, - true, - false, - true, - false, - false, - null, - null, - null, - null, - null, - null, - null, - null - ] - }, - "hash": "1cd4d592f7c230b3587a9f6d0ec78905a8439a12c9ec94042016e607c9788c98" -} diff --git a/.sqlx/query-1d6f3e926fc4a27c5af172f672b7f825f9f5fe2d538b06337ef182ab1a553398.json b/.sqlx/query-1d6f3e926fc4a27c5af172f672b7f825f9f5fe2d538b06337ef182ab1a553398.json deleted file mode 100644 index 5b3eb4aa..00000000 --- a/.sqlx/query-1d6f3e926fc4a27c5af172f672b7f825f9f5fe2d538b06337ef182ab1a553398.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT name FROM project_types pt\n INNER JOIN mods ON mods.project_type = pt.id\n WHERE mods.id = $1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "name", - "type_info": "Varchar" - } - ], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [ - false - ] - }, - "hash": "1d6f3e926fc4a27c5af172f672b7f825f9f5fe2d538b06337ef182ab1a553398" -} diff --git a/.sqlx/query-21ef50f46b7b3e62b91e7d067c1cb33806e14c33bb76d63c2711f822c44261f6.json b/.sqlx/query-21ef50f46b7b3e62b91e7d067c1cb33806e14c33bb76d63c2711f822c44261f6.json deleted file mode 100644 index 2212ad16..00000000 --- a/.sqlx/query-21ef50f46b7b3e62b91e7d067c1cb33806e14c33bb76d63c2711f822c44261f6.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT name FROM project_types pt\n INNER JOIN mods ON mods.project_type = pt.id\n WHERE mods.id = $1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "name", - "type_info": "Varchar" - } - ], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [ - false - ] - }, - "hash": "21ef50f46b7b3e62b91e7d067c1cb33806e14c33bb76d63c2711f822c44261f6" -} diff --git a/.sqlx/query-3afbc93a8945e7ae07e39a88752f400c06f9c8a8132fd7a05dcc55c6eab5d2e7.json b/.sqlx/query-3afbc93a8945e7ae07e39a88752f400c06f9c8a8132fd7a05dcc55c6eab5d2e7.json new file mode 100644 index 00000000..0ecfb803 --- /dev/null +++ b/.sqlx/query-3afbc93a8945e7ae07e39a88752f400c06f9c8a8132fd7a05dcc55c6eab5d2e7.json @@ -0,0 +1,126 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT m.id id, m.title title, m.description description, m.color color,\n m.icon_url icon_url, m.slug slug,\n pt.name project_type, u.username username, u.avatar_url avatar_url,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null) categories,\n ARRAY_AGG(DISTINCT lo.loader) filter (where lo.loader is not null) loaders,\n ARRAY_AGG(DISTINCT pt.name) filter (where pt.name is not null) project_types,\n ARRAY_AGG(DISTINCT g.name) filter (where g.name is not null) games,\n ARRAY_AGG(DISTINCT mg.image_url) filter (where mg.image_url is not null and mg.featured is false) gallery,\n ARRAY_AGG(DISTINCT mg.image_url) filter (where mg.image_url is not null and mg.featured is true) featured_gallery,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'field_id', vf.field_id,\n 'int_value', vf.int_value,\n 'enum_value', vf.enum_value,\n 'string_value', vf.string_value\n )\n ) filter (where vf.field_id is not null) version_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'lf_id', lf.id,\n 'loader_name', lo.loader,\n 'field', lf.field,\n 'field_type', lf.field_type,\n 'enum_type', lf.enum_type,\n 'min_val', lf.min_val,\n 'max_val', lf.max_val,\n 'optional', lf.optional\n )\n ) filter (where lf.id is not null) loader_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'id', lfev.id,\n 'enum_id', lfev.enum_id,\n 'value', lfev.value,\n 'ordering', lfev.ordering,\n 'created', lfev.created,\n 'metadata', lfev.metadata\n ) \n ) filter (where lfev.id is not null) loader_field_enum_values\n FROM mods m\n LEFT OUTER JOIN mods_categories mc ON joining_mod_id = m.id AND mc.is_additional = FALSE\n LEFT OUTER JOIN categories c ON mc.joining_category_id = c.id\n LEFT OUTER JOIN versions v ON v.mod_id = m.id AND v.status != ALL($2)\n LEFT OUTER JOIN loaders_versions lv ON lv.version_id = v.id\n LEFT OUTER JOIN loaders lo ON lo.id = lv.loader_id\n LEFT JOIN loaders_project_types lpt ON lpt.joining_loader_id = lo.id\n LEFT JOIN project_types pt ON pt.id = lpt.joining_project_type_id\n LEFT JOIN loaders_project_types_games lptg ON lptg.loader_id = lo.id AND lptg.project_type_id = pt.id\n LEFT JOIN games g ON lptg.game_id = g.id\n LEFT OUTER JOIN mods_gallery mg ON mg.mod_id = m.id\n INNER JOIN team_members tm ON tm.team_id = m.team_id AND tm.role = $3 AND tm.accepted = TRUE\n INNER JOIN users u ON tm.user_id = u.id\n LEFT OUTER JOIN version_fields vf on v.id = vf.version_id\n LEFT OUTER JOIN loader_fields lf on vf.field_id = lf.id\n LEFT OUTER JOIN loader_field_enums lfe on lf.enum_type = lfe.id\n LEFT OUTER JOIN loader_field_enum_values lfev on lfev.enum_id = lfe.id\n WHERE m.id = $1\n GROUP BY m.id, pt.id, u.id;\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "title", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "description", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "color", + "type_info": "Int4" + }, + { + "ordinal": 4, + "name": "icon_url", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "slug", + "type_info": "Varchar" + }, + { + "ordinal": 6, + "name": "project_type", + "type_info": "Varchar" + }, + { + "ordinal": 7, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 8, + "name": "avatar_url", + "type_info": "Varchar" + }, + { + "ordinal": 9, + "name": "categories", + "type_info": "VarcharArray" + }, + { + "ordinal": 10, + "name": "loaders", + "type_info": "VarcharArray" + }, + { + "ordinal": 11, + "name": "project_types", + "type_info": "VarcharArray" + }, + { + "ordinal": 12, + "name": "games", + "type_info": "VarcharArray" + }, + { + "ordinal": 13, + "name": "gallery", + "type_info": "VarcharArray" + }, + { + "ordinal": 14, + "name": "featured_gallery", + "type_info": "VarcharArray" + }, + { + "ordinal": 15, + "name": "version_fields", + "type_info": "Jsonb" + }, + { + "ordinal": 16, + "name": "loader_fields", + "type_info": "Jsonb" + }, + { + "ordinal": 17, + "name": "loader_field_enum_values", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Int8", + "TextArray", + "Text" + ] + }, + "nullable": [ + false, + false, + false, + true, + true, + true, + false, + false, + true, + null, + null, + null, + null, + null, + null, + null, + null, + null + ] + }, + "hash": "3afbc93a8945e7ae07e39a88752f400c06f9c8a8132fd7a05dcc55c6eab5d2e7" +} diff --git a/.sqlx/query-683e186dc086ef21d2f82c0d427fcee16c613fb93ea74d6eb0da684363ca7b13.json b/.sqlx/query-683e186dc086ef21d2f82c0d427fcee16c613fb93ea74d6eb0da684363ca7b13.json new file mode 100644 index 00000000..b079a30f --- /dev/null +++ b/.sqlx/query-683e186dc086ef21d2f82c0d427fcee16c613fb93ea74d6eb0da684363ca7b13.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id, project_type FROM categories\n WHERE category = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "project_type", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false + ] + }, + "hash": "683e186dc086ef21d2f82c0d427fcee16c613fb93ea74d6eb0da684363ca7b13" +} diff --git a/.sqlx/query-72d6b5f2f11d88981db82c7247c9e7e5ebfd8d34985a1a8209d6628e66490f37.json b/.sqlx/query-72d6b5f2f11d88981db82c7247c9e7e5ebfd8d34985a1a8209d6628e66490f37.json deleted file mode 100644 index abc96eab..00000000 --- a/.sqlx/query-72d6b5f2f11d88981db82c7247c9e7e5ebfd8d34985a1a8209d6628e66490f37.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT id FROM categories\n WHERE category = $1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int4" - } - ], - "parameters": { - "Left": [ - "Text" - ] - }, - "nullable": [ - false - ] - }, - "hash": "72d6b5f2f11d88981db82c7247c9e7e5ebfd8d34985a1a8209d6628e66490f37" -} diff --git a/.sqlx/query-923d1d1e5e9b879479a244479952df15841d35b96fbdcadc7d5af8d6b4671f9e.json b/.sqlx/query-923d1d1e5e9b879479a244479952df15841d35b96fbdcadc7d5af8d6b4671f9e.json new file mode 100644 index 00000000..65c31f42 --- /dev/null +++ b/.sqlx/query-923d1d1e5e9b879479a244479952df15841d35b96fbdcadc7d5af8d6b4671f9e.json @@ -0,0 +1,44 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT l.id id, l.loader loader, l.icon icon,\n ARRAY_AGG(DISTINCT pt.name) filter (where pt.name is not null) project_types,\n ARRAY_AGG(DISTINCT g.name) filter (where g.name is not null) games\n FROM loaders l \n LEFT OUTER JOIN loaders_project_types lpt ON joining_loader_id = l.id\n LEFT OUTER JOIN project_types pt ON lpt.joining_project_type_id = pt.id\n LEFT OUTER JOIN loaders_project_types_games lptg ON lptg.loader_id = lpt.joining_loader_id AND lptg.project_type_id = lpt.joining_project_type_id\n LEFT OUTER JOIN games g ON lptg.game_id = g.id\n GROUP BY l.id;\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "loader", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "icon", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "project_types", + "type_info": "VarcharArray" + }, + { + "ordinal": 4, + "name": "games", + "type_info": "VarcharArray" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + false, + false, + null, + null + ] + }, + "hash": "923d1d1e5e9b879479a244479952df15841d35b96fbdcadc7d5af8d6b4671f9e" +} diff --git a/.sqlx/query-a377a9953cc222848dcad095cf4a6de53aeadacb33bd3134dae2d9c8f8a18651.json b/.sqlx/query-a377a9953cc222848dcad095cf4a6de53aeadacb33bd3134dae2d9c8f8a18651.json new file mode 100644 index 00000000..e57c1530 --- /dev/null +++ b/.sqlx/query-a377a9953cc222848dcad095cf4a6de53aeadacb33bd3134dae2d9c8f8a18651.json @@ -0,0 +1,142 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT v.id id, v.mod_id mod_id, v.author_id author_id, v.name version_name, v.version_number version_number,\n v.changelog changelog, v.date_published date_published, v.downloads downloads,\n v.version_type version_type, v.featured featured, v.status status, v.requested_status requested_status,\n ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null) loaders,\n ARRAY_AGG(DISTINCT pt.name) filter (where pt.name is not null) project_types,\n ARRAY_AGG(DISTINCT g.name) filter (where g.name is not null) games,\n JSONB_AGG(DISTINCT jsonb_build_object('id', f.id, 'url', f.url, 'filename', f.filename, 'primary', f.is_primary, 'size', f.size, 'file_type', f.file_type)) filter (where f.id is not null) files,\n JSONB_AGG(DISTINCT jsonb_build_object('algorithm', h.algorithm, 'hash', encode(h.hash, 'escape'), 'file_id', h.file_id)) filter (where h.hash is not null) hashes,\n JSONB_AGG(DISTINCT jsonb_build_object('project_id', d.mod_dependency_id, 'version_id', d.dependency_id, 'dependency_type', d.dependency_type,'file_name', dependency_file_name)) filter (where d.dependency_type is not null) dependencies,\n \n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'field_id', vf.field_id,\n 'int_value', vf.int_value,\n 'enum_value', vf.enum_value,\n 'string_value', vf.string_value\n )\n ) filter (where vf.field_id is not null) version_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'lf_id', lf.id,\n 'loader_name', l.loader,\n 'field', lf.field,\n 'field_type', lf.field_type,\n 'enum_type', lf.enum_type,\n 'min_val', lf.min_val,\n 'max_val', lf.max_val,\n 'optional', lf.optional\n )\n ) filter (where lf.id is not null) loader_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'id', lfev.id,\n 'enum_id', lfev.enum_id,\n 'value', lfev.value,\n 'ordering', lfev.ordering,\n 'created', lfev.created,\n 'metadata', lfev.metadata\n ) \n ) filter (where lfev.id is not null) loader_field_enum_values\n \n FROM versions v\n LEFT OUTER JOIN loaders_versions lv on v.id = lv.version_id\n LEFT OUTER JOIN loaders l on lv.loader_id = l.id\n LEFT OUTER JOIN loaders_project_types lpt on l.id = lpt.joining_loader_id\n LEFT JOIN project_types pt on lpt.joining_project_type_id = pt.id\n LEFT OUTER JOIN loaders_project_types_games lptg on l.id = lptg.loader_id AND pt.id = lptg.project_type_id\n LEFT JOIN games g on lptg.game_id = g.id\n LEFT OUTER JOIN files f on v.id = f.version_id\n LEFT OUTER JOIN hashes h on f.id = h.file_id\n LEFT OUTER JOIN dependencies d on v.id = d.dependent_id\n LEFT OUTER JOIN version_fields vf on v.id = vf.version_id\n LEFT OUTER JOIN loader_fields lf on vf.field_id = lf.id\n LEFT OUTER JOIN loader_field_enums lfe on lf.enum_type = lfe.id\n LEFT OUTER JOIN loader_field_enum_values lfev on lfe.id = lfev.enum_id\n\n WHERE v.id = ANY($1)\n GROUP BY v.id\n ORDER BY v.date_published ASC;\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "mod_id", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "author_id", + "type_info": "Int8" + }, + { + "ordinal": 3, + "name": "version_name", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "version_number", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "changelog", + "type_info": "Varchar" + }, + { + "ordinal": 6, + "name": "date_published", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "downloads", + "type_info": "Int4" + }, + { + "ordinal": 8, + "name": "version_type", + "type_info": "Varchar" + }, + { + "ordinal": 9, + "name": "featured", + "type_info": "Bool" + }, + { + "ordinal": 10, + "name": "status", + "type_info": "Varchar" + }, + { + "ordinal": 11, + "name": "requested_status", + "type_info": "Varchar" + }, + { + "ordinal": 12, + "name": "loaders", + "type_info": "VarcharArray" + }, + { + "ordinal": 13, + "name": "project_types", + "type_info": "VarcharArray" + }, + { + "ordinal": 14, + "name": "games", + "type_info": "VarcharArray" + }, + { + "ordinal": 15, + "name": "files", + "type_info": "Jsonb" + }, + { + "ordinal": 16, + "name": "hashes", + "type_info": "Jsonb" + }, + { + "ordinal": 17, + "name": "dependencies", + "type_info": "Jsonb" + }, + { + "ordinal": 18, + "name": "version_fields", + "type_info": "Jsonb" + }, + { + "ordinal": 19, + "name": "loader_fields", + "type_info": "Jsonb" + }, + { + "ordinal": 20, + "name": "loader_field_enum_values", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Int8Array" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + true, + null, + null, + null, + null, + null, + null, + null, + null, + null + ] + }, + "hash": "a377a9953cc222848dcad095cf4a6de53aeadacb33bd3134dae2d9c8f8a18651" +} diff --git a/.sqlx/query-bc662b93312190ce868135248dfbf9633f160dfb783cefa751ff400655e8660f.json b/.sqlx/query-bc662b93312190ce868135248dfbf9633f160dfb783cefa751ff400655e8660f.json deleted file mode 100644 index 5bc6e3d1..00000000 --- a/.sqlx/query-bc662b93312190ce868135248dfbf9633f160dfb783cefa751ff400655e8660f.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT m.id id, m.title title, m.description description, m.color color,\n m.icon_url icon_url, m.slug slug,\n pt.name project_type, u.username username, u.avatar_url avatar_url,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null) categories,\n ARRAY_AGG(DISTINCT lo.loader) filter (where lo.loader is not null) loaders,\n ARRAY_AGG(DISTINCT mg.image_url) filter (where mg.image_url is not null and mg.featured is false) gallery,\n ARRAY_AGG(DISTINCT mg.image_url) filter (where mg.image_url is not null and mg.featured is true) featured_gallery,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'field_id', vf.field_id,\n 'int_value', vf.int_value,\n 'enum_value', vf.enum_value,\n 'string_value', vf.string_value\n )\n ) filter (where vf.field_id is not null) version_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'lf_id', lf.id,\n 'loader_name', lo.loader,\n 'field', lf.field,\n 'field_type', lf.field_type,\n 'enum_type', lf.enum_type,\n 'min_val', lf.min_val,\n 'max_val', lf.max_val,\n 'optional', lf.optional\n )\n ) filter (where lf.id is not null) loader_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'id', lfev.id,\n 'enum_id', lfev.enum_id,\n 'value', lfev.value,\n 'ordering', lfev.ordering,\n 'created', lfev.created,\n 'metadata', lfev.metadata\n ) \n ) filter (where lfev.id is not null) loader_field_enum_values\n FROM mods m\n LEFT OUTER JOIN mods_categories mc ON joining_mod_id = m.id AND mc.is_additional = FALSE\n LEFT OUTER JOIN categories c ON mc.joining_category_id = c.id\n LEFT OUTER JOIN versions v ON v.mod_id = m.id AND v.status != ALL($2)\n LEFT OUTER JOIN loaders_versions lv ON lv.version_id = v.id\n LEFT OUTER JOIN loaders lo ON lo.id = lv.loader_id\n LEFT OUTER JOIN mods_gallery mg ON mg.mod_id = m.id\n INNER JOIN project_types pt ON pt.id = m.project_type\n INNER JOIN team_members tm ON tm.team_id = m.team_id AND tm.role = $3 AND tm.accepted = TRUE\n INNER JOIN users u ON tm.user_id = u.id\n LEFT OUTER JOIN version_fields vf on v.id = vf.version_id\n LEFT OUTER JOIN loader_fields lf on vf.field_id = lf.id\n LEFT OUTER JOIN loader_field_enums lfe on lf.enum_type = lfe.id\n LEFT OUTER JOIN loader_field_enum_values lfev on lfev.enum_id = lfe.id\n WHERE m.id = $1\n GROUP BY m.id, pt.id, u.id;\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int8" - }, - { - "ordinal": 1, - "name": "title", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "description", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "color", - "type_info": "Int4" - }, - { - "ordinal": 4, - "name": "icon_url", - "type_info": "Varchar" - }, - { - "ordinal": 5, - "name": "slug", - "type_info": "Varchar" - }, - { - "ordinal": 6, - "name": "project_type", - "type_info": "Varchar" - }, - { - "ordinal": 7, - "name": "username", - "type_info": "Varchar" - }, - { - "ordinal": 8, - "name": "avatar_url", - "type_info": "Varchar" - }, - { - "ordinal": 9, - "name": "categories", - "type_info": "VarcharArray" - }, - { - "ordinal": 10, - "name": "loaders", - "type_info": "VarcharArray" - }, - { - "ordinal": 11, - "name": "gallery", - "type_info": "VarcharArray" - }, - { - "ordinal": 12, - "name": "featured_gallery", - "type_info": "VarcharArray" - }, - { - "ordinal": 13, - "name": "version_fields", - "type_info": "Jsonb" - }, - { - "ordinal": 14, - "name": "loader_fields", - "type_info": "Jsonb" - }, - { - "ordinal": 15, - "name": "loader_field_enum_values", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Int8", - "TextArray", - "Text" - ] - }, - "nullable": [ - false, - false, - false, - true, - true, - true, - false, - false, - true, - null, - null, - null, - null, - null, - null, - null - ] - }, - "hash": "bc662b93312190ce868135248dfbf9633f160dfb783cefa751ff400655e8660f" -} diff --git a/.sqlx/query-cab90ea34929643f9e9814150c4dbd027fc0bd427bfba5e6eb99c989af53b680.json b/.sqlx/query-cab90ea34929643f9e9814150c4dbd027fc0bd427bfba5e6eb99c989af53b680.json new file mode 100644 index 00000000..0951bcc2 --- /dev/null +++ b/.sqlx/query-cab90ea34929643f9e9814150c4dbd027fc0bd427bfba5e6eb99c989af53b680.json @@ -0,0 +1,180 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT m.id id, v.id version_id, m.title title, m.description description, m.downloads downloads, m.follows follows,\n m.icon_url icon_url, m.published published, m.approved approved, m.updated updated,\n m.team_id team_id, m.license license, m.slug slug, m.status status_name, m.color color,\n pt.name project_type_name, u.username username,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,\n ARRAY_AGG(DISTINCT lo.loader) filter (where lo.loader is not null) loaders,\n ARRAY_AGG(DISTINCT pt.name) filter (where pt.name is not null) project_types,\n ARRAY_AGG(DISTINCT g.name) filter (where g.name is not null) games,\n ARRAY_AGG(DISTINCT mg.image_url) filter (where mg.image_url is not null and mg.featured is false) gallery,\n ARRAY_AGG(DISTINCT mg.image_url) filter (where mg.image_url is not null and mg.featured is true) featured_gallery,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'field_id', vf.field_id,\n 'int_value', vf.int_value,\n 'enum_value', vf.enum_value,\n 'string_value', vf.string_value\n )\n ) filter (where vf.field_id is not null) version_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'lf_id', lf.id,\n 'loader_name', lo.loader,\n 'field', lf.field,\n 'field_type', lf.field_type,\n 'enum_type', lf.enum_type,\n 'min_val', lf.min_val,\n 'max_val', lf.max_val,\n 'optional', lf.optional\n )\n ) filter (where lf.id is not null) loader_fields,\n JSONB_AGG(\n DISTINCT jsonb_build_object(\n 'id', lfev.id,\n 'enum_id', lfev.enum_id,\n 'value', lfev.value,\n 'ordering', lfev.ordering,\n 'created', lfev.created,\n 'metadata', lfev.metadata\n ) \n ) filter (where lfev.id is not null) loader_field_enum_values\n\n FROM versions v\n INNER JOIN mods m ON v.mod_id = m.id AND m.status = ANY($2)\n LEFT OUTER JOIN mods_categories mc ON joining_mod_id = m.id\n LEFT OUTER JOIN categories c ON mc.joining_category_id = c.id\n LEFT OUTER JOIN loaders_versions lv ON lv.version_id = v.id\n LEFT OUTER JOIN loaders lo ON lo.id = lv.loader_id\n LEFT JOIN loaders_project_types lpt ON lpt.joining_loader_id = lo.id\n LEFT JOIN project_types pt ON pt.id = lpt.joining_project_type_id\n LEFT JOIN loaders_project_types_games lptg ON lptg.loader_id = lo.id AND lptg.project_type_id = pt.id\n LEFT JOIN games g ON lptg.game_id = g.id\n LEFT OUTER JOIN mods_gallery mg ON mg.mod_id = m.id\n INNER JOIN team_members tm ON tm.team_id = m.team_id AND tm.role = $3 AND tm.accepted = TRUE\n INNER JOIN users u ON tm.user_id = u.id\n LEFT OUTER JOIN version_fields vf on v.id = vf.version_id\n LEFT OUTER JOIN loader_fields lf on vf.field_id = lf.id\n LEFT OUTER JOIN loader_field_enums lfe on lf.enum_type = lfe.id\n LEFT OUTER JOIN loader_field_enum_values lfev on lfev.enum_id = lfe.id\n WHERE v.status != ANY($1)\n GROUP BY v.id, m.id, pt.id, u.id;\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "version_id", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "title", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "description", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "downloads", + "type_info": "Int4" + }, + { + "ordinal": 5, + "name": "follows", + "type_info": "Int4" + }, + { + "ordinal": 6, + "name": "icon_url", + "type_info": "Varchar" + }, + { + "ordinal": 7, + "name": "published", + "type_info": "Timestamptz" + }, + { + "ordinal": 8, + "name": "approved", + "type_info": "Timestamptz" + }, + { + "ordinal": 9, + "name": "updated", + "type_info": "Timestamptz" + }, + { + "ordinal": 10, + "name": "team_id", + "type_info": "Int8" + }, + { + "ordinal": 11, + "name": "license", + "type_info": "Varchar" + }, + { + "ordinal": 12, + "name": "slug", + "type_info": "Varchar" + }, + { + "ordinal": 13, + "name": "status_name", + "type_info": "Varchar" + }, + { + "ordinal": 14, + "name": "color", + "type_info": "Int4" + }, + { + "ordinal": 15, + "name": "project_type_name", + "type_info": "Varchar" + }, + { + "ordinal": 16, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 17, + "name": "categories", + "type_info": "VarcharArray" + }, + { + "ordinal": 18, + "name": "additional_categories", + "type_info": "VarcharArray" + }, + { + "ordinal": 19, + "name": "loaders", + "type_info": "VarcharArray" + }, + { + "ordinal": 20, + "name": "project_types", + "type_info": "VarcharArray" + }, + { + "ordinal": 21, + "name": "games", + "type_info": "VarcharArray" + }, + { + "ordinal": 22, + "name": "gallery", + "type_info": "VarcharArray" + }, + { + "ordinal": 23, + "name": "featured_gallery", + "type_info": "VarcharArray" + }, + { + "ordinal": 24, + "name": "version_fields", + "type_info": "Jsonb" + }, + { + "ordinal": 25, + "name": "loader_fields", + "type_info": "Jsonb" + }, + { + "ordinal": 26, + "name": "loader_field_enum_values", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "TextArray", + "TextArray", + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + true, + false, + true, + false, + false, + false, + true, + false, + true, + false, + false, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ] + }, + "hash": "cab90ea34929643f9e9814150c4dbd027fc0bd427bfba5e6eb99c989af53b680" +} diff --git a/.sqlx/query-ef59f99fc0ab66ff5779d0e71c4a2134e2f26eed002ff9ea5626ea3e23518594.json b/.sqlx/query-ef59f99fc0ab66ff5779d0e71c4a2134e2f26eed002ff9ea5626ea3e23518594.json deleted file mode 100644 index 101e5838..00000000 --- a/.sqlx/query-ef59f99fc0ab66ff5779d0e71c4a2134e2f26eed002ff9ea5626ea3e23518594.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT name FROM project_types pt\n INNER JOIN mods ON mods.project_type = pt.id\n WHERE mods.id = $1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "name", - "type_info": "Varchar" - } - ], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [ - false - ] - }, - "hash": "ef59f99fc0ab66ff5779d0e71c4a2134e2f26eed002ff9ea5626ea3e23518594" -} diff --git a/.sqlx/query-baa0615e8abc97e5529cff39ffed4e740b51b303aaf533662285061e7f5c0bca.json b/.sqlx/query-f73ffab12a96eb9480615e333d40cde031df280039cd8e435cfca5e15ed3d1c4.json similarity index 58% rename from .sqlx/query-baa0615e8abc97e5529cff39ffed4e740b51b303aaf533662285061e7f5c0bca.json rename to .sqlx/query-f73ffab12a96eb9480615e333d40cde031df280039cd8e435cfca5e15ed3d1c4.json index e077f28a..91e7b818 100644 --- a/.sqlx/query-baa0615e8abc97e5529cff39ffed4e740b51b303aaf533662285061e7f5c0bca.json +++ b/.sqlx/query-f73ffab12a96eb9480615e333d40cde031df280039cd8e435cfca5e15ed3d1c4.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT m.id id, g.name, m.project_type project_type, m.title title, m.description description, m.downloads downloads, m.follows follows,\n m.icon_url icon_url, m.body body, m.published published,\n m.updated updated, m.approved approved, m.queued, m.status status, m.requested_status requested_status,\n m.issues_url issues_url, m.source_url source_url, m.wiki_url wiki_url, m.discord_url discord_url, m.license_url license_url,\n m.team_id team_id, m.organization_id organization_id, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,\n pt.name project_type_name, m.webhook_sent, m.color,\n t.id thread_id, m.monetization_status monetization_status,\n ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null) loaders,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,\n JSONB_AGG(DISTINCT jsonb_build_object('id', v.id, 'date_published', v.date_published)) filter (where v.id is not null) versions,\n JSONB_AGG(DISTINCT jsonb_build_object('image_url', mg.image_url, 'featured', mg.featured, 'title', mg.title, 'description', mg.description, 'created', mg.created, 'ordering', mg.ordering)) filter (where mg.image_url is not null) gallery,\n JSONB_AGG(DISTINCT jsonb_build_object('platform_id', md.joining_platform_id, 'platform_short', dp.short, 'platform_name', dp.name,'url', md.url)) filter (where md.joining_platform_id is not null) donations\n FROM mods m\n INNER JOIN games g ON g.id = m.game_id\n INNER JOIN project_types pt ON pt.id = m.project_type\n INNER JOIN threads t ON t.mod_id = m.id\n LEFT JOIN mods_gallery mg ON mg.mod_id = m.id\n LEFT JOIN mods_donations md ON md.joining_mod_id = m.id\n LEFT JOIN donation_platforms dp ON md.joining_platform_id = dp.id\n LEFT JOIN mods_categories mc ON mc.joining_mod_id = m.id\n LEFT JOIN categories c ON mc.joining_category_id = c.id\n LEFT JOIN versions v ON v.mod_id = m.id AND v.status = ANY($3)\n LEFT JOIN loaders_versions lv ON lv.version_id = v.id\n LEFT JOIN loaders l on lv.loader_id = l.id\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n GROUP BY pt.id, t.id, m.id, g.name;\n ", + "query": "\n SELECT m.id id, m.title title, m.description description, m.downloads downloads, m.follows follows,\n m.icon_url icon_url, m.body body, m.published published,\n m.updated updated, m.approved approved, m.queued, m.status status, m.requested_status requested_status,\n m.issues_url issues_url, m.source_url source_url, m.wiki_url wiki_url, m.discord_url discord_url, m.license_url license_url,\n m.team_id team_id, m.organization_id organization_id, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,\n m.webhook_sent, m.color,\n t.id thread_id, m.monetization_status monetization_status,\n ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null) loaders,\n ARRAY_AGG(DISTINCT pt.name) filter (where pt.name is not null) project_types,\n ARRAY_AGG(DISTINCT g.name) filter (where g.name is not null) games,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,\n ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,\n JSONB_AGG(DISTINCT jsonb_build_object('id', v.id, 'date_published', v.date_published)) filter (where v.id is not null) versions,\n JSONB_AGG(DISTINCT jsonb_build_object('image_url', mg.image_url, 'featured', mg.featured, 'title', mg.title, 'description', mg.description, 'created', mg.created, 'ordering', mg.ordering)) filter (where mg.image_url is not null) gallery,\n JSONB_AGG(DISTINCT jsonb_build_object('platform_id', md.joining_platform_id, 'platform_short', dp.short, 'platform_name', dp.name,'url', md.url)) filter (where md.joining_platform_id is not null) donations\n FROM mods m \n INNER JOIN threads t ON t.mod_id = m.id\n LEFT JOIN mods_gallery mg ON mg.mod_id = m.id\n LEFT JOIN mods_donations md ON md.joining_mod_id = m.id\n LEFT JOIN donation_platforms dp ON md.joining_platform_id = dp.id\n LEFT JOIN mods_categories mc ON mc.joining_mod_id = m.id\n LEFT JOIN categories c ON mc.joining_category_id = c.id\n LEFT JOIN versions v ON v.mod_id = m.id AND v.status = ANY($3)\n LEFT JOIN loaders_versions lv ON lv.version_id = v.id\n LEFT JOIN loaders l on lv.loader_id = l.id\n LEFT JOIN loaders_project_types lpt ON lpt.joining_loader_id = l.id\n LEFT JOIN project_types pt ON pt.id = lpt.joining_project_type_id\n LEFT JOIN loaders_project_types_games lptg ON lptg.loader_id = l.id AND lptg.project_type_id = pt.id\n LEFT JOIN games g ON lptg.game_id = g.id\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n GROUP BY t.id, m.id;\n ", "describe": { "columns": [ { @@ -10,181 +10,176 @@ }, { "ordinal": 1, - "name": "name", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "project_type", - "type_info": "Int4" - }, - { - "ordinal": 3, "name": "title", "type_info": "Varchar" }, { - "ordinal": 4, + "ordinal": 2, "name": "description", "type_info": "Varchar" }, { - "ordinal": 5, + "ordinal": 3, "name": "downloads", "type_info": "Int4" }, { - "ordinal": 6, + "ordinal": 4, "name": "follows", "type_info": "Int4" }, { - "ordinal": 7, + "ordinal": 5, "name": "icon_url", "type_info": "Varchar" }, { - "ordinal": 8, + "ordinal": 6, "name": "body", "type_info": "Varchar" }, { - "ordinal": 9, + "ordinal": 7, "name": "published", "type_info": "Timestamptz" }, { - "ordinal": 10, + "ordinal": 8, "name": "updated", "type_info": "Timestamptz" }, { - "ordinal": 11, + "ordinal": 9, "name": "approved", "type_info": "Timestamptz" }, { - "ordinal": 12, + "ordinal": 10, "name": "queued", "type_info": "Timestamptz" }, { - "ordinal": 13, + "ordinal": 11, "name": "status", "type_info": "Varchar" }, { - "ordinal": 14, + "ordinal": 12, "name": "requested_status", "type_info": "Varchar" }, { - "ordinal": 15, + "ordinal": 13, "name": "issues_url", "type_info": "Varchar" }, { - "ordinal": 16, + "ordinal": 14, "name": "source_url", "type_info": "Varchar" }, { - "ordinal": 17, + "ordinal": 15, "name": "wiki_url", "type_info": "Varchar" }, { - "ordinal": 18, + "ordinal": 16, "name": "discord_url", "type_info": "Varchar" }, { - "ordinal": 19, + "ordinal": 17, "name": "license_url", "type_info": "Varchar" }, { - "ordinal": 20, + "ordinal": 18, "name": "team_id", "type_info": "Int8" }, { - "ordinal": 21, + "ordinal": 19, "name": "organization_id", "type_info": "Int8" }, { - "ordinal": 22, + "ordinal": 20, "name": "license", "type_info": "Varchar" }, { - "ordinal": 23, + "ordinal": 21, "name": "slug", "type_info": "Varchar" }, { - "ordinal": 24, + "ordinal": 22, "name": "moderation_message", "type_info": "Varchar" }, { - "ordinal": 25, + "ordinal": 23, "name": "moderation_message_body", "type_info": "Varchar" }, { - "ordinal": 26, - "name": "project_type_name", - "type_info": "Varchar" - }, - { - "ordinal": 27, + "ordinal": 24, "name": "webhook_sent", "type_info": "Bool" }, { - "ordinal": 28, + "ordinal": 25, "name": "color", "type_info": "Int4" }, { - "ordinal": 29, + "ordinal": 26, "name": "thread_id", "type_info": "Int8" }, { - "ordinal": 30, + "ordinal": 27, "name": "monetization_status", "type_info": "Varchar" }, { - "ordinal": 31, + "ordinal": 28, "name": "loaders", "type_info": "VarcharArray" }, { - "ordinal": 32, + "ordinal": 29, + "name": "project_types", + "type_info": "VarcharArray" + }, + { + "ordinal": 30, + "name": "games", + "type_info": "VarcharArray" + }, + { + "ordinal": 31, "name": "categories", "type_info": "VarcharArray" }, { - "ordinal": 33, + "ordinal": 32, "name": "additional_categories", "type_info": "VarcharArray" }, { - "ordinal": 34, + "ordinal": 33, "name": "versions", "type_info": "Jsonb" }, { - "ordinal": 35, + "ordinal": 34, "name": "gallery", "type_info": "Jsonb" }, { - "ordinal": 36, + "ordinal": 35, "name": "donations", "type_info": "Jsonb" } @@ -197,8 +192,6 @@ ] }, "nullable": [ - false, - true, false, false, false, @@ -224,7 +217,6 @@ true, true, false, - false, true, false, false, @@ -233,8 +225,10 @@ null, null, null, + null, + null, null ] }, - "hash": "baa0615e8abc97e5529cff39ffed4e740b51b303aaf533662285061e7f5c0bca" + "hash": "f73ffab12a96eb9480615e333d40cde031df280039cd8e435cfca5e15ed3d1c4" } diff --git a/.sqlx/query-fd6c1accdafbeab3142b7fab397c3b0d629c470f654f1e30250bd8773ed04f5b.json b/.sqlx/query-fd6c1accdafbeab3142b7fab397c3b0d629c470f654f1e30250bd8773ed04f5b.json deleted file mode 100644 index faaf49de..00000000 --- a/.sqlx/query-fd6c1accdafbeab3142b7fab397c3b0d629c470f654f1e30250bd8773ed04f5b.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT l.id id, l.loader loader, l.icon icon,\n ARRAY_AGG(DISTINCT pt.name) filter (where pt.name is not null) project_types\n FROM loaders l\n INNER JOIN games g ON l.game_id = g.id\n LEFT OUTER JOIN loaders_project_types lpt ON joining_loader_id = l.id\n LEFT OUTER JOIN project_types pt ON lpt.joining_project_type_id = pt.id\n WHERE g.name = $1\n GROUP BY l.id;\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int4" - }, - { - "ordinal": 1, - "name": "loader", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "icon", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "project_types", - "type_info": "VarcharArray" - } - ], - "parameters": { - "Left": [ - "Text" - ] - }, - "nullable": [ - false, - false, - false, - null - ] - }, - "hash": "fd6c1accdafbeab3142b7fab397c3b0d629c470f654f1e30250bd8773ed04f5b" -} diff --git a/.sqlx/query-b26c1b47aefa6df4a0daf39a83151e7168f7cc483d219813e4c70f5f805e84a3.json b/.sqlx/query-fefb4f07a0f0c0cf74e554d120f8707d698fc8b4dbb66d2830f4ec0229bc1019.json similarity index 63% rename from .sqlx/query-b26c1b47aefa6df4a0daf39a83151e7168f7cc483d219813e4c70f5f805e84a3.json rename to .sqlx/query-fefb4f07a0f0c0cf74e554d120f8707d698fc8b4dbb66d2830f4ec0229bc1019.json index 09221ca6..e2b9c106 100644 --- a/.sqlx/query-b26c1b47aefa6df4a0daf39a83151e7168f7cc483d219813e4c70f5f805e84a3.json +++ b/.sqlx/query-fefb4f07a0f0c0cf74e554d120f8707d698fc8b4dbb66d2830f4ec0229bc1019.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n INSERT INTO mods (\n id, team_id, title, description, body,\n published, downloads, icon_url, issues_url,\n source_url, wiki_url, status, requested_status, discord_url,\n license_url, license,\n slug, project_type, color, monetization_status\n )\n VALUES (\n $1, $2, $3, $4, $5,\n $6, $7, $8, $9,\n $10, $11, $12, $13, $14,\n $15, $16, LOWER($17), $18,\n $19, $20\n )\n ", + "query": "\n INSERT INTO mods (\n id, team_id, title, description, body,\n published, downloads, icon_url, issues_url,\n source_url, wiki_url, status, requested_status, discord_url,\n license_url, license,\n slug, color, monetization_status\n )\n VALUES (\n $1, $2, $3, $4, $5,\n $6, $7, $8, $9,\n $10, $11, $12, $13, $14,\n $15, $16, \n LOWER($17), $18, $19\n )\n ", "describe": { "columns": [], "parameters": { @@ -23,11 +23,10 @@ "Varchar", "Text", "Int4", - "Int4", "Varchar" ] }, "nullable": [] }, - "hash": "b26c1b47aefa6df4a0daf39a83151e7168f7cc483d219813e4c70f5f805e84a3" + "hash": "fefb4f07a0f0c0cf74e554d120f8707d698fc8b4dbb66d2830f4ec0229bc1019" } diff --git a/src/database/models/categories.rs b/src/database/models/categories.rs index a033e276..95d054f2 100644 --- a/src/database/models/categories.rs +++ b/src/database/models/categories.rs @@ -39,7 +39,10 @@ impl Category { // Gets hashmap of category ids matching a name // Multiple categories can have the same name, but different project types, so we need to return a hashmap // ProjectTypeId -> CategoryId - pub async fn get_ids<'a, E>(name: &str, exec: E) -> Result, DatabaseError> + pub async fn get_ids<'a, E>( + name: &str, + exec: E, + ) -> Result, DatabaseError> where E: sqlx::Executor<'a, Database = sqlx::Postgres>, { @@ -57,7 +60,7 @@ impl Category { for r in result { map.insert(ProjectTypeId(r.project_type), CategoryId(r.id)); } - + Ok(map) } diff --git a/src/database/models/loader_fields.rs b/src/database/models/loader_fields.rs index 207c5811..c755d1c1 100644 --- a/src/database/models/loader_fields.rs +++ b/src/database/models/loader_fields.rs @@ -84,14 +84,10 @@ impl Loader { Ok(result) } - pub async fn list<'a, E>( - exec: E, - redis: &RedisPool, - ) -> Result, DatabaseError> + pub async fn list<'a, E>(exec: E, redis: &RedisPool) -> Result, DatabaseError> where E: sqlx::Executor<'a, Database = sqlx::Postgres>, { - let cached_loaders: Option> = redis .get_deserialized_from_json(LOADERS_LIST_NAMESPACE, "all") .await?; diff --git a/src/database/models/project_item.rs b/src/database/models/project_item.rs index 4b647b6f..a7589a3d 100644 --- a/src/database/models/project_item.rs +++ b/src/database/models/project_item.rs @@ -600,9 +600,9 @@ impl Project { ) .fetch_many(exec) .try_filter_map(|e| async { - Ok(e.right().and_then(|m| { + Ok(e.right().map(|m| { let id = m.id; - Some(QueryProject { + QueryProject { inner: Project { id: ProjectId(id), team_id: TeamId(m.team_id), @@ -673,7 +673,7 @@ impl Project { m.donations.unwrap_or_default(), ).ok().unwrap_or_default(), thread_id: ThreadId(m.thread_id), - })})) + }})) }) .try_collect::>() .await?; diff --git a/src/models/mod.rs b/src/models/mod.rs index d2111891..c4ff81a2 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -16,4 +16,4 @@ pub use v3::reports; pub use v3::sessions; pub use v3::teams; pub use v3::threads; -pub use v3::users; \ No newline at end of file +pub use v3::users; diff --git a/src/models/v3/mod.rs b/src/models/v3/mod.rs index 04dc7237..7c97ad31 100644 --- a/src/models/v3/mod.rs +++ b/src/models/v3/mod.rs @@ -13,4 +13,4 @@ pub mod reports; pub mod sessions; pub mod teams; pub mod threads; -pub mod users; \ No newline at end of file +pub mod users; diff --git a/src/routes/maven.rs b/src/routes/maven.rs index a2009a34..a50ec7f2 100644 --- a/src/routes/maven.rs +++ b/src/routes/maven.rs @@ -255,7 +255,7 @@ fn find_file<'a>( .iter() .find(|x| x.primary) .or_else(|| version.files.iter().last()); - } + } } None } diff --git a/src/routes/v2/analytics_get.rs b/src/routes/v2/analytics_get.rs index d719010a..91de3bb6 100644 --- a/src/routes/v2/analytics_get.rs +++ b/src/routes/v2/analytics_get.rs @@ -1,12 +1,7 @@ use super::ApiError; use crate::database::redis::RedisPool; use crate::routes::v3; -use crate::{ - models:: - ids:: - VersionId, - queue::session::AuthQueue, -}; +use crate::{models::ids::VersionId, queue::session::AuthQueue}; use actix_web::{get, web, HttpRequest, HttpResponse}; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; @@ -82,7 +77,8 @@ pub async fn playtimes_get( session_queue, pool, redis, - ).await + ) + .await } /// Get view data for a set of projects or versions @@ -117,7 +113,8 @@ pub async fn views_get( session_queue, pool, redis, - ).await + ) + .await } /// Get download data for a set of projects or versions @@ -152,7 +149,8 @@ pub async fn downloads_get( session_queue, pool, redis, - ).await + ) + .await } /// Get payout data for a set of projects @@ -185,7 +183,8 @@ pub async fn revenue_get( session_queue, pool, redis, - ).await + ) + .await } /// Get country data for a set of projects or versions @@ -223,7 +222,8 @@ pub async fn countries_downloads_get( session_queue, pool, redis, - ).await + ) + .await } /// Get country data for a set of projects or versions @@ -261,5 +261,6 @@ pub async fn countries_views_get( session_queue, pool, redis, - ).await -} \ No newline at end of file + ) + .await +} diff --git a/src/routes/v2/collections.rs b/src/routes/v2/collections.rs index 0bdfb2bf..32412ab5 100644 --- a/src/routes/v2/collections.rs +++ b/src/routes/v2/collections.rs @@ -3,7 +3,7 @@ use crate::file_hosting::FileHost; use crate::models::collections::CollectionStatus; use crate::queue::session::AuthQueue; use crate::routes::v3::project_creation::CreateError; -use crate::routes::{ApiError, v3}; +use crate::routes::{v3, ApiError}; use actix_web::web::Data; use actix_web::{delete, get, patch, post, web, HttpRequest, HttpResponse}; use serde::{Deserialize, Serialize}; @@ -60,7 +60,8 @@ pub async fn collection_create( client, redis, session_queue, - ).await + ) + .await } #[derive(Serialize, Deserialize)] @@ -75,9 +76,14 @@ pub async fn collections_get( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::collections::collections_get(req, web::Query(v3::collections::CollectionIds{ - ids: ids.ids - }), pool, redis, session_queue).await + v3::collections::collections_get( + req, + web::Query(v3::collections::CollectionIds { ids: ids.ids }), + pool, + redis, + session_queue, + ) + .await } #[get("{id}")] @@ -115,14 +121,20 @@ pub async fn collection_edit( session_queue: web::Data, ) -> Result { let new_collection = new_collection.into_inner(); - v3::collections::collection_edit(req, info, pool, web::Json( - v3::collections::EditCollection { + v3::collections::collection_edit( + req, + info, + pool, + web::Json(v3::collections::EditCollection { title: new_collection.title, description: new_collection.description, status: new_collection.status, new_projects: new_collection.new_projects, - } - ), redis, session_queue).await + }), + redis, + session_queue, + ) + .await } #[derive(Serialize, Deserialize)] @@ -143,9 +155,7 @@ pub async fn collection_icon_edit( session_queue: web::Data, ) -> Result { v3::collections::collection_icon_edit( - web::Query(v3::collections::Extension { - ext: ext.ext - }), + web::Query(v3::collections::Extension { ext: ext.ext }), req, info, pool, @@ -153,7 +163,8 @@ pub async fn collection_icon_edit( file_host, payload, session_queue, - ).await + ) + .await } #[delete("{id}/icon")] @@ -165,14 +176,7 @@ pub async fn delete_collection_icon( file_host: web::Data>, session_queue: web::Data, ) -> Result { - v3::collections::delete_collection_icon( - req, - info, - pool, - redis, - file_host, - session_queue, - ).await + v3::collections::delete_collection_icon(req, info, pool, redis, file_host, session_queue).await } #[delete("{id}")] @@ -184,4 +188,4 @@ pub async fn collection_delete( session_queue: web::Data, ) -> Result { v3::collections::collection_delete(req, info, pool, redis, session_queue).await -} \ No newline at end of file +} diff --git a/src/routes/v2/images.rs b/src/routes/v2/images.rs index 71a64e13..da6d2aea 100644 --- a/src/routes/v2/images.rs +++ b/src/routes/v2/images.rs @@ -5,7 +5,7 @@ use crate::file_hosting::FileHost; use crate::models::ids::{ThreadMessageId, VersionId}; use crate::models::reports::ReportId; use crate::queue::session::AuthQueue; -use crate::routes::{ApiError, v3}; +use crate::routes::{v3, ApiError}; use actix_web::{post, web, HttpRequest, HttpResponse}; use serde::{Deserialize, Serialize}; use sqlx::PgPool; @@ -39,12 +39,21 @@ pub async fn images_add( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::images::images_add(req, web::Query(v3::images::ImageUpload { - ext: data.ext, - context: data.context, - project_id: data.project_id, - version_id: data.version_id, - thread_message_id: data.thread_message_id, - report_id: data.report_id, - }), file_host, payload, pool, redis, session_queue).await + v3::images::images_add( + req, + web::Query(v3::images::ImageUpload { + ext: data.ext, + context: data.context, + project_id: data.project_id, + version_id: data.version_id, + thread_message_id: data.thread_message_id, + report_id: data.report_id, + }), + file_host, + payload, + pool, + redis, + session_queue, + ) + .await } diff --git a/src/routes/v2/moderation.rs b/src/routes/v2/moderation.rs index b1287eeb..f44214de 100644 --- a/src/routes/v2/moderation.rs +++ b/src/routes/v2/moderation.rs @@ -28,7 +28,12 @@ pub async fn get_projects( count: web::Query, session_queue: web::Data, ) -> Result { - v3::moderation::get_projects(req, pool, redis, - web::Query(v3::moderation::ResultCount { - count: count.count}), session_queue).await + v3::moderation::get_projects( + req, + pool, + redis, + web::Query(v3::moderation::ResultCount { count: count.count }), + session_queue, + ) + .await } diff --git a/src/routes/v2/notifications.rs b/src/routes/v2/notifications.rs index 9bb10c67..af04cafb 100644 --- a/src/routes/v2/notifications.rs +++ b/src/routes/v2/notifications.rs @@ -1,7 +1,7 @@ -use crate::routes::v3; use crate::database::redis::RedisPool; use crate::models::ids::NotificationId; use crate::queue::session::AuthQueue; +use crate::routes::v3; use crate::routes::ApiError; use actix_web::{delete, get, patch, web, HttpRequest, HttpResponse}; use serde::{Deserialize, Serialize}; @@ -39,7 +39,8 @@ pub async fn notifications_get( pool, redis, session_queue, - ).await + ) + .await } #[get("{id}")] @@ -50,13 +51,7 @@ pub async fn notification_get( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::notifications::notification_get( - req, - info, - pool, - redis, - session_queue, - ).await + v3::notifications::notification_get(req, info, pool, redis, session_queue).await } #[patch("{id}")] @@ -67,13 +62,7 @@ pub async fn notification_read( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::notifications::notification_read( - req, - info, - pool, - redis, - session_queue, - ).await + v3::notifications::notification_read(req, info, pool, redis, session_queue).await } #[delete("{id}")] @@ -84,13 +73,7 @@ pub async fn notification_delete( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::notifications::notification_delete( - req, - info, - pool, - redis, - session_queue, - ).await + v3::notifications::notification_delete(req, info, pool, redis, session_queue).await } #[patch("notifications")] @@ -107,7 +90,8 @@ pub async fn notifications_read( pool, redis, session_queue, - ).await + ) + .await } #[delete("notifications")] @@ -124,5 +108,6 @@ pub async fn notifications_delete( pool, redis, session_queue, - ).await + ) + .await } diff --git a/src/routes/v2/organizations.rs b/src/routes/v2/organizations.rs index ef4e4b36..15ea4e6f 100644 --- a/src/routes/v2/organizations.rs +++ b/src/routes/v2/organizations.rs @@ -1,4 +1,3 @@ -use std::sync::Arc; use crate::database::redis::RedisPool; use crate::file_hosting::FileHost; use crate::models::projects::Project; @@ -9,6 +8,7 @@ use crate::routes::{v2_reroute, v3, ApiError}; use actix_web::{delete, get, patch, post, web, HttpRequest, HttpResponse}; use serde::{Deserialize, Serialize}; use sqlx::PgPool; +use std::sync::Arc; use validator::Validate; pub fn config(cfg: &mut web::ServiceConfig) { @@ -57,7 +57,8 @@ pub async fn organization_create( pool.clone(), redis.clone(), session_queue, - ).await + ) + .await } #[get("{id}")] @@ -68,13 +69,7 @@ pub async fn organization_get( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::organizations::organization_get( - req, - info, - pool.clone(), - redis.clone(), - session_queue, - ).await + v3::organizations::organization_get(req, info, pool.clone(), redis.clone(), session_queue).await } #[derive(Deserialize)] @@ -95,7 +90,8 @@ pub async fn organizations_get( pool, redis, session_queue, - ).await + ) + .await } #[derive(Serialize, Deserialize, Validate)] @@ -130,7 +126,8 @@ pub async fn organizations_edit( pool.clone(), redis.clone(), session_queue, - ).await + ) + .await } #[delete("{id}")] @@ -141,13 +138,8 @@ pub async fn organization_delete( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::organizations::organization_delete( - req, - info, - pool.clone(), - redis.clone(), - session_queue, - ).await + v3::organizations::organization_delete(req, info, pool.clone(), redis.clone(), session_queue) + .await } #[get("{id}/projects")] @@ -200,7 +192,8 @@ pub async fn organization_projects_add( pool.clone(), redis.clone(), session_queue, - ).await + ) + .await } #[delete("{organization_id}/projects/{project_id}")] @@ -217,7 +210,8 @@ pub async fn organization_projects_remove( pool.clone(), redis.clone(), session_queue, - ).await + ) + .await } #[derive(Serialize, Deserialize)] @@ -246,7 +240,8 @@ pub async fn organization_icon_edit( file_host, payload, session_queue, - ).await + ) + .await } #[delete("{id}/icon")] @@ -265,5 +260,6 @@ pub async fn delete_organization_icon( redis.clone(), file_host, session_queue, - ).await + ) + .await } diff --git a/src/routes/v2/project_creation.rs b/src/routes/v2/project_creation.rs index 1e550392..1d628eee 100644 --- a/src/routes/v2/project_creation.rs +++ b/src/routes/v2/project_creation.rs @@ -3,7 +3,7 @@ use crate::database::redis::RedisPool; use crate::file_hosting::FileHost; use crate::models; use crate::models::ids::ImageId; -use crate::models::projects::{DonationLink, Project, ProjectStatus, SideType, Loader}; +use crate::models::projects::{DonationLink, Loader, Project, ProjectStatus, SideType}; use crate::models::v2::projects::LegacyProject; use crate::queue::session::AuthQueue; use crate::routes::v3::project_creation::default_project_type; @@ -157,41 +157,48 @@ pub async fn project_create( // Setting of 'project_type' directly is removed, it's loader-based now. let mut additional_categories = legacy_create.additional_categories; - let initial_versions = legacy_create.initial_versions.into_iter().map(|v| { - let mut fields = HashMap::new(); - fields.insert("client_side".to_string(), json!(client_side)); - fields.insert("server_side".to_string(), json!(server_side)); - fields.insert("game_versions".to_string(), json!(v.game_versions)); - - if project_type == "modpack" { - additional_categories.extend(v.loaders.iter().map(|l| l.0.clone())); - } - - let loaders = if project_type == "modpack" { - vec![Loader("mrpack".to_string())] - } else { - v.loaders - }; - - v3::version_creation::InitialVersionData { - project_id: v.project_id, - file_parts: v.file_parts, - version_number: v.version_number, - version_title: v.version_title, - version_body: v.version_body, - dependencies: v.dependencies, - release_channel: v.release_channel, - loaders, - featured: v.featured, - primary_file: v.primary_file, - status: v.status, - file_types: v.file_types, - uploaded_images: v.uploaded_images, - fields, - } - }).collect(); - - let additional_categories = additional_categories.into_iter().unique().collect::>(); + let initial_versions = legacy_create + .initial_versions + .into_iter() + .map(|v| { + let mut fields = HashMap::new(); + fields.insert("client_side".to_string(), json!(client_side)); + fields.insert("server_side".to_string(), json!(server_side)); + fields.insert("game_versions".to_string(), json!(v.game_versions)); + + if project_type == "modpack" { + additional_categories.extend(v.loaders.iter().map(|l| l.0.clone())); + } + + let loaders = if project_type == "modpack" { + vec![Loader("mrpack".to_string())] + } else { + v.loaders + }; + + v3::version_creation::InitialVersionData { + project_id: v.project_id, + file_parts: v.file_parts, + version_number: v.version_number, + version_title: v.version_title, + version_body: v.version_body, + dependencies: v.dependencies, + release_channel: v.release_channel, + loaders, + featured: v.featured, + primary_file: v.primary_file, + status: v.status, + file_types: v.file_types, + uploaded_images: v.uploaded_images, + fields, + } + }) + .collect(); + + let additional_categories = additional_categories + .into_iter() + .unique() + .collect::>(); println!("additional_categories: {:?}", additional_categories); Ok(v3::project_creation::ProjectCreateData { title: legacy_create.title, @@ -233,14 +240,17 @@ pub async fn project_create( // Convert response to V2 format match v2_reroute::extract_ok_json::(response).await { Ok(project) => { - println!("Just finished doing a project create, looking at repsonse: {:?}", serde_json::to_string(&project).unwrap()); + println!( + "Just finished doing a project create, looking at repsonse: {:?}", + serde_json::to_string(&project).unwrap() + ); let version_item = match project.versions.first() { Some(vid) => version_item::Version::get((*vid).into(), &**client, &redis).await?, None => None, }; let project = LegacyProject::from(project, version_item); Ok(HttpResponse::Ok().json(project)) - }, + } Err(response) => Ok(response), } -} \ No newline at end of file +} diff --git a/src/routes/v2/projects.rs b/src/routes/v2/projects.rs index ab82807c..f85f785c 100644 --- a/src/routes/v2/projects.rs +++ b/src/routes/v2/projects.rs @@ -491,7 +491,8 @@ pub async fn projects_edit( }), redis, session_queue, - ).await + ) + .await } #[derive(Deserialize)] @@ -550,7 +551,8 @@ pub async fn project_icon_edit( file_host, payload, session_queue, - ).await + ) + .await } #[delete("{id}/icon")] @@ -603,7 +605,8 @@ pub async fn add_gallery_item( file_host, payload, session_queue, - ).await + ) + .await } #[derive(Serialize, Deserialize, Validate)] @@ -650,7 +653,8 @@ pub async fn edit_gallery_item( pool, redis, session_queue, - ).await + ) + .await } #[derive(Serialize, Deserialize)] @@ -676,7 +680,8 @@ pub async fn delete_gallery_item( redis, file_host, session_queue, - ).await + ) + .await } #[delete("{id}")] @@ -688,14 +693,7 @@ pub async fn project_delete( config: web::Data, session_queue: web::Data, ) -> Result { - v3::projects::project_delete( - req, - info, - pool, - redis, - config, - session_queue, - ).await + v3::projects::project_delete(req, info, pool, redis, config, session_queue).await } #[post("{id}/follow")] @@ -706,13 +704,7 @@ pub async fn project_follow( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::projects::project_follow( - req, - info, - pool, - redis, - session_queue, - ).await + v3::projects::project_follow(req, info, pool, redis, session_queue).await } #[delete("{id}/follow")] @@ -723,11 +715,5 @@ pub async fn project_unfollow( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::projects::project_unfollow( - req, - info, - pool, - redis, - session_queue, - ).await + v3::projects::project_unfollow(req, info, pool, redis, session_queue).await } diff --git a/src/routes/v2/reports.rs b/src/routes/v2/reports.rs index 7c3f4a3f..f167eceb 100644 --- a/src/routes/v2/reports.rs +++ b/src/routes/v2/reports.rs @@ -2,7 +2,7 @@ use crate::database::redis::RedisPool; use crate::models::ids::ImageId; use crate::models::reports::ItemType; use crate::queue::session::AuthQueue; -use crate::routes::{ApiError, v3}; +use crate::routes::{v3, ApiError}; use actix_web::{delete, get, patch, post, web, HttpRequest, HttpResponse}; use serde::Deserialize; use sqlx::PgPool; @@ -37,13 +37,7 @@ pub async fn report_create( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::reports::report_create( - req, - pool, - body, - redis, - session_queue, - ).await + v3::reports::report_create(req, pool, body, redis, session_queue).await } #[derive(Deserialize)] @@ -69,7 +63,6 @@ pub async fn reports( count: web::Query, session_queue: web::Data, ) -> Result { - v3::reports::reports( req, pool, @@ -79,7 +72,8 @@ pub async fn reports( all: count.all, }), session_queue, - ).await + ) + .await } #[derive(Deserialize)] @@ -101,7 +95,8 @@ pub async fn reports_get( pool, redis, session_queue, - ).await + ) + .await } #[get("report/{id}")] @@ -112,13 +107,7 @@ pub async fn report_get( info: web::Path<(crate::models::reports::ReportId,)>, session_queue: web::Data, ) -> Result { - v3::reports::report_get( - req, - pool, - redis, - info, - session_queue, - ).await + v3::reports::report_get(req, pool, redis, info, session_queue).await } #[derive(Deserialize, Validate)] @@ -148,7 +137,8 @@ pub async fn report_edit( body: edit_report.body, closed: edit_report.closed, }), - ).await + ) + .await } #[delete("report/{id}")] @@ -159,11 +149,5 @@ pub async fn report_delete( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::reports::report_delete( - req, - pool, - info, - redis, - session_queue, - ).await + v3::reports::report_delete(req, pool, info, redis, session_queue).await } diff --git a/src/routes/v2/statistics.rs b/src/routes/v2/statistics.rs index cb2c3280..962bc39f 100644 --- a/src/routes/v2/statistics.rs +++ b/src/routes/v2/statistics.rs @@ -1,4 +1,4 @@ -use crate::routes::{ApiError, v3}; +use crate::routes::{v3, ApiError}; use actix_web::{get, web, HttpResponse}; use sqlx::PgPool; diff --git a/src/routes/v2/tags.rs b/src/routes/v2/tags.rs index 407d58c8..2f4075ea 100644 --- a/src/routes/v2/tags.rs +++ b/src/routes/v2/tags.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use super::ApiError; use crate::database::models::loader_fields::LoaderFieldEnumValue; use crate::database::redis::RedisPool; -use crate::routes::v3::tags::{LoaderFieldsEnumQuery, LoaderData as LoaderDataV3}; +use crate::routes::v3::tags::{LoaderData as LoaderDataV3, LoaderFieldsEnumQuery}; use crate::routes::{v2_reroute, v3}; use actix_web::{get, web, HttpResponse}; use chrono::{DateTime, Utc}; @@ -37,10 +37,7 @@ pub async fn category_list( pool: web::Data, redis: web::Data, ) -> Result { - v3::tags::category_list( - pool, - redis, - ).await + v3::tags::category_list(pool, redis).await } #[derive(serde::Serialize, serde::Deserialize)] @@ -55,11 +52,7 @@ pub async fn loader_list( pool: web::Data, redis: web::Data, ) -> Result { - let response = v3::tags::loader_list( - pool, - redis, - ) - .await?; + let response = v3::tags::loader_list(pool, redis).await?; // Convert to V2 format match v2_reroute::extract_ok_json::>(response).await { @@ -69,8 +62,7 @@ pub async fn loader_list( .map(|l| LoaderData { icon: l.icon, name: l.name, - supported_project_types: l - .supported_project_types, + supported_project_types: l.supported_project_types, }) .collect::>(); Ok(HttpResponse::Ok().json(loaders)) @@ -167,7 +159,7 @@ pub struct LicenseText { pub async fn license_text(params: web::Path<(String,)>) -> Result { v3::tags::license_text(params).await } - + #[derive(serde::Serialize)] pub struct DonationPlatformQueryData { short: String, @@ -179,10 +171,7 @@ pub async fn donation_platform_list( pool: web::Data, redis: web::Data, ) -> Result { - v3::tags::donation_platform_list( - pool, - redis, - ).await + v3::tags::donation_platform_list(pool, redis).await } #[get("report_type")] @@ -190,10 +179,7 @@ pub async fn report_type_list( pool: web::Data, redis: web::Data, ) -> Result { - v3::tags::report_type_list( - pool, - redis, - ).await + v3::tags::report_type_list(pool, redis).await } #[get("project_type")] @@ -201,10 +187,7 @@ pub async fn project_type_list( pool: web::Data, redis: web::Data, ) -> Result { - v3::tags::project_type_list( - pool, - redis, - ).await + v3::tags::project_type_list(pool, redis).await } #[get("side_type")] diff --git a/src/routes/v2/teams.rs b/src/routes/v2/teams.rs index 39d75fa9..87b2df16 100644 --- a/src/routes/v2/teams.rs +++ b/src/routes/v2/teams.rs @@ -2,7 +2,7 @@ use crate::database::redis::RedisPool; use crate::models::teams::{OrganizationPermissions, ProjectPermissions, TeamId}; use crate::models::users::UserId; use crate::queue::session::AuthQueue; -use crate::routes::{ApiError, v3}; +use crate::routes::{v3, ApiError}; use actix_web::{delete, get, patch, post, web, HttpRequest, HttpResponse}; use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; @@ -73,9 +73,14 @@ pub async fn teams_get( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::teams::teams_get(req, web::Query(v3::teams::TeamIds { - ids: ids.ids, - }), pool, redis, session_queue).await + v3::teams::teams_get( + req, + web::Query(v3::teams::TeamIds { ids: ids.ids }), + pool, + redis, + session_queue, + ) + .await } #[post("{id}/join")] @@ -121,14 +126,22 @@ pub async fn add_team_member( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::teams::add_team_member(req, info, pool, web::Json(v3::teams::NewTeamMember{ - user_id: new_member.user_id, - role: new_member.role.clone(), - permissions: new_member.permissions, - organization_permissions: new_member.organization_permissions, - payouts_split: new_member.payouts_split, - ordering: new_member.ordering, - }), redis, session_queue).await + v3::teams::add_team_member( + req, + info, + pool, + web::Json(v3::teams::NewTeamMember { + user_id: new_member.user_id, + role: new_member.role.clone(), + permissions: new_member.permissions, + organization_permissions: new_member.organization_permissions, + payouts_split: new_member.payouts_split, + ordering: new_member.ordering, + }), + redis, + session_queue, + ) + .await } #[derive(Serialize, Deserialize, Clone)] @@ -149,13 +162,21 @@ pub async fn edit_team_member( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::teams::edit_team_member(req, info, pool, web::Json(v3::teams::EditTeamMember{ - permissions: edit_member.permissions, - organization_permissions: edit_member.organization_permissions, - role: edit_member.role.clone(), - payouts_split: edit_member.payouts_split, - ordering: edit_member.ordering, - }), redis, session_queue).await + v3::teams::edit_team_member( + req, + info, + pool, + web::Json(v3::teams::EditTeamMember { + permissions: edit_member.permissions, + organization_permissions: edit_member.organization_permissions, + role: edit_member.role.clone(), + payouts_split: edit_member.payouts_split, + ordering: edit_member.ordering, + }), + redis, + session_queue, + ) + .await } #[derive(Deserialize)] @@ -172,9 +193,17 @@ pub async fn transfer_ownership( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::teams::transfer_ownership(req, info, pool, web::Json(v3::teams::TransferOwnership{ - user_id: new_owner.user_id, - }), redis, session_queue).await + v3::teams::transfer_ownership( + req, + info, + pool, + web::Json(v3::teams::TransferOwnership { + user_id: new_owner.user_id, + }), + redis, + session_queue, + ) + .await } #[delete("{id}/members/{user_id}")] diff --git a/src/routes/v2/threads.rs b/src/routes/v2/threads.rs index c9c5d8ef..6b7e8c2b 100644 --- a/src/routes/v2/threads.rs +++ b/src/routes/v2/threads.rs @@ -5,7 +5,7 @@ use crate::file_hosting::FileHost; use crate::models::ids::ThreadMessageId; use crate::models::threads::{MessageBody, ThreadId}; use crate::queue::session::AuthQueue; -use crate::routes::{ApiError, v3}; +use crate::routes::{v3, ApiError}; use actix_web::{delete, get, post, web, HttpRequest, HttpResponse}; use serde::Deserialize; use sqlx::PgPool; @@ -46,11 +46,14 @@ pub async fn threads_get( redis: web::Data, session_queue: web::Data, ) -> Result { - v3::threads::threads_get(req, web::Query( - v3::threads::ThreadIds { - ids: ids.ids - }, - ), pool, redis, session_queue).await + v3::threads::threads_get( + req, + web::Query(v3::threads::ThreadIds { ids: ids.ids }), + pool, + redis, + session_queue, + ) + .await } #[derive(Deserialize)] @@ -68,11 +71,17 @@ pub async fn thread_send_message( session_queue: web::Data, ) -> Result { let new_message = new_message.into_inner(); - v3::threads::thread_send_message(req, info, pool, web::Json( - v3::threads::NewThreadMessage { - body: new_message.body - }, - ), redis, session_queue).await + v3::threads::thread_send_message( + req, + info, + pool, + web::Json(v3::threads::NewThreadMessage { + body: new_message.body, + }), + redis, + session_queue, + ) + .await } #[get("inbox")] diff --git a/src/routes/v2/users.rs b/src/routes/v2/users.rs index 38790e36..830d81a3 100644 --- a/src/routes/v2/users.rs +++ b/src/routes/v2/users.rs @@ -1,9 +1,7 @@ use crate::database::redis::RedisPool; use crate::file_hosting::FileHost; use crate::models::projects::Project; -use crate::models::users::{ - Badges, Role, -}; +use crate::models::users::{Badges, Role}; use crate::models::v2::projects::LegacyProject; use crate::queue::payouts::PayoutsQueue; use crate::queue::session::AuthQueue; @@ -60,9 +58,7 @@ pub async fn users_get( pool: web::Data, redis: web::Data, ) -> Result { - v3::users::users_get(web::Query(v3::users::UserIds { - ids: ids.ids, - }), pool, redis).await + v3::users::users_get(web::Query(v3::users::UserIds { ids: ids.ids }), pool, redis).await } #[get("{id}")] @@ -153,15 +149,21 @@ pub async fn user_edit( session_queue: web::Data, ) -> Result { let new_user = new_user.into_inner(); - v3::users::user_edit(req, info, web::Json( - v3::users::EditUser { + v3::users::user_edit( + req, + info, + web::Json(v3::users::EditUser { username: new_user.username, name: new_user.name, bio: new_user.bio, role: new_user.role, badges: new_user.badges, - } - ), pool, redis, session_queue).await + }), + pool, + redis, + session_queue, + ) + .await } #[derive(Serialize, Deserialize)] @@ -190,7 +192,8 @@ pub async fn user_icon_edit( file_host, payload, session_queue, - ).await + ) + .await } #[derive(Deserialize)] @@ -213,10 +216,17 @@ pub async fn user_delete( session_queue: web::Data, ) -> Result { let removal_type = removal_type.into_inner(); - v3::users::user_delete(req, info, pool, + v3::users::user_delete( + req, + info, + pool, web::Query(v3::users::RemovalType { removal_type: removal_type.removal_type, - }), redis, session_queue).await + }), + redis, + session_queue, + ) + .await } #[get("{id}/follows")] @@ -270,12 +280,15 @@ pub async fn user_payouts_fees( v3::users::user_payouts_fees( req, info, - web::Query(v3::users::FeeEstimateAmount { amount: amount.amount }), + web::Query(v3::users::FeeEstimateAmount { + amount: amount.amount, + }), pool, redis, session_queue, payouts_queue, - ).await + ) + .await } #[derive(Deserialize)] @@ -297,9 +310,12 @@ pub async fn user_payouts_request( req, info, pool, - web::Json(v3::users::PayoutData { amount: data.amount }), + web::Json(v3::users::PayoutData { + amount: data.amount, + }), payouts_queue, redis, session_queue, - ).await + ) + .await } diff --git a/src/routes/v2/version_file.rs b/src/routes/v2/version_file.rs index 13dd654a..36906347 100644 --- a/src/routes/v2/version_file.rs +++ b/src/routes/v2/version_file.rs @@ -62,8 +62,7 @@ pub async fn download_version( hash_query: web::Query, session_queue: web::Data, ) -> Result { - v3::version_file::download_version(req, info, pool, redis, hash_query, session_queue) - .await + v3::version_file::download_version(req, info, pool, redis, hash_query, session_queue).await } // under /api/v1/version_file/{hash} diff --git a/src/routes/v2/versions.rs b/src/routes/v2/versions.rs index 8276d133..ffce00e2 100644 --- a/src/routes/v2/versions.rs +++ b/src/routes/v2/versions.rs @@ -277,7 +277,8 @@ pub async fn version_schedule( requested_status: scheduling_data.requested_status, }), session_queue, - ).await + ) + .await } #[delete("{version_id}")] diff --git a/src/routes/v3/analytics_get.rs b/src/routes/v3/analytics_get.rs index 82a13467..5b971318 100644 --- a/src/routes/v3/analytics_get.rs +++ b/src/routes/v3/analytics_get.rs @@ -27,7 +27,10 @@ pub fn config(cfg: &mut web::ServiceConfig) { .route("views", web::get().to(views_get)) .route("downloads", web::get().to(downloads_get)) .route("revenue", web::get().to(revenue_get)) - .route("countries/downloads", web::get().to(countries_downloads_get)) + .route( + "countries/downloads", + web::get().to(countries_downloads_get), + ) .route("countries/views", web::get().to(countries_views_get)), ); } diff --git a/src/routes/v3/mod.rs b/src/routes/v3/mod.rs index e8828655..c715d85b 100644 --- a/src/routes/v3/mod.rs +++ b/src/routes/v3/mod.rs @@ -6,9 +6,9 @@ use serde_json::json; pub mod analytics_get; pub mod collections; pub mod images; -pub mod organizations; pub mod moderation; pub mod notifications; +pub mod organizations; pub mod project_creation; pub mod projects; pub mod reports; diff --git a/src/routes/v3/notifications.rs b/src/routes/v3/notifications.rs index a12db1f5..3eda349e 100644 --- a/src/routes/v3/notifications.rs +++ b/src/routes/v3/notifications.rs @@ -11,15 +11,15 @@ use serde::{Deserialize, Serialize}; use sqlx::PgPool; pub fn config(cfg: &mut web::ServiceConfig) { - cfg.route("notifications",web::get().to(notifications_get)); - cfg.route("notifications",web::patch().to(notifications_read)); - cfg.route("notifications",web::delete().to(notifications_delete)); + cfg.route("notifications", web::get().to(notifications_get)); + cfg.route("notifications", web::patch().to(notifications_read)); + cfg.route("notifications", web::delete().to(notifications_delete)); cfg.service( web::scope("notification") - .route("{id}", web::get().to(notification_get)) - .route("{id}", web::patch().to(notification_read)) - .route("{id}", web::delete().to(notification_delete)) + .route("{id}", web::get().to(notification_get)) + .route("{id}", web::patch().to(notification_read)) + .route("{id}", web::delete().to(notification_delete)), ); } diff --git a/src/routes/v3/organizations.rs b/src/routes/v3/organizations.rs index e8bc7311..64eb1f74 100644 --- a/src/routes/v3/organizations.rs +++ b/src/routes/v3/organizations.rs @@ -1,7 +1,8 @@ use std::collections::HashMap; use std::sync::Arc; -use crate::auth::{get_user_from_headers, filter_authorized_projects}; +use super::ApiError; +use crate::auth::{filter_authorized_projects, get_user_from_headers}; use crate::database::models::team_item::TeamMember; use crate::database::models::{generate_organization_id, team_item, Organization}; use crate::database::redis::RedisPool; @@ -20,20 +21,25 @@ use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; use sqlx::PgPool; use validator::Validate; -use super::ApiError; pub fn config(cfg: &mut web::ServiceConfig) { cfg.service( web::scope("organization") - .route("{id}/projects", web::get().to(organization_projects_get)) - .route("{id}", web::get().to(organization_get)) - .route("{id}", web::patch().to(organizations_edit)) - .route("{id}", web::delete().to(organization_delete)) - .route("{id}/projects", web::post().to(organization_projects_add)) - .route("{id}/projects", web::delete().to(organization_projects_remove)) - .route("{id}/icon", web::patch().to(organization_icon_edit)) - .route("{id}/icon", web::delete().to(delete_organization_icon)) - .route("{id}/members", web::get().to(super::teams::team_members_get_organization)) + .route("{id}/projects", web::get().to(organization_projects_get)) + .route("{id}", web::get().to(organization_get)) + .route("{id}", web::patch().to(organizations_edit)) + .route("{id}", web::delete().to(organization_delete)) + .route("{id}/projects", web::post().to(organization_projects_add)) + .route( + "{id}/projects", + web::delete().to(organization_projects_remove), + ) + .route("{id}/icon", web::patch().to(organization_icon_edit)) + .route("{id}/icon", web::delete().to(delete_organization_icon)) + .route( + "{id}/members", + web::get().to(super::teams::team_members_get_organization), + ), ); } diff --git a/src/routes/v3/project_creation.rs b/src/routes/v3/project_creation.rs index 667b01f2..66890599 100644 --- a/src/routes/v3/project_creation.rs +++ b/src/routes/v3/project_creation.rs @@ -1,7 +1,7 @@ use super::version_creation::InitialVersionData; use crate::auth::{get_user_from_headers, AuthenticationError}; use crate::database::models::loader_fields::{ - LoaderField, LoaderFieldEnumValue, VersionField, Loader, + Loader, LoaderField, LoaderFieldEnumValue, VersionField, }; use crate::database::models::thread_item::ThreadBuilder; use crate::database::models::{self, image_item, User}; @@ -370,7 +370,7 @@ async fn project_create_inner( .1; let project_id: ProjectId = models::generate_project_id(transaction).await?.into(); - let all_loaders = models::loader_fields::Loader::list(&mut **transaction, redis).await?; + let all_loaders = models::loader_fields::Loader::list(&mut **transaction, redis).await?; let project_create_data: ProjectCreateData; let mut versions; @@ -565,7 +565,7 @@ async fn project_create_inner( let created_version = versions.get_mut(index).unwrap(); let version_data = project_create_data.initial_versions.get(index).unwrap(); // TODO: maybe redundant is this calculation done elsewhere? - + // Upload the new jar file super::version_creation::upload_file( &mut field, @@ -622,7 +622,7 @@ async fn project_create_inner( if ids.is_empty() { return Err(CreateError::InvalidCategory(category.clone())); } - + // TODO: We should filter out categories that don't match the project type of any of the versions // ie: if mod and modpack both share a name this should only have modpack if it only has a modpack as a version categories.extend(ids.values()); @@ -788,17 +788,19 @@ async fn project_create_inner( .flat_map(|v| v.loaders.clone()) .unique() .collect::>(); - let (project_types, games) = Loader::list(&mut **transaction, &redis).await?.into_iter().fold( - (Vec::new(), Vec::new()), - |(mut project_types, mut games), loader| { - if loaders.contains(&loader.id) { - project_types.extend(loader.supported_project_types); - games.extend(loader.supported_games.iter().map(|x| x.name().to_string())); - } - (project_types, games) - }, - ); - + let (project_types, games) = Loader::list(&mut **transaction, redis) + .await? + .into_iter() + .fold( + (Vec::new(), Vec::new()), + |(mut project_types, mut games), loader| { + if loaders.contains(&loader.id) { + project_types.extend(loader.supported_project_types); + games.extend(loader.supported_games.iter().map(|x| x.name().to_string())); + } + (project_types, games) + }, + ); let response = crate::models::projects::Project { id: project_id, @@ -876,9 +878,7 @@ async fn create_initial_version( .map(|x| { all_loaders .iter() - .find(|y| { - y.loader == x.0 - }) + .find(|y| y.loader == x.0) .ok_or_else(|| CreateError::InvalidLoader(x.0.clone())) .map(|y| y.id) }) diff --git a/src/routes/v3/projects.rs b/src/routes/v3/projects.rs index cfb2fdb1..1cc40a19 100644 --- a/src/routes/v3/projects.rs +++ b/src/routes/v3/projects.rs @@ -1,12 +1,12 @@ use std::sync::Arc; use crate::auth::{filter_authorized_projects, get_user_from_headers, is_authorized}; -use crate::database::{models as db_models, self}; -use crate::database::models::{ids as db_ids, image_item}; use crate::database::models::notification_item::NotificationBuilder; -use crate::database::models::project_item::{ModCategory, GalleryItem}; +use crate::database::models::project_item::{GalleryItem, ModCategory}; use crate::database::models::thread_item::ThreadMessageBuilder; +use crate::database::models::{ids as db_ids, image_item}; use crate::database::redis::RedisPool; +use crate::database::{self, models as db_models}; use crate::file_hosting::FileHost; use crate::models; use crate::models::ids::base62_impl::parse_base62; @@ -41,35 +41,34 @@ pub fn config(cfg: &mut web::ServiceConfig) { cfg.service( web::scope("project") - .route("{id}", web::get().to(project_get)) - .route("{id}/check", web::get().to(project_get_check)) - .route("{id}", web::delete().to(project_get)) - .route("{id}", web::patch().to(project_edit)) - .route("{id}/icon", web::patch().to(project_icon_edit)) - .route("{id}/icon", web::delete().to(delete_project_icon)) - .route("{id}/gallery", web::post().to(add_gallery_item)) - .route("{id}/gallery", web::patch().to(edit_gallery_item)) - .route("{id}/gallery", web::delete().to(delete_gallery_item)) - .route("{id}/follow", web::post().to(project_follow)) - .route("{id}/follow", web::delete().to(project_unfollow)) - .route("{id}/schedule", web::post().to(project_schedule)) + .route("{id}", web::get().to(project_get)) + .route("{id}/check", web::get().to(project_get_check)) + .route("{id}", web::delete().to(project_get)) + .route("{id}", web::patch().to(project_edit)) + .route("{id}/icon", web::patch().to(project_icon_edit)) + .route("{id}/icon", web::delete().to(delete_project_icon)) + .route("{id}/gallery", web::post().to(add_gallery_item)) + .route("{id}/gallery", web::patch().to(edit_gallery_item)) + .route("{id}/gallery", web::delete().to(delete_gallery_item)) + .route("{id}/follow", web::post().to(project_follow)) + .route("{id}/follow", web::delete().to(project_unfollow)) + .route("{id}/schedule", web::post().to(project_schedule)) .service( web::scope("{project_id}") - .route("members", web::get().to(super::teams::team_members_get_project)) + .route( + "members", + web::get().to(super::teams::team_members_get_project), + ) .route("versions", web::get().to(super::versions::version_list)) .route( "version/{slug}", web::get().to(super::versions::version_project_get), ) - .route( - "dependencies", - web::get().to(dependency_list) - ) + .route("dependencies", web::get().to(dependency_list)), ), ); } - #[derive(Deserialize, Validate)] pub struct RandomProjects { #[validate(range(min = 1, max = 100))] @@ -984,8 +983,8 @@ pub async fn edit_project_categories( let mut mod_categories = Vec::new(); for category in categories { - let category_ids = db_models::categories::Category::get_ids(category, &mut **transaction) - .await?; + let category_ids = + db_models::categories::Category::get_ids(category, &mut **transaction).await?; // TODO: We should filter out categories that don't match the project type of any of the versions // ie: if mod and modpack both share a name this should only have modpack if it only has a modpack as a version diff --git a/src/routes/v3/tags.rs b/src/routes/v3/tags.rs index 861f2d8e..a82beaf1 100644 --- a/src/routes/v3/tags.rs +++ b/src/routes/v3/tags.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use super::ApiError; -use crate::database::models::categories::{Category, DonationPlatform, ReportType, ProjectType}; +use crate::database::models::categories::{Category, DonationPlatform, ProjectType, ReportType}; use crate::database::models::loader_fields::{ Loader, LoaderField, LoaderFieldEnumValue, LoaderFieldType, }; @@ -13,14 +13,15 @@ use sqlx::PgPool; pub fn config(cfg: &mut web::ServiceConfig) { cfg.service( web::scope("tag") - .route("category", web::get().to(category_list)) - .route("loader", web::get().to(loader_list))) - .route("loader_fields", web::get().to(loader_fields_list)) - .route("license", web::get().to(license_list)) - .route("license/{id}", web::get().to(license_text)) - .route("donation_platform", web::get().to(donation_platform_list)) - .route("report_type", web::get().to(report_type_list)) - .route("project_type", web::get().to(project_type_list)); + .route("category", web::get().to(category_list)) + .route("loader", web::get().to(loader_list)), + ) + .route("loader_fields", web::get().to(loader_fields_list)) + .route("license", web::get().to(license_list)) + .route("license/{id}", web::get().to(license_text)) + .route("donation_platform", web::get().to(donation_platform_list)) + .route("report_type", web::get().to(report_type_list)) + .route("project_type", web::get().to(project_type_list)); } #[derive(serde::Serialize, serde::Deserialize)] @@ -68,7 +69,11 @@ pub async fn loader_list( icon: x.icon, name: x.loader, supported_project_types: x.supported_project_types, - supported_games: x.supported_games.iter().map(|x| x.name().to_string()).collect(), + supported_games: x + .supported_games + .iter() + .map(|x| x.name().to_string()) + .collect(), }) .collect::>(); diff --git a/src/routes/v3/teams.rs b/src/routes/v3/teams.rs index 31470bc8..05f19c69 100644 --- a/src/routes/v3/teams.rs +++ b/src/routes/v3/teams.rs @@ -20,12 +20,15 @@ pub fn config(cfg: &mut web::ServiceConfig) { cfg.service( web::scope("team") - .route("{id}/members", web::get().to(team_members_get)) - .route("{id}/members/{user_id}", web::patch().to(edit_team_member)) - .route("{id}/members/{user_id}", web::delete().to(remove_team_member)) - .route("{id}/members", web::post().to(add_team_member)) - .route("{id}/join", web::post().to(join_team)) - .route("{id}/owner", web::patch().to(transfer_ownership)) + .route("{id}/members", web::get().to(team_members_get)) + .route("{id}/members/{user_id}", web::patch().to(edit_team_member)) + .route( + "{id}/members/{user_id}", + web::delete().to(remove_team_member), + ) + .route("{id}/members", web::post().to(add_team_member)) + .route("{id}/join", web::post().to(join_team)) + .route("{id}/owner", web::patch().to(transfer_ownership)), ); } diff --git a/src/routes/v3/threads.rs b/src/routes/v3/threads.rs index ca75c025..9f10c2b5 100644 --- a/src/routes/v3/threads.rs +++ b/src/routes/v3/threads.rs @@ -24,11 +24,11 @@ use sqlx::PgPool; pub fn config(cfg: &mut web::ServiceConfig) { cfg.service( web::scope("thread") - .route("{id}", web::get().to(thread_get)) + .route("{id}", web::get().to(thread_get)) .route("inbox", web::get().to(moderation_inbox)) .route("{id}", web::post().to(thread_send_message)) - .route("{id}/read", web::post().to(thread_read)) - ); + .route("{id}/read", web::post().to(thread_read)), + ); cfg.service(web::scope("message").route("{id}", web::delete().to(message_delete))); cfg.route("threads", web::get().to(threads_get)); } diff --git a/src/routes/v3/users.rs b/src/routes/v3/users.rs index e7be0326..7e9f3a32 100644 --- a/src/routes/v3/users.rs +++ b/src/routes/v3/users.rs @@ -1,20 +1,29 @@ -use std::{sync::{Arc}, collections::HashMap}; +use std::{collections::HashMap, sync::Arc}; use actix_web::{web, HttpRequest, HttpResponse}; +use lazy_static::lazy_static; use regex::Regex; use rust_decimal::Decimal; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; use serde_json::json; use sqlx::PgPool; -use lazy_static::lazy_static; use tokio::sync::Mutex; use validator::Validate; use crate::{ auth::get_user_from_headers, - database::{models::{User}, redis::RedisPool}, - models::{ids::UserId, pats::Scopes, projects::Project, users::{Badges, Role, Payout, PayoutStatus, UserPayoutData, RecipientStatus}, collections::{CollectionStatus, Collection}, notifications::Notification}, - queue::{session::AuthQueue, payouts::PayoutsQueue}, file_hosting::FileHost, util::{routes::read_from_payload, validate::validation_errors_to_string}, + database::{models::User, redis::RedisPool}, + file_hosting::FileHost, + models::{ + collections::{Collection, CollectionStatus}, + ids::UserId, + notifications::Notification, + pats::Scopes, + projects::Project, + users::{Badges, Payout, PayoutStatus, RecipientStatus, Role, UserPayoutData}, + }, + queue::{payouts::PayoutsQueue, session::AuthQueue}, + util::{routes::read_from_payload, validate::validation_errors_to_string}, }; use super::ApiError; @@ -25,23 +34,21 @@ pub fn config(cfg: &mut web::ServiceConfig) { cfg.service( web::scope("user") - .route("{user_id}/projects", web::get().to(projects_list)) - .route("{id}", web::get().to(user_get)) - .route("{user_id}/collections", web::get().to(collections_list)) - .route("{user_id}/organizations", web::get().to(orgs_list)) - .route("{id}", web::patch().to(user_edit)) - .route("{id}/icon", web::patch().to(user_icon_edit)) - .route("{id}", web::delete().to(user_delete)) - .route("{id}/follows", web::get().to(user_follows)) - .route("{id}/notifications", web::get().to(user_notifications)) - .route("{id}/payouts", web::get().to(user_payouts)) - .route("{id}/payouts_fees", web::get().to(user_payouts_fees)) - .route("{id}/payouts", web::post().to(user_payouts_request)) - + .route("{user_id}/projects", web::get().to(projects_list)) + .route("{id}", web::get().to(user_get)) + .route("{user_id}/collections", web::get().to(collections_list)) + .route("{user_id}/organizations", web::get().to(orgs_list)) + .route("{id}", web::patch().to(user_edit)) + .route("{id}/icon", web::patch().to(user_icon_edit)) + .route("{id}", web::delete().to(user_delete)) + .route("{id}/follows", web::get().to(user_follows)) + .route("{id}/notifications", web::get().to(user_notifications)) + .route("{id}/payouts", web::get().to(user_payouts)) + .route("{id}/payouts_fees", web::get().to(user_payouts_fees)) + .route("{id}/payouts", web::post().to(user_payouts_request)), ); } - pub async fn projects_list( req: HttpRequest, info: web::Path<(String,)>, @@ -270,7 +277,6 @@ pub async fn orgs_list( } } - lazy_static! { static ref RE_URL_SAFE: Regex = Regex::new(r"^[a-zA-Z0-9_-]*$").unwrap(); } @@ -670,7 +676,10 @@ pub async fn user_notifications( .collect(); notifications.sort_by(|a, b| b.created.cmp(&a.created)); - println!("notifications: {:?}", serde_json::to_string(¬ifications).unwrap()); + println!( + "notifications: {:?}", + serde_json::to_string(¬ifications).unwrap() + ); Ok(HttpResponse::Ok().json(notifications)) } else { Ok(HttpResponse::NotFound().body("")) diff --git a/src/routes/v3/version_creation.rs b/src/routes/v3/version_creation.rs index c8fd74ab..3176a103 100644 --- a/src/routes/v3/version_creation.rs +++ b/src/routes/v3/version_creation.rs @@ -1,8 +1,6 @@ use super::project_creation::{CreateError, UploadedFile}; use crate::auth::get_user_from_headers; -use crate::database::models::loader_fields::{ - LoaderField, LoaderFieldEnumValue, VersionField, -}; +use crate::database::models::loader_fields::{LoaderField, LoaderFieldEnumValue, VersionField}; use crate::database::models::notification_item::NotificationBuilder; use crate::database::models::version_item::{ DependencyBuilder, VersionBuilder, VersionFileBuilder, @@ -16,8 +14,8 @@ use crate::models::pack::PackFileHash; use crate::models::pats::Scopes; use crate::models::projects::{skip_nulls, DependencyType}; use crate::models::projects::{ - Dependency, FileType, Loader, ProjectId, Version, VersionFile, VersionId, - VersionStatus, VersionType, + Dependency, FileType, Loader, ProjectId, Version, VersionFile, VersionId, VersionStatus, + VersionType, }; use crate::models::teams::ProjectPermissions; use crate::queue::session::AuthQueue; @@ -204,7 +202,9 @@ async fn version_create_inner( // Ensure that the project this version is being added to exists if models::Project::get_id(project_id, &mut **transaction, redis) - .await?.is_none() { + .await? + .is_none() + { return Err(CreateError::InvalidInput( "An invalid project id was supplied".to_string(), )); @@ -252,11 +252,8 @@ async fn version_create_inner( let version_id: VersionId = models::generate_version_id(transaction).await?.into(); - let all_loaders = models::loader_fields::Loader::list( - &mut **transaction, - redis, - ) - .await?; + let all_loaders = + models::loader_fields::Loader::list(&mut **transaction, redis).await?; let loader_fields = LoaderField::get_fields(&mut **transaction, redis).await?; let mut version_fields = vec![]; @@ -294,16 +291,13 @@ async fn version_create_inner( .map(|x| { all_loaders .iter() - .find(|y| { - y.loader == x.0 - }) + .find(|y| y.loader == x.0) .cloned() .ok_or_else(|| CreateError::InvalidLoader(x.0.clone())) - }).collect::, _>>()?; + }) + .collect::, _>>()?; selected_loaders = Some(loaders.clone()); - let loader_ids = loaders.iter() - .map(|y| y.id) - .collect_vec(); + let loader_ids = loaders.iter().map(|y| y.id).collect_vec(); let dependencies = version_create_data .dependencies @@ -315,7 +309,7 @@ async fn version_create_inner( file_name: None, }) .collect::>(); - + version_builder = Some(VersionBuilder { version_id: version_id.into(), project_id, @@ -342,8 +336,11 @@ async fn version_create_inner( let loaders = selected_loaders.as_ref().ok_or_else(|| { CreateError::InvalidInput(String::from("`data` field must come before file fields")) })?; - let loaders = loaders.iter().map(|x| Loader(x.loader.clone())).collect::>(); - + let loaders = loaders + .iter() + .map(|x| Loader(x.loader.clone())) + .collect::>(); + let version_data = initial_version_data .clone() .ok_or_else(|| CreateError::InvalidInput("`data` field is required".to_string()))?; @@ -420,11 +417,13 @@ async fn version_create_inner( .await?; let loader_structs = selected_loaders.unwrap_or_default(); - let (all_project_types, all_games) : (Vec, Vec) = loader_structs.iter().fold((vec![], vec![]), |mut acc, x| { - acc.0.extend_from_slice(&x.supported_project_types); - acc.1.extend(x.supported_games.iter().map(|x| x.name().to_string())); - acc - }); + let (all_project_types, all_games): (Vec, Vec) = + loader_structs.iter().fold((vec![], vec![]), |mut acc, x| { + acc.0.extend_from_slice(&x.supported_project_types); + acc.1 + .extend(x.supported_games.iter().map(|x| x.name().to_string())); + acc + }); let response = Version { id: builder.version_id.into(), @@ -605,20 +604,20 @@ async fn upload_file_to_version_inner( .map(|x| { all_loaders .iter() - .find(|y| { - &y.loader == x - }) + .find(|y| &y.loader == x) .cloned() .ok_or_else(|| CreateError::InvalidLoader(x.clone())) - }).collect::, _>>()?; - - if models::Project::get_id(version.inner.project_id, &mut **transaction, &redis) - .await?.is_none() { - return Err(CreateError::InvalidInput( - "An invalid project id was supplied".to_string(), - )); - } + }) + .collect::, _>>()?; + if models::Project::get_id(version.inner.project_id, &mut **transaction, &redis) + .await? + .is_none() + { + return Err(CreateError::InvalidInput( + "An invalid project id was supplied".to_string(), + )); + } if !user.role.is_admin() { let team_member = models::TeamMember::get_from_user_id_project( @@ -689,8 +688,11 @@ async fn upload_file_to_version_inner( CreateError::InvalidInput(String::from("`data` field must come before file fields")) })?; - let loaders = selected_loaders.iter().map(|x| Loader(x.loader.clone())).collect::>(); - + let loaders = selected_loaders + .iter() + .map(|x| Loader(x.loader.clone())) + .collect::>(); + let mut dependencies = version .dependencies .iter() @@ -765,7 +767,7 @@ pub async fn upload_file( project_id: ProjectId, version_id: VersionId, version_fields: &[VersionField], - loaders : Vec, + loaders: Vec, ignore_primary: bool, force_primary: bool, file_type: Option, @@ -887,8 +889,7 @@ pub async fn upload_file( } let data = data.freeze(); - let primary = (version_files.iter().all(|x| !x.primary) - && !ignore_primary) + let primary = (version_files.iter().all(|x| !x.primary) && !ignore_primary) || force_primary || total_files_len == 1; diff --git a/src/routes/v3/version_file.rs b/src/routes/v3/version_file.rs index 428409ac..28375d70 100644 --- a/src/routes/v3/version_file.rs +++ b/src/routes/v3/version_file.rs @@ -616,7 +616,6 @@ pub struct DownloadRedirect { pub url: String, } - // under /api/v1/version_file/{hash}/download pub async fn download_version( req: HttpRequest, diff --git a/src/routes/v3/versions.rs b/src/routes/v3/versions.rs index 382c5a8b..dfe128f4 100644 --- a/src/routes/v3/versions.rs +++ b/src/routes/v3/versions.rs @@ -7,7 +7,7 @@ use crate::auth::{ use crate::database; use crate::database::models::loader_fields::{LoaderField, LoaderFieldEnumValue, VersionField}; use crate::database::models::version_item::{DependencyBuilder, LoaderVersion}; -use crate::database::models::{Organization, image_item}; +use crate::database::models::{image_item, Organization}; use crate::database::redis::RedisPool; use crate::models; use crate::models::ids::base62_impl::parse_base62; @@ -349,33 +349,29 @@ pub async fn version_edit_helper( if let Some(dependencies) = &new_version.dependencies { // TODO: Re-add this exclusions when modpack also has separate dependency retrieval that was removed from validators // if let Some(project) = project_item { - // if project.project_type != "modpack" { - sqlx::query!( - " + // if project.project_type != "modpack" { + sqlx::query!( + " DELETE FROM dependencies WHERE dependent_id = $1 ", - id as database::models::ids::VersionId, - ) - .execute(&mut *transaction) - .await?; - - let builders = dependencies - .iter() - .map(|x| database::models::version_item::DependencyBuilder { - project_id: x.project_id.map(|x| x.into()), - version_id: x.version_id.map(|x| x.into()), - file_name: x.file_name.clone(), - dependency_type: x.dependency_type.to_string(), - }) - .collect::>(); - - DependencyBuilder::insert_many( - builders, - version_item.inner.id, - &mut transaction, - ) - .await?; - // } + id as database::models::ids::VersionId, + ) + .execute(&mut *transaction) + .await?; + + let builders = dependencies + .iter() + .map(|x| database::models::version_item::DependencyBuilder { + project_id: x.project_id.map(|x| x.into()), + version_id: x.version_id.map(|x| x.into()), + file_name: x.file_name.clone(), + dependency_type: x.dependency_type.to_string(), + }) + .collect::>(); + + DependencyBuilder::insert_many(builders, version_item.inner.id, &mut transaction) + .await?; + // } // } } diff --git a/src/validate/mod.rs b/src/validate/mod.rs index 1ddaa33c..90507927 100644 --- a/src/validate/mod.rs +++ b/src/validate/mod.rs @@ -118,7 +118,7 @@ pub async fn validate_file( transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>, redis: &RedisPool, ) -> Result { - // TODO: This needs to be revisited or removed with v3. + // TODO: This needs to be revisited or removed with v3. // Currently, it checks if the loader is the modpack loader, and extracts the pack data from it. // This (and the funnction that calls this) should be refactored such that // - validators are removed (or altogether reworked) @@ -143,7 +143,7 @@ pub async fn validate_file( file_type, ) .await - }, + } _ => Ok(ValidationResult::Pass), } } diff --git a/tests/common/dummy_data.rs b/tests/common/dummy_data.rs index da063c07..619579a0 100644 --- a/tests/common/dummy_data.rs +++ b/tests/common/dummy_data.rs @@ -4,11 +4,10 @@ use std::io::{Cursor, Write}; use actix_http::StatusCode; use actix_web::test::{self, TestRequest}; use labrinth::models::{ - - oauth_clients::OAuthClient, organizations::Organization, + oauth_clients::OAuthClient, + organizations::Organization, pats::Scopes, - v2::projects::{LegacyProject, LegacyVersion, - }, + v2::projects::{LegacyProject, LegacyVersion}, }; use serde_json::json; use sqlx::Executor; @@ -19,11 +18,7 @@ use labrinth::util::actix::{AppendsMultipart, MultipartSegment, MultipartSegment use super::{environment::TestEnvironment, request_data::get_public_project_creation_data}; -use super::{ - asserts::assert_status, - database::USER_USER_ID, - get_json_val_str, -}; +use super::{asserts::assert_status, database::USER_USER_ID, get_json_val_str}; pub const DUMMY_DATA_UPDATE: i64 = 3; diff --git a/tests/tags.rs b/tests/tags.rs index 60aebdfb..51f408ca 100644 --- a/tests/tags.rs +++ b/tests/tags.rs @@ -29,7 +29,10 @@ async fn get_tags() { let loader_names = loaders.into_iter().map(|x| x.name).collect::>(); assert_eq!( loader_names, - ["fabric", "forge", "mrpack"].iter().map(|s| s.to_string()).collect() + ["fabric", "forge", "mrpack"] + .iter() + .map(|s| s.to_string()) + .collect() ); let side_type_names = side_types.into_iter().collect::>();