You've already forked AstralRinth
forked from didirus/AstralRinth
gv loader cache bring back (#677)
* gv loader cache bring back * run prep fmt
This commit is contained in:
20
migrations/20230808162652_gv-loader-fixes.sql
Normal file
20
migrations/20230808162652_gv-loader-fixes.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
ALTER TABLE mods ADD COLUMN loaders varchar(255)[] NOT NULL default array[]::varchar[];
|
||||
ALTER TABLE mods ADD COLUMN game_versions varchar(255)[] NOT NULL default array[]::varchar[];
|
||||
|
||||
UPDATE mods
|
||||
SET loaders = (
|
||||
SELECT COALESCE(ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null), array[]::varchar[])
|
||||
FROM versions v
|
||||
INNER JOIN loaders_versions lv ON lv.version_id = v.id
|
||||
INNER JOIN loaders l on lv.loader_id = l.id
|
||||
WHERE v.mod_id = mods.id
|
||||
);
|
||||
|
||||
UPDATE mods
|
||||
SET game_versions = (
|
||||
SELECT COALESCE(ARRAY_AGG(DISTINCT gv.version) filter (where gv.version is not null), array[]::varchar[])
|
||||
FROM versions v
|
||||
INNER JOIN game_versions_versions gvv ON v.id = gvv.joining_version_id
|
||||
INNER JOIN game_versions gv on gvv.game_version_id = gv.id
|
||||
WHERE v.mod_id = mods.id
|
||||
);
|
||||
538
sqlx-data.json
538
sqlx-data.json
@@ -573,6 +573,19 @@
|
||||
},
|
||||
"query": "\n DELETE FROM sessions WHERE id = $1\n "
|
||||
},
|
||||
"177716d2b04fd2a2b63b2e14c8ffdfa554d84254b14053496c118dec24bf5049": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"TextArray"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "\n UPDATE mods\n SET game_versions = (\n SELECT COALESCE(ARRAY_AGG(DISTINCT gv.version) filter (where gv.version is not null), array[]::varchar[])\n FROM versions v\n INNER JOIN game_versions_versions gvv ON v.id = gvv.joining_version_id\n INNER JOIN game_versions gv on gvv.game_version_id = gv.id\n WHERE v.mod_id = mods.id AND v.status != ALL($2)\n )\n WHERE id = $1\n "
|
||||
},
|
||||
"1931ff3846345c0af4e15c3a84dcbfc7c9cbb92c98d2e73634f611a1e5358c7a": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
@@ -2575,6 +2588,19 @@
|
||||
},
|
||||
"query": "\n SELECT r.id, rt.name, r.mod_id, r.version_id, r.user_id, r.body, r.reporter, r.created, t.id thread_id, r.closed\n FROM reports r\n INNER JOIN report_types rt ON rt.id = r.report_type_id\n INNER JOIN threads t ON t.report_id = r.id\n WHERE r.id = ANY($1)\n ORDER BY r.created DESC\n "
|
||||
},
|
||||
"6b89c2b2557e304c2a3a02d7824327685f9be696254bf2370d0c995aafc6a2d8": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"TextArray"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "\n UPDATE mods\n SET loaders = (\n SELECT COALESCE(ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null), array[]::varchar[])\n FROM versions v\n INNER JOIN loaders_versions lv ON lv.version_id = v.id\n INNER JOIN loaders l on lv.loader_id = l.id\n WHERE v.mod_id = mods.id AND v.status != ALL($2)\n )\n WHERE id = $1\n "
|
||||
},
|
||||
"6c7aeb0db4a4fb3387c37b8d7aca6fdafaa637fd883a44416b56270aeebb7a01": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
@@ -3017,6 +3043,262 @@
|
||||
},
|
||||
"query": "\n SELECT n.id FROM notifications n\n WHERE n.user_id = $1\n "
|
||||
},
|
||||
"7b1d14e79d07247bf3061accdccdd83a36abb186ebeb253f34daf6c7337c6f7c": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"ordinal": 0,
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"name": "project_type",
|
||||
"ordinal": 1,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"ordinal": 2,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "description",
|
||||
"ordinal": 3,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "downloads",
|
||||
"ordinal": 4,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "follows",
|
||||
"ordinal": 5,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "icon_url",
|
||||
"ordinal": 6,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"ordinal": 7,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "published",
|
||||
"ordinal": 8,
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "updated",
|
||||
"ordinal": 9,
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "approved",
|
||||
"ordinal": 10,
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "queued",
|
||||
"ordinal": 11,
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
"ordinal": 12,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "requested_status",
|
||||
"ordinal": 13,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "issues_url",
|
||||
"ordinal": 14,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "source_url",
|
||||
"ordinal": 15,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "wiki_url",
|
||||
"ordinal": 16,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "discord_url",
|
||||
"ordinal": 17,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "license_url",
|
||||
"ordinal": 18,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "team_id",
|
||||
"ordinal": 19,
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"name": "client_side",
|
||||
"ordinal": 20,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "server_side",
|
||||
"ordinal": 21,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "license",
|
||||
"ordinal": 22,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "slug",
|
||||
"ordinal": 23,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "moderation_message",
|
||||
"ordinal": 24,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "moderation_message_body",
|
||||
"ordinal": 25,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "client_side_type",
|
||||
"ordinal": 26,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "server_side_type",
|
||||
"ordinal": 27,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "project_type_name",
|
||||
"ordinal": 28,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "webhook_sent",
|
||||
"ordinal": 29,
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"name": "color",
|
||||
"ordinal": 30,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "thread_id",
|
||||
"ordinal": 31,
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"name": "monetization_status",
|
||||
"ordinal": 32,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "loaders",
|
||||
"ordinal": 33,
|
||||
"type_info": "VarcharArray"
|
||||
},
|
||||
{
|
||||
"name": "game_versions",
|
||||
"ordinal": 34,
|
||||
"type_info": "VarcharArray"
|
||||
},
|
||||
{
|
||||
"name": "categories",
|
||||
"ordinal": 35,
|
||||
"type_info": "VarcharArray"
|
||||
},
|
||||
{
|
||||
"name": "additional_categories",
|
||||
"ordinal": 36,
|
||||
"type_info": "VarcharArray"
|
||||
},
|
||||
{
|
||||
"name": "versions",
|
||||
"ordinal": 37,
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"name": "gallery",
|
||||
"ordinal": 38,
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"name": "donations",
|
||||
"ordinal": 39,
|
||||
"type_info": "Jsonb"
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8Array",
|
||||
"TextArray",
|
||||
"TextArray"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "\n SELECT m.id 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.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.client_side client_side, m.server_side server_side, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,\n cs.name client_side_type, ss.name server_side_type, pt.name project_type_name, m.webhook_sent, m.color,\n t.id thread_id, m.monetization_status monetization_status, m.loaders loaders, m.game_versions game_versions,\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 project_types pt ON pt.id = m.project_type\n INNER JOIN side_types cs ON m.client_side = cs.id\n INNER JOIN side_types ss ON m.server_side = ss.id\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 WHERE m.id = ANY($1) OR m.slug = ANY($2)\n GROUP BY pt.id, cs.id, ss.id, t.id, m.id;\n "
|
||||
},
|
||||
"7c0cdacf0898155c94008a96a0b918550df4475b9e3362a926d4d00e001880c1": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
@@ -4602,262 +4884,6 @@
|
||||
},
|
||||
"query": "\n SELECT id, user_id, session, created, last_login, expires, refresh_expires, os, platform,\n city, country, ip, user_agent\n FROM sessions\n WHERE id = ANY($1) OR session = ANY($2)\n ORDER BY created DESC\n "
|
||||
},
|
||||
"cb1958b4d8821c8b1b3af4f567f7882939b0ac2fb50d12bd1638281d898b822f": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"ordinal": 0,
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"name": "project_type",
|
||||
"ordinal": 1,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"ordinal": 2,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "description",
|
||||
"ordinal": 3,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "downloads",
|
||||
"ordinal": 4,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "follows",
|
||||
"ordinal": 5,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "icon_url",
|
||||
"ordinal": 6,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"ordinal": 7,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "published",
|
||||
"ordinal": 8,
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "updated",
|
||||
"ordinal": 9,
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "approved",
|
||||
"ordinal": 10,
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "queued",
|
||||
"ordinal": 11,
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
"ordinal": 12,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "requested_status",
|
||||
"ordinal": 13,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "issues_url",
|
||||
"ordinal": 14,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "source_url",
|
||||
"ordinal": 15,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "wiki_url",
|
||||
"ordinal": 16,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "discord_url",
|
||||
"ordinal": 17,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "license_url",
|
||||
"ordinal": 18,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "team_id",
|
||||
"ordinal": 19,
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"name": "client_side",
|
||||
"ordinal": 20,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "server_side",
|
||||
"ordinal": 21,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "license",
|
||||
"ordinal": 22,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "slug",
|
||||
"ordinal": 23,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "moderation_message",
|
||||
"ordinal": 24,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "moderation_message_body",
|
||||
"ordinal": 25,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "client_side_type",
|
||||
"ordinal": 26,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "server_side_type",
|
||||
"ordinal": 27,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "project_type_name",
|
||||
"ordinal": 28,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "webhook_sent",
|
||||
"ordinal": 29,
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"name": "color",
|
||||
"ordinal": 30,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "thread_id",
|
||||
"ordinal": 31,
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"name": "monetization_status",
|
||||
"ordinal": 32,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "loaders",
|
||||
"ordinal": 33,
|
||||
"type_info": "VarcharArray"
|
||||
},
|
||||
{
|
||||
"name": "game_versions",
|
||||
"ordinal": 34,
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"name": "categories",
|
||||
"ordinal": 35,
|
||||
"type_info": "VarcharArray"
|
||||
},
|
||||
{
|
||||
"name": "additional_categories",
|
||||
"ordinal": 36,
|
||||
"type_info": "VarcharArray"
|
||||
},
|
||||
{
|
||||
"name": "versions",
|
||||
"ordinal": 37,
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"name": "gallery",
|
||||
"ordinal": 38,
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"name": "donations",
|
||||
"ordinal": 39,
|
||||
"type_info": "Jsonb"
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8Array",
|
||||
"TextArray",
|
||||
"TextArray"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "\n SELECT m.id 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.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.client_side client_side, m.server_side server_side, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,\n cs.name client_side_type, ss.name server_side_type, 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 JSONB_AGG(DISTINCT jsonb_build_object('id', gv.version, 'created', gv.created)) filter (where gv.version is not null) game_versions,\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 project_types pt ON pt.id = m.project_type\n INNER JOIN side_types cs ON m.client_side = cs.id\n INNER JOIN side_types ss ON m.server_side = ss.id\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 v.id = lv.version_id\n LEFT JOIN loaders l ON lv.loader_id = l.id\n LEFT JOIN game_versions_versions gvv ON v.id = gvv.joining_version_id\n LEFT JOIN game_versions gv ON gvv.game_version_id = gv.id\n WHERE m.id = ANY($1) OR m.slug = ANY($2)\n GROUP BY pt.id, cs.id, ss.id, t.id, m.id;\n "
|
||||
},
|
||||
"cb57ae673f1a7e50cc319efddb9bdc82e2251596bcf85aea52e8def343e423b8": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
|
||||
@@ -154,6 +154,8 @@ impl ProjectBuilder {
|
||||
webhook_sent: false,
|
||||
color: self.color,
|
||||
monetization_status: self.monetization_status,
|
||||
loaders: vec![],
|
||||
game_versions: vec![],
|
||||
};
|
||||
project_struct.insert(&mut *transaction).await?;
|
||||
|
||||
@@ -196,6 +198,9 @@ impl ProjectBuilder {
|
||||
.await?;
|
||||
}
|
||||
|
||||
Project::update_game_versions(self.project_id, &mut *transaction).await?;
|
||||
Project::update_loaders(self.project_id, &mut *transaction).await?;
|
||||
|
||||
Ok(self.project_id)
|
||||
}
|
||||
}
|
||||
@@ -231,6 +236,8 @@ pub struct Project {
|
||||
pub webhook_sent: bool,
|
||||
pub color: Option<u32>,
|
||||
pub monetization_status: MonetizationStatus,
|
||||
pub loaders: Vec<String>,
|
||||
pub game_versions: Vec<String>,
|
||||
}
|
||||
|
||||
impl Project {
|
||||
@@ -547,9 +554,7 @@ impl Project {
|
||||
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,
|
||||
m.team_id team_id, m.client_side client_side, m.server_side server_side, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,
|
||||
cs.name client_side_type, ss.name server_side_type, pt.name project_type_name, m.webhook_sent, m.color,
|
||||
t.id thread_id, m.monetization_status monetization_status,
|
||||
ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null) loaders,
|
||||
JSONB_AGG(DISTINCT jsonb_build_object('id', gv.version, 'created', gv.created)) filter (where gv.version is not null) game_versions,
|
||||
t.id thread_id, m.monetization_status monetization_status, m.loaders loaders, m.game_versions game_versions,
|
||||
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,
|
||||
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,
|
||||
JSONB_AGG(DISTINCT jsonb_build_object('id', v.id, 'date_published', v.date_published)) filter (where v.id is not null) versions,
|
||||
@@ -566,10 +571,6 @@ impl Project {
|
||||
LEFT JOIN mods_categories mc ON mc.joining_mod_id = m.id
|
||||
LEFT JOIN categories c ON mc.joining_category_id = c.id
|
||||
LEFT JOIN versions v ON v.mod_id = m.id AND v.status = ANY($3)
|
||||
LEFT JOIN loaders_versions lv ON v.id = lv.version_id
|
||||
LEFT JOIN loaders l ON lv.loader_id = l.id
|
||||
LEFT JOIN game_versions_versions gvv ON v.id = gvv.joining_version_id
|
||||
LEFT JOIN game_versions gv ON gvv.game_version_id = gv.id
|
||||
WHERE m.id = ANY($1) OR m.slug = ANY($2)
|
||||
GROUP BY pt.id, cs.id, ss.id, t.id, m.id;
|
||||
",
|
||||
@@ -620,6 +621,8 @@ impl Project {
|
||||
monetization_status: MonetizationStatus::from_str(
|
||||
&m.monetization_status,
|
||||
),
|
||||
loaders: m.loaders,
|
||||
game_versions: m.game_versions,
|
||||
},
|
||||
project_type: m.project_type_name,
|
||||
categories: m.categories.unwrap_or_default(),
|
||||
@@ -655,25 +658,7 @@ impl Project {
|
||||
).ok().unwrap_or_default(),
|
||||
client_side: crate::models::projects::SideType::from_str(&m.client_side_type),
|
||||
server_side: crate::models::projects::SideType::from_str(&m.server_side_type),
|
||||
loaders: m.loaders.unwrap_or_default(),
|
||||
game_versions: {
|
||||
#[derive(Deserialize)]
|
||||
struct GameVersion {
|
||||
pub id: String,
|
||||
pub created: DateTime<Utc>,
|
||||
}
|
||||
|
||||
let mut game_versions: Vec<GameVersion> = serde_json::from_value(
|
||||
m.game_versions.unwrap_or_default(),
|
||||
)
|
||||
.ok()
|
||||
.unwrap_or_default();
|
||||
|
||||
game_versions.sort_by(|a, b| a.created.cmp(&b.created));
|
||||
|
||||
game_versions.into_iter().map(|x| x.id).collect()
|
||||
},
|
||||
thread_id: ThreadId(m.thread_id),
|
||||
thread_id: ThreadId(m.thread_id),
|
||||
}}))
|
||||
})
|
||||
.try_collect::<Vec<QueryProject>>()
|
||||
@@ -771,6 +756,56 @@ impl Project {
|
||||
Ok(dependencies)
|
||||
}
|
||||
|
||||
pub async fn update_game_versions(
|
||||
id: ProjectId,
|
||||
transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,
|
||||
) -> Result<(), sqlx::error::Error> {
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE mods
|
||||
SET game_versions = (
|
||||
SELECT COALESCE(ARRAY_AGG(DISTINCT gv.version) filter (where gv.version is not null), array[]::varchar[])
|
||||
FROM versions v
|
||||
INNER JOIN game_versions_versions gvv ON v.id = gvv.joining_version_id
|
||||
INNER JOIN game_versions gv on gvv.game_version_id = gv.id
|
||||
WHERE v.mod_id = mods.id AND v.status != ALL($2)
|
||||
)
|
||||
WHERE id = $1
|
||||
",
|
||||
id as ProjectId,
|
||||
&*crate::models::projects::VersionStatus::iterator().filter(|x| x.is_hidden()).map(|x| x.to_string()).collect::<Vec<String>>()
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn update_loaders(
|
||||
id: ProjectId,
|
||||
transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,
|
||||
) -> Result<(), sqlx::error::Error> {
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE mods
|
||||
SET loaders = (
|
||||
SELECT COALESCE(ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null), array[]::varchar[])
|
||||
FROM versions v
|
||||
INNER JOIN loaders_versions lv ON lv.version_id = v.id
|
||||
INNER JOIN loaders l on lv.loader_id = l.id
|
||||
WHERE v.mod_id = mods.id AND v.status != ALL($2)
|
||||
)
|
||||
WHERE id = $1
|
||||
",
|
||||
id as ProjectId,
|
||||
&*crate::models::projects::VersionStatus::iterator().filter(|x| x.is_hidden()).map(|x| x.to_string()).collect::<Vec<String>>()
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn clear_cache(
|
||||
id: ProjectId,
|
||||
slug: Option<String>,
|
||||
@@ -809,7 +844,5 @@ pub struct QueryProject {
|
||||
pub gallery_items: Vec<GalleryItem>,
|
||||
pub client_side: crate::models::projects::SideType,
|
||||
pub server_side: crate::models::projects::SideType,
|
||||
pub loaders: Vec<String>,
|
||||
pub game_versions: Vec<String>,
|
||||
pub thread_id: ThreadId,
|
||||
}
|
||||
|
||||
@@ -381,6 +381,17 @@ impl Version {
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
crate::database::models::Project::update_game_versions(
|
||||
ProjectId(project_id.mod_id),
|
||||
&mut *transaction,
|
||||
)
|
||||
.await?;
|
||||
crate::database::models::Project::update_loaders(
|
||||
ProjectId(project_id.mod_id),
|
||||
&mut *transaction,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Some(()))
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,8 @@ impl From<QueryProject> for Project {
|
||||
followers: m.follows as u32,
|
||||
categories: data.categories,
|
||||
additional_categories: data.additional_categories,
|
||||
game_versions: data.game_versions,
|
||||
loaders: data.loaders,
|
||||
game_versions: m.game_versions,
|
||||
loaders: m.loaders,
|
||||
versions: data.versions.into_iter().map(|v| v.into()).collect(),
|
||||
icon_url: m.icon_url,
|
||||
issues_url: m.issues_url,
|
||||
|
||||
@@ -436,6 +436,8 @@ async fn version_create_inner(
|
||||
let project_id = builder.project_id;
|
||||
builder.insert(transaction).await?;
|
||||
|
||||
models::Project::update_game_versions(project_id, &mut *transaction).await?;
|
||||
models::Project::update_loaders(project_id, &mut *transaction).await?;
|
||||
models::Project::clear_cache(project_id, None, Some(true), redis).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
|
||||
@@ -476,6 +476,12 @@ pub async fn version_edit(
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
}
|
||||
|
||||
database::models::Project::update_game_versions(
|
||||
version_item.inner.project_id,
|
||||
&mut transaction,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if let Some(loaders) = &new_version.loaders {
|
||||
@@ -509,6 +515,12 @@ pub async fn version_edit(
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
}
|
||||
|
||||
database::models::Project::update_loaders(
|
||||
version_item.inner.project_id,
|
||||
&mut transaction,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if let Some(featured) = &new_version.featured {
|
||||
|
||||
Reference in New Issue
Block a user