From d5f602d80dfc352cb293cf78f0e5539881f96076 Mon Sep 17 00:00:00 2001 From: Alexandre Henrique Afonso Campos Date: Tue, 1 Jul 2025 21:16:08 -0300 Subject: [PATCH 1/5] Fix part of the scripts for testing sum of ranks --- server/db/migration/V1__tables.sql | 2 +- server/src/main/resources/schema.sql | 2 +- .../generate_0.json | 6 +- .../sum-of-ranks-controller-i-t/list_0.json | 40 +- .../sum-of-ranks-controller-i-t/list_1.json | 24 +- .../sum-of-ranks-controller-i-t/list_3.json | 12 +- .../sum-of-ranks-controller-i-t/list_4.json | 465 ------------------ .../sum-of-ranks-controller-i-t/list_5.json | 465 ------------------ .../test-scripts/SumOfRanksControllerIT.sql | 51 +- .../resources/test-scripts/cleanTestData.sql | 2 + 10 files changed, 92 insertions(+), 977 deletions(-) delete mode 100644 server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_4.json delete mode 100644 server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_5.json diff --git a/server/db/migration/V1__tables.sql b/server/db/migration/V1__tables.sql index 708a9c4f..acd6d52a 100644 --- a/server/db/migration/V1__tables.sql +++ b/server/db/migration/V1__tables.sql @@ -2333,7 +2333,7 @@ CREATE TABLE `sum_of_ranks` ( `region_type` varchar(20) NOT NULL, `wca_id` varchar(10) NOT NULL, `name` varchar(255) DEFAULT NULL, - `country_iso2` varchar(2) DEFAULT NULL, + `country_iso2` varchar(100) DEFAULT NULL, `result_type` varchar(7) NOT NULL, `overall` int DEFAULT NULL, `events` json NOT NULL, diff --git a/server/src/main/resources/schema.sql b/server/src/main/resources/schema.sql index 07422b94..bbf4554c 100644 --- a/server/src/main/resources/schema.sql +++ b/server/src/main/resources/schema.sql @@ -39,7 +39,7 @@ create table if not exists sum_of_ranks ( region_type varchar(20) not null, wca_id varchar(10) not null, name varchar(255), - country_iso2 varchar(2), + country_iso2 varchar(100), result_type varchar(7) not null, overall int default null, events json not null, diff --git a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/generate_0.json b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/generate_0.json index 593a4915..9d7b1462 100644 --- a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/generate_0.json +++ b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/generate_0.json @@ -1,6 +1,6 @@ { "worldRank": 68, - "continentRank": 68, - "countryRank": 68, - "meta": 10 + "continentRank": 0, + "countryRank": 34, + "meta": 4 } \ No newline at end of file diff --git a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_0.json b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_0.json index aa2cb0db..bed33239 100644 --- a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_0.json +++ b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_0.json @@ -5,8 +5,8 @@ { "regionRank": 1, "wcaId": "2014GERB01", - "name": "Henri Gerber", - "countryIso2": "DE", + "name": "2014GERB01", + "countryIso2": "Germany", "overall": 3277, "events": [ { @@ -167,8 +167,8 @@ { "regionRank": 2, "wcaId": "2015CECC01", - "name": "Vicenzo Guerino Cecchini", - "countryIso2": "BR", + "name": "2015CECC01 Cecchini", + "countryIso2": "Brazil", "overall": 5495, "events": [ { @@ -329,8 +329,8 @@ { "regionRank": 3, "wcaId": "2014FRIT02", - "name": "Oliver Fritz", - "countryIso2": "DE", + "name": "2014FRIT02", + "countryIso2": "Germany", "overall": 5515, "events": [ { @@ -491,8 +491,8 @@ { "regionRank": 4, "wcaId": "2013GERH01", - "name": "Kevin Gerhardt", - "countryIso2": "DE", + "name": "2013GERH01", + "countryIso2": "Germany", "overall": 6035, "events": [ { @@ -653,8 +653,8 @@ { "regionRank": 5, "wcaId": "2015MATT05", - "name": "Enzo Mattos", - "countryIso2": "BR", + "name": "2015MATT05", + "countryIso2": "Brazil", "overall": 9504, "events": [ { @@ -815,8 +815,8 @@ { "regionRank": 6, "wcaId": "2010BENT01", - "name": "Jan Bentlage", - "countryIso2": "DE", + "name": "2010BENT01", + "countryIso2": "Germany", "overall": 9967, "events": [ { @@ -977,8 +977,8 @@ { "regionRank": 7, "wcaId": "2016CETR01", - "name": "Joel Cetra", - "countryIso2": "DE", + "name": "2016CETR01", + "countryIso2": "Germany", "overall": 11470, "events": [ { @@ -1139,8 +1139,8 @@ { "regionRank": 8, "wcaId": "2013BOTZ01", - "name": "Alexander Botz", - "countryIso2": "DE", + "name": "2013BOTZ01", + "countryIso2": "Germany", "overall": 11710, "events": [ { @@ -1301,8 +1301,8 @@ { "regionRank": 9, "wcaId": "2016IHLE01", - "name": "Malte Ihlefeld", - "countryIso2": "DE", + "name": "2016IHLE01", + "countryIso2": "Germany", "overall": 11859, "events": [ { @@ -1463,8 +1463,8 @@ { "regionRank": 10, "wcaId": "2017MAND13", - "name": "Francisco Moraes Mandalozzo", - "countryIso2": "BR", + "name": "2017MAND13 Mandalozzo", + "countryIso2": "Brazil", "overall": 12063, "events": [ { diff --git a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_1.json b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_1.json index 748f50de..76062b53 100644 --- a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_1.json +++ b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_1.json @@ -5,8 +5,8 @@ { "regionRank": 7, "wcaId": "2016CETR01", - "name": "Joel Cetra", - "countryIso2": "DE", + "name": "2016CETR01", + "countryIso2": "Germany", "overall": 11470, "events": [ { @@ -167,8 +167,8 @@ { "regionRank": 8, "wcaId": "2013BOTZ01", - "name": "Alexander Botz", - "countryIso2": "DE", + "name": "2013BOTZ01", + "countryIso2": "Germany", "overall": 11710, "events": [ { @@ -329,8 +329,8 @@ { "regionRank": 9, "wcaId": "2016IHLE01", - "name": "Malte Ihlefeld", - "countryIso2": "DE", + "name": "2016IHLE01", + "countryIso2": "Germany", "overall": 11859, "events": [ { @@ -491,8 +491,8 @@ { "regionRank": 10, "wcaId": "2017MAND13", - "name": "Francisco Moraes Mandalozzo", - "countryIso2": "BR", + "name": "2017MAND13 Mandalozzo", + "countryIso2": "Brazil", "overall": 12063, "events": [ { @@ -653,8 +653,8 @@ { "regionRank": 11, "wcaId": "2012WESC01", - "name": "Lucas Wesche", - "countryIso2": "DE", + "name": "2012WESC01", + "countryIso2": "Germany", "overall": 12268, "events": [ { @@ -815,8 +815,8 @@ { "regionRank": 12, "wcaId": "2015KOEN01", - "name": "Christian König", - "countryIso2": "DE", + "name": "2015KOEN01", + "countryIso2": "Germany", "overall": 13372, "events": [ { diff --git a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_3.json b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_3.json index d81f4924..6fd33df1 100644 --- a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_3.json +++ b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_3.json @@ -5,8 +5,8 @@ { "regionRank": 31, "wcaId": "2017SOUZ10", - "name": "Gabriel Lincon Souza", - "countryIso2": "BR", + "name": "2017SOUZ10 Souza", + "countryIso2": "Brazil", "overall": 44247, "events": [ { @@ -167,8 +167,8 @@ { "regionRank": 32, "wcaId": "2011LIMA02", - "name": "Bruno Fonsêca Coelho Lima", - "countryIso2": "BR", + "name": "2011LIMA02 Coelho Lima", + "countryIso2": "Brazil", "overall": 45708, "events": [ { @@ -329,8 +329,8 @@ { "regionRank": 33, "wcaId": "2011LIMA01", - "name": "Allyson Dias de Lima", - "countryIso2": "BR", + "name": "2011LIMA01 de Lima", + "countryIso2": "Brazil", "overall": 47807, "events": [ { diff --git a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_4.json b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_4.json deleted file mode 100644 index 68e56268..00000000 --- a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_4.json +++ /dev/null @@ -1,465 +0,0 @@ -{ - "page": 4, - "pageSize": 3, - "content": [ - { - "regionRank": 13, - "wcaId": "2017SOUZ10", - "name": "Gabriel Lincon Souza", - "countryIso2": "BR", - "overall": 2242, - "events": [ - { - "event": { - "id": "333", - "name": "3x3x3 Cube", - "rank": 10 - }, - "regionalRank": 255, - "completed": true - }, - { - "event": { - "id": "222", - "name": "2x2x2 Cube", - "rank": 20 - }, - "regionalRank": 455, - "completed": true - }, - { - "event": { - "id": "444", - "name": "4x4x4 Cube", - "rank": 30 - }, - "regionalRank": 157, - "completed": true - }, - { - "event": { - "id": "555", - "name": "5x5x5 Cube", - "rank": 40 - }, - "regionalRank": 128, - "completed": true - }, - { - "event": { - "id": "666", - "name": "6x6x6 Cube", - "rank": 50 - }, - "regionalRank": 93, - "completed": true - }, - { - "event": { - "id": "777", - "name": "7x7x7 Cube", - "rank": 60 - }, - "regionalRank": 148, - "completed": true - }, - { - "event": { - "id": "333bf", - "name": "3x3x3 Blindfolded", - "rank": 70 - }, - "regionalRank": 137, - "completed": true - }, - { - "event": { - "id": "333fm", - "name": "3x3x3 Fewest Moves", - "rank": 80 - }, - "regionalRank": 190, - "completed": false - }, - { - "event": { - "id": "333oh", - "name": "3x3x3 One-Handed", - "rank": 90 - }, - "regionalRank": 45, - "completed": true - }, - { - "event": { - "id": "clock", - "name": "Clock", - "rank": 110 - }, - "regionalRank": 9, - "completed": true - }, - { - "event": { - "id": "minx", - "name": "Megaminx", - "rank": 120 - }, - "regionalRank": 191, - "completed": true - }, - { - "event": { - "id": "pyram", - "name": "Pyraminx", - "rank": 130 - }, - "regionalRank": 354, - "completed": true - }, - { - "event": { - "id": "skewb", - "name": "Skewb", - "rank": 140 - }, - "regionalRank": 61, - "completed": true - }, - { - "event": { - "id": "sq1", - "name": "Square-1", - "rank": 150 - }, - "regionalRank": 17, - "completed": true - }, - { - "event": { - "id": "444bf", - "name": "4x4x4 Blindfolded", - "rank": 160 - }, - "regionalRank": 1, - "completed": false - }, - { - "event": { - "id": "555bf", - "name": "5x5x5 Blindfolded", - "rank": 170 - }, - "regionalRank": 1, - "completed": false - } - ] - }, - { - "regionRank": 14, - "wcaId": "2019MIYA05", - "name": "Pedro Lobeto Miyamoto", - "countryIso2": "BR", - "overall": 2292, - "events": [ - { - "event": { - "id": "333", - "name": "3x3x3 Cube", - "rank": 10 - }, - "regionalRank": 223, - "completed": true - }, - { - "event": { - "id": "222", - "name": "2x2x2 Cube", - "rank": 20 - }, - "regionalRank": 42, - "completed": true - }, - { - "event": { - "id": "444", - "name": "4x4x4 Cube", - "rank": 30 - }, - "regionalRank": 364, - "completed": true - }, - { - "event": { - "id": "555", - "name": "5x5x5 Cube", - "rank": 40 - }, - "regionalRank": 175, - "completed": true - }, - { - "event": { - "id": "666", - "name": "6x6x6 Cube", - "rank": 50 - }, - "regionalRank": 353, - "completed": false - }, - { - "event": { - "id": "777", - "name": "7x7x7 Cube", - "rank": 60 - }, - "regionalRank": 285, - "completed": false - }, - { - "event": { - "id": "333bf", - "name": "3x3x3 Blindfolded", - "rank": 70 - }, - "regionalRank": 40, - "completed": true - }, - { - "event": { - "id": "333fm", - "name": "3x3x3 Fewest Moves", - "rank": 80 - }, - "regionalRank": 165, - "completed": true - }, - { - "event": { - "id": "333oh", - "name": "3x3x3 One-Handed", - "rank": 90 - }, - "regionalRank": 208, - "completed": true - }, - { - "event": { - "id": "clock", - "name": "Clock", - "rank": 110 - }, - "regionalRank": 18, - "completed": true - }, - { - "event": { - "id": "minx", - "name": "Megaminx", - "rank": 120 - }, - "regionalRank": 125, - "completed": true - }, - { - "event": { - "id": "pyram", - "name": "Pyraminx", - "rank": 130 - }, - "regionalRank": 73, - "completed": true - }, - { - "event": { - "id": "skewb", - "name": "Skewb", - "rank": 140 - }, - "regionalRank": 162, - "completed": true - }, - { - "event": { - "id": "sq1", - "name": "Square-1", - "rank": 150 - }, - "regionalRank": 57, - "completed": true - }, - { - "event": { - "id": "444bf", - "name": "4x4x4 Blindfolded", - "rank": 160 - }, - "regionalRank": 1, - "completed": false - }, - { - "event": { - "id": "555bf", - "name": "5x5x5 Blindfolded", - "rank": 170 - }, - "regionalRank": 1, - "completed": false - } - ] - }, - { - "regionRank": 15, - "wcaId": "2011LIMA02", - "name": "Bruno Fonsêca Coelho Lima", - "countryIso2": "BR", - "overall": 2518, - "events": [ - { - "event": { - "id": "333", - "name": "3x3x3 Cube", - "rank": 10 - }, - "regionalRank": 234, - "completed": true - }, - { - "event": { - "id": "222", - "name": "2x2x2 Cube", - "rank": 20 - }, - "regionalRank": 120, - "completed": true - }, - { - "event": { - "id": "444", - "name": "4x4x4 Cube", - "rank": 30 - }, - "regionalRank": 179, - "completed": true - }, - { - "event": { - "id": "555", - "name": "5x5x5 Cube", - "rank": 40 - }, - "regionalRank": 237, - "completed": true - }, - { - "event": { - "id": "666", - "name": "6x6x6 Cube", - "rank": 50 - }, - "regionalRank": 198, - "completed": true - }, - { - "event": { - "id": "777", - "name": "7x7x7 Cube", - "rank": 60 - }, - "regionalRank": 206, - "completed": true - }, - { - "event": { - "id": "333bf", - "name": "3x3x3 Blindfolded", - "rank": 70 - }, - "regionalRank": 138, - "completed": false - }, - { - "event": { - "id": "333fm", - "name": "3x3x3 Fewest Moves", - "rank": 80 - }, - "regionalRank": 10, - "completed": true - }, - { - "event": { - "id": "333oh", - "name": "3x3x3 One-Handed", - "rank": 90 - }, - "regionalRank": 382, - "completed": true - }, - { - "event": { - "id": "clock", - "name": "Clock", - "rank": 110 - }, - "regionalRank": 136, - "completed": true - }, - { - "event": { - "id": "minx", - "name": "Megaminx", - "rank": 120 - }, - "regionalRank": 219, - "completed": true - }, - { - "event": { - "id": "pyram", - "name": "Pyraminx", - "rank": 130 - }, - "regionalRank": 135, - "completed": true - }, - { - "event": { - "id": "skewb", - "name": "Skewb", - "rank": 140 - }, - "regionalRank": 271, - "completed": true - }, - { - "event": { - "id": "sq1", - "name": "Square-1", - "rank": 150 - }, - "regionalRank": 51, - "completed": true - }, - { - "event": { - "id": "444bf", - "name": "4x4x4 Blindfolded", - "rank": 160 - }, - "regionalRank": 1, - "completed": false - }, - { - "event": { - "id": "555bf", - "name": "5x5x5 Blindfolded", - "rank": 170 - }, - "regionalRank": 1, - "completed": false - } - ] - } - ] -} \ No newline at end of file diff --git a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_5.json b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_5.json deleted file mode 100644 index d331827f..00000000 --- a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_5.json +++ /dev/null @@ -1,465 +0,0 @@ -{ - "page": 4, - "pageSize": 3, - "content": [ - { - "regionRank": 13, - "wcaId": "2011LIMA02", - "name": "Bruno Fonsêca Coelho Lima", - "countryIso2": "BR", - "overall": 566, - "events": [ - { - "event": { - "id": "333", - "name": "3x3x3 Cube", - "rank": 10 - }, - "regionalRank": 55, - "completed": true - }, - { - "event": { - "id": "222", - "name": "2x2x2 Cube", - "rank": 20 - }, - "regionalRank": 26, - "completed": true - }, - { - "event": { - "id": "444", - "name": "4x4x4 Cube", - "rank": 30 - }, - "regionalRank": 33, - "completed": true - }, - { - "event": { - "id": "555", - "name": "5x5x5 Cube", - "rank": 40 - }, - "regionalRank": 48, - "completed": true - }, - { - "event": { - "id": "666", - "name": "6x6x6 Cube", - "rank": 50 - }, - "regionalRank": 35, - "completed": true - }, - { - "event": { - "id": "777", - "name": "7x7x7 Cube", - "rank": 60 - }, - "regionalRank": 42, - "completed": true - }, - { - "event": { - "id": "333bf", - "name": "3x3x3 Blindfolded", - "rank": 70 - }, - "regionalRank": 57, - "completed": false - }, - { - "event": { - "id": "333fm", - "name": "3x3x3 Fewest Moves", - "rank": 80 - }, - "regionalRank": 9, - "completed": true - }, - { - "event": { - "id": "333oh", - "name": "3x3x3 One-Handed", - "rank": 90 - }, - "regionalRank": 89, - "completed": true - }, - { - "event": { - "id": "clock", - "name": "Clock", - "rank": 110 - }, - "regionalRank": 43, - "completed": true - }, - { - "event": { - "id": "minx", - "name": "Megaminx", - "rank": 120 - }, - "regionalRank": 39, - "completed": true - }, - { - "event": { - "id": "pyram", - "name": "Pyraminx", - "rank": 130 - }, - "regionalRank": 35, - "completed": true - }, - { - "event": { - "id": "skewb", - "name": "Skewb", - "rank": 140 - }, - "regionalRank": 41, - "completed": true - }, - { - "event": { - "id": "sq1", - "name": "Square-1", - "rank": 150 - }, - "regionalRank": 12, - "completed": true - }, - { - "event": { - "id": "444bf", - "name": "4x4x4 Blindfolded", - "rank": 160 - }, - "regionalRank": 1, - "completed": false - }, - { - "event": { - "id": "555bf", - "name": "5x5x5 Blindfolded", - "rank": 170 - }, - "regionalRank": 1, - "completed": false - } - ] - }, - { - "regionRank": 14, - "wcaId": "2017SOUZ10", - "name": "Gabriel Lincon Souza", - "countryIso2": "BR", - "overall": 567, - "events": [ - { - "event": { - "id": "333", - "name": "3x3x3 Cube", - "rank": 10 - }, - "regionalRank": 59, - "completed": true - }, - { - "event": { - "id": "222", - "name": "2x2x2 Cube", - "rank": 20 - }, - "regionalRank": 95, - "completed": true - }, - { - "event": { - "id": "444", - "name": "4x4x4 Cube", - "rank": 30 - }, - "regionalRank": 30, - "completed": true - }, - { - "event": { - "id": "555", - "name": "5x5x5 Cube", - "rank": 40 - }, - "regionalRank": 24, - "completed": true - }, - { - "event": { - "id": "666", - "name": "6x6x6 Cube", - "rank": 50 - }, - "regionalRank": 17, - "completed": true - }, - { - "event": { - "id": "777", - "name": "7x7x7 Cube", - "rank": 60 - }, - "regionalRank": 27, - "completed": true - }, - { - "event": { - "id": "333bf", - "name": "3x3x3 Blindfolded", - "rank": 70 - }, - "regionalRank": 56, - "completed": true - }, - { - "event": { - "id": "333fm", - "name": "3x3x3 Fewest Moves", - "rank": 80 - }, - "regionalRank": 104, - "completed": false - }, - { - "event": { - "id": "333oh", - "name": "3x3x3 One-Handed", - "rank": 90 - }, - "regionalRank": 14, - "completed": true - }, - { - "event": { - "id": "clock", - "name": "Clock", - "rank": 110 - }, - "regionalRank": 3, - "completed": true - }, - { - "event": { - "id": "minx", - "name": "Megaminx", - "rank": 120 - }, - "regionalRank": 36, - "completed": true - }, - { - "event": { - "id": "pyram", - "name": "Pyraminx", - "rank": 130 - }, - "regionalRank": 82, - "completed": true - }, - { - "event": { - "id": "skewb", - "name": "Skewb", - "rank": 140 - }, - "regionalRank": 13, - "completed": true - }, - { - "event": { - "id": "sq1", - "name": "Square-1", - "rank": 150 - }, - "regionalRank": 5, - "completed": true - }, - { - "event": { - "id": "444bf", - "name": "4x4x4 Blindfolded", - "rank": 160 - }, - "regionalRank": 1, - "completed": false - }, - { - "event": { - "id": "555bf", - "name": "5x5x5 Blindfolded", - "rank": 170 - }, - "regionalRank": 1, - "completed": false - } - ] - }, - { - "regionRank": 15, - "wcaId": "2017BORG02", - "name": "Gabriel Bergue", - "countryIso2": "BR", - "overall": 571, - "events": [ - { - "event": { - "id": "333", - "name": "3x3x3 Cube", - "rank": 10 - }, - "regionalRank": 54, - "completed": true - }, - { - "event": { - "id": "222", - "name": "2x2x2 Cube", - "rank": 20 - }, - "regionalRank": 56, - "completed": true - }, - { - "event": { - "id": "444", - "name": "4x4x4 Cube", - "rank": 30 - }, - "regionalRank": 53, - "completed": true - }, - { - "event": { - "id": "555", - "name": "5x5x5 Cube", - "rank": 40 - }, - "regionalRank": 31, - "completed": true - }, - { - "event": { - "id": "666", - "name": "6x6x6 Cube", - "rank": 50 - }, - "regionalRank": 7, - "completed": true - }, - { - "event": { - "id": "777", - "name": "7x7x7 Cube", - "rank": 60 - }, - "regionalRank": 8, - "completed": true - }, - { - "event": { - "id": "333bf", - "name": "3x3x3 Blindfolded", - "rank": 70 - }, - "regionalRank": 57, - "completed": false - }, - { - "event": { - "id": "333fm", - "name": "3x3x3 Fewest Moves", - "rank": 80 - }, - "regionalRank": 44, - "completed": true - }, - { - "event": { - "id": "333oh", - "name": "3x3x3 One-Handed", - "rank": 90 - }, - "regionalRank": 33, - "completed": true - }, - { - "event": { - "id": "clock", - "name": "Clock", - "rank": 110 - }, - "regionalRank": 26, - "completed": true - }, - { - "event": { - "id": "minx", - "name": "Megaminx", - "rank": 120 - }, - "regionalRank": 26, - "completed": true - }, - { - "event": { - "id": "pyram", - "name": "Pyraminx", - "rank": 130 - }, - "regionalRank": 42, - "completed": true - }, - { - "event": { - "id": "skewb", - "name": "Skewb", - "rank": 140 - }, - "regionalRank": 12, - "completed": true - }, - { - "event": { - "id": "sq1", - "name": "Square-1", - "rank": 150 - }, - "regionalRank": 120, - "completed": true - }, - { - "event": { - "id": "444bf", - "name": "4x4x4 Blindfolded", - "rank": 160 - }, - "regionalRank": 1, - "completed": false - }, - { - "event": { - "id": "555bf", - "name": "5x5x5 Blindfolded", - "rank": 170 - }, - "regionalRank": 1, - "completed": false - } - ] - } - ] -} \ No newline at end of file diff --git a/server/src/test/resources/test-scripts/SumOfRanksControllerIT.sql b/server/src/test/resources/test-scripts/SumOfRanksControllerIT.sql index 0b993e56..95b67cdf 100644 --- a/server/src/test/resources/test-scripts/SumOfRanksControllerIT.sql +++ b/server/src/test/resources/test-scripts/SumOfRanksControllerIT.sql @@ -1,10 +1,53 @@ -- Continent -INSERT INTO wca_development.continents (id, name, record_name, latitude, longitude, zoom) VALUES('_Europe', 'Europe', 'ER', 58299984, 23049300, 3); -INSERT INTO wca_development.continents (id, name, record_name, latitude, longitude, zoom) VALUES('_South America', 'South America', 'SAR', -21735104, -63281250, 3); +INSERT INTO continents (id, name, record_name, latitude, longitude, zoom) VALUES('_Africa', 'Africa', 'AfR', 213671, 16984850, 3); +INSERT INTO continents (id, name, record_name, latitude, longitude, zoom) VALUES('_Asia', 'Asia', 'AsR', 34364439, 108330700, 2); +INSERT INTO continents (id, name, record_name, latitude, longitude, zoom) VALUES('_Europe', 'Europe', 'ER', 58299984, 23049300, 3); +INSERT INTO continents (id, name, record_name, latitude, longitude, zoom) VALUES('_Multiple Continents', 'Multiple Continents', '', 0, 0, 1); +INSERT INTO continents (id, name, record_name, latitude, longitude, zoom) VALUES('_North America', 'North America', 'NAR', 45486546, -93449700, 3); +INSERT INTO continents (id, name, record_name, latitude, longitude, zoom) VALUES('_Oceania', 'Oceania', 'OcR', -25274398, 133775136, 3); +INSERT INTO continents (id, name, record_name, latitude, longitude, zoom) VALUES('_South America', 'South America', 'SAR', -21735104, -63281250, 3); -- Countries -INSERT INTO wca_development.countries (id, name, continent_id, iso2) VALUES('Brazil', 'Brazil', '_South America', 'BR'); -INSERT INTO wca_development.countries (id, name, continent_id, iso2) VALUES('Germany', 'Germany', '_Europe', 'DE'); +INSERT INTO countries (id, name, continent_id, iso2) VALUES('Brazil', 'Brazil', '_South America', 'BR'); +INSERT INTO countries (id, name, continent_id, iso2) VALUES('Germany', 'Germany', '_Europe', 'DE'); + +-- Persons +INSERT INTO persons (wca_id,sub_id,name,country_id,gender,dob,comments,incorrect_wca_id_claim_count) VALUES + ('2010BENT01',1,'2010BENT01','Germany','m','1954-12-04','',0), + ('2010KILD02',1,'2010KILD02','Germany','m','1954-12-04','',0), + ('2011FRES01',1,'2011FRES01','Germany','m','1954-12-04','',0), + ('2011LIMA01',1,'2011LIMA01 de Lima','Brazil','m','1954-12-04','',0), + ('2011LIMA02',1,'2011LIMA02 Coelho Lima','Brazil','m','1954-12-04','',0), + ('2011RHEI01',1,'2011RHEI01','Germany','m','1954-12-04','',0), + ('2012ROQU01',1,'2012ROQU01','Brazil','m','1954-12-04','',0), + ('2012WESC01',1,'2012WESC01','Germany','m','1954-12-04','',0), + ('2013BOTZ01',1,'2013BOTZ01','Germany','m','1954-12-04','',0), + ('2013GERH01',1,'2013GERH01','Germany','m','1954-12-04','',0), + ('2014FRIT02',1,'2014FRIT02','Germany','m','1954-12-04','',0), + ('2014GERB01',1,'2014GERB01','Germany','m','1954-12-04','',0), + ('2014TONO01',1,'2014TONO01 Tono','Brazil','m','1954-12-04','',0), + ('2014YUNO01',1,'2014YUNO01 Yunomae','Brazil','m','1954-12-04','',0), + ('2015CECC01',1,'2015CECC01 Cecchini','Brazil','m','1954-12-04','',0), + ('2015KOEN01',1,'2015KOEN01','Germany','m','1954-12-04','',0), + ('2015MATT05',1,'2015MATT05','Brazil','m','1954-12-04','',0), + ('2015ONOF01',1,'2015ONOF01 Abib Onofre','Brazil','m','1954-12-04','',0), + ('2015SILV55',1,'2015SILV55 Freitas da Silva','Brazil','m','1954-12-04','',0), + ('2016CETR01',1,'2016CETR01','Germany','m','1954-12-04','',0), + ('2016HOLZ01',1,'2016HOLZ01','Germany','f','1954-12-04','',0), + ('2016IHLE01',1,'2016IHLE01','Germany','m','1954-12-04','',0), + ('2016KRAF01',1,'2016KRAF01','Germany','m','1954-12-04','',0), + ('2016SANT66',1,'2016SANT66 de A. Santos','Brazil','m','1954-12-04','',0), + ('2016SATO01',1,'2016SATO01 Sato','Brazil','m','1954-12-04','',0), + ('2016TANN01',1,'2016TANN01 M. Tannenbaum','Brazil','f','1954-12-04','',0), + ('2016WETZ01',1,'2016WETZ01','Germany','m','1954-12-04','',0), + ('2017BORG02',1,'2017BORG02','Brazil','m','1954-12-04','',0), + ('2017MAND13',1,'2017MAND13 Mandalozzo','Brazil','m','1954-12-04','',0), + ('2017SOUZ10',1,'2017SOUZ10 Souza','Brazil','m','1954-12-04','',0), + ('2018GOME29',1,'2018GOME29 Gomes','Brazil','m','1954-12-04','',0), + ('2018MACH13',1,'2018MACH13','Germany','m','1954-12-04','',0), + ('2019FUJI09',1,'2019FUJI09 Fujita','Brazil','m','1954-12-04','',0), + ('2019MIYA05',1,'2019MIYA05 Miyamoto','Brazil','m','1954-12-04','',0); + -- Ranks single INSERT INTO wca_development.ranks_single (id, person_id, event_id, best, world_rank, continent_rank, country_rank) VALUES(526727877, '2013GERH01', '222', 66, 32, 15, 1); diff --git a/server/src/test/resources/test-scripts/cleanTestData.sql b/server/src/test/resources/test-scripts/cleanTestData.sql index 4e18f985..62248738 100644 --- a/server/src/test/resources/test-scripts/cleanTestData.sql +++ b/server/src/test/resources/test-scripts/cleanTestData.sql @@ -8,6 +8,8 @@ truncate wca_development.competition_events; truncate wca_development.results; +truncate wca_development.persons; + truncate wca_development.continents; truncate wca_development.countries; From 92ae3aa95042dacbd23116451f351f302aa4b4f1 Mon Sep 17 00:00:00 2001 From: Alexandre Henrique Afonso Campos Date: Sun, 10 Aug 2025 08:02:34 -0300 Subject: [PATCH 2/5] Consider sub ids --- .../query/sumofranks/continentAverageInsert.sql | 15 ++++++++------- .../db/query/sumofranks/continentSingleInsert.sql | 14 +++++++------- .../db/query/sumofranks/countryAverageInsert.sql | 15 ++++++++------- .../db/query/sumofranks/countrySingleInsert.sql | 1 + 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/server/src/main/resources/db/query/sumofranks/continentAverageInsert.sql b/server/src/main/resources/db/query/sumofranks/continentAverageInsert.sql index ba722d97..5a639cde 100644 --- a/server/src/main/resources/db/query/sumofranks/continentAverageInsert.sql +++ b/server/src/main/resources/db/query/sumofranks/continentAverageInsert.sql @@ -17,8 +17,8 @@ insert into coalesce(max(continent_rank), 0) from ranks_average r - inner join users u on u.wca_id = r.person_id - inner join countries c on c.iso2 = u.country_iso2 + inner join users u on p.wca_id = r.person_id + inner join countries c on c.iso2 = p.country_id where c.continent_id = c2.id and r.event_id = e.id @@ -37,14 +37,14 @@ select countries c left join continents c2 on c.continent_id = c2.id where - u.country_iso2 = c.iso2 + p.country_is = c.iso2 ) region, ( select 'Continent' ) region_type, wca_id, - u.name, + p.name, country_iso2, ( select @@ -74,15 +74,16 @@ select ) events from events e - left join users u on e.`rank` < 900 -- Filter by active ranks + left join persons p on e.`rank` < 900 -- Filter by active ranks left join ranks_average r on r.event_id = e.id - and r.person_id = u.wca_id - left join countries c on c.iso2 = u.country_iso2 + and r.person_id = p.wca_id + left join countries c on c.iso2 = p.country_is left join continents c2 on c.continent_id = c2.id left join default_ranks dr on dr.event_id = e.id and dr.region = c2.name where wca_id is not null + and sub_id = 1 and exists ( -- Some events has no averages and this excludes them to avoid adding 1 into the sum select diff --git a/server/src/main/resources/db/query/sumofranks/continentSingleInsert.sql b/server/src/main/resources/db/query/sumofranks/continentSingleInsert.sql index 1bd87b83..db92f55a 100644 --- a/server/src/main/resources/db/query/sumofranks/continentSingleInsert.sql +++ b/server/src/main/resources/db/query/sumofranks/continentSingleInsert.sql @@ -17,8 +17,7 @@ insert into coalesce(max(continent_rank), 0) from ranks_single r - inner join users u on u.wca_id = r.person_id - inner join countries c on c.iso2 = u.country_iso2 + inner join countries c on c.iso2 = p.country_id where c.continent_id = c2.id and r.event_id = e.id @@ -37,14 +36,14 @@ select countries c left join continents c2 on c.continent_id = c2.id where - u.country_iso2 = c.iso2 + p.countr_id = c.iso2 ) region, ( select 'Continent' ) region_type, wca_id, - u.name, + p.name, country_iso2, ( select @@ -74,14 +73,15 @@ select ) events from events e - left join users u on e.`rank` < 900 -- Filter by active ranks + left join persons p on e.`rank` < 900 -- Filter by active ranks left join ranks_single r on r.event_id = e.id - and r.person_id = u.wca_id - left join countries c on c.iso2 = u.country_iso2 + and r.person_id = p.wca_id + left join countries c on c.iso2 = p.country_id left join continents c2 on c.continent_id = c2.id left join default_ranks dr on dr.event_id = e.id and dr.region = c2.name where wca_id is not null + and sub_id = 1 group by wca_id \ No newline at end of file diff --git a/server/src/main/resources/db/query/sumofranks/countryAverageInsert.sql b/server/src/main/resources/db/query/sumofranks/countryAverageInsert.sql index a63f53e2..19bccdf4 100644 --- a/server/src/main/resources/db/query/sumofranks/countryAverageInsert.sql +++ b/server/src/main/resources/db/query/sumofranks/countryAverageInsert.sql @@ -17,10 +17,10 @@ insert into coalesce(max(country_rank), 0) from ranks_average r - inner join users u on u.wca_id = r.person_id + inner join users u on p.wca_id = r.person_id where r.event_id = e.id - and u.country_iso2 = c2.iso2 + and p.country_id = c2.iso2 ) + 1 default_rank from events e, @@ -35,14 +35,14 @@ select from countries c where - u.country_iso2 = c.iso2 + p.country_id = c.iso2 ) region, ( select 'Country' ) region_type, wca_id, - u.name, + p.name, country_iso2, ( select @@ -72,14 +72,15 @@ select ) events from events e - left join users u on e.`rank` < 900 -- Filter by active ranks + left join persons p on e.`rank` < 900 -- Filter by active ranks left join ranks_average r on r.event_id = e.id - and r.person_id = u.wca_id - left join countries c on c.iso2 = u.country_iso2 + and r.person_id = p.wca_id + left join countries c on c.iso2 = p.country_id left join default_ranks dr on dr.event_id = e.id and dr.region = c.iso2 where wca_id is not null + and sub_id = 1 and exists ( -- Some events has no averages and this excludes them to avoid adding 1 into the sum select diff --git a/server/src/main/resources/db/query/sumofranks/countrySingleInsert.sql b/server/src/main/resources/db/query/sumofranks/countrySingleInsert.sql index 508ea89a..28fe8c6b 100644 --- a/server/src/main/resources/db/query/sumofranks/countrySingleInsert.sql +++ b/server/src/main/resources/db/query/sumofranks/countrySingleInsert.sql @@ -80,6 +80,7 @@ from and dr.region = c.id where wca_id is not null + and sub_id = 1 group by wca_id, country_id, From fc48c23db73e96e0df8f6c04b92f991af647490e Mon Sep 17 00:00:00 2001 From: Alexandre Henrique Afonso Campos Date: Sun, 10 Aug 2025 17:52:48 -0300 Subject: [PATCH 3/5] Update test schema tables --- server/db/migration/V1__tables.sql | 161 ++++++++++++++++++++++------- 1 file changed, 122 insertions(+), 39 deletions(-) diff --git a/server/db/migration/V1__tables.sql b/server/db/migration/V1__tables.sql index acd6d52a..2f423e8d 100644 --- a/server/db/migration/V1__tables.sql +++ b/server/db/migration/V1__tables.sql @@ -1,7 +1,6 @@ /*M!999999\- enable the sandbox mode */ -- MariaDB dump 10.19-11.7.2-MariaDB, for osx10.20 (arm64) -- --- Host: localhost Database: wca_development -- ------------------------------------------------------ -- Server version 8.0.33 @@ -392,7 +391,7 @@ CREATE TABLE `assignments` ( PRIMARY KEY (`id`), KEY `index_assignments_on_registration_id_and_registration_type` (`registration_id`,`registration_type`), KEY `index_assignments_on_schedule_activity_id` (`schedule_activity_id`) -) ENGINE=InnoDB AUTO_INCREMENT=72549755 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=79843055 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -424,7 +423,7 @@ CREATE TABLE `bookmarked_competitions` ( PRIMARY KEY (`id`), KEY `index_bookmarked_competitions_on_competition_id` (`competition_id`), KEY `index_bookmarked_competitions_on_user_id` (`user_id`) -) ENGINE=InnoDB AUTO_INCREMENT=302079 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=312951 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -457,7 +456,7 @@ CREATE TABLE `championships` ( PRIMARY KEY (`id`), UNIQUE KEY `index_championships_on_competition_id_and_championship_type` (`competition_id`,`championship_type`), KEY `index_championships_on_championship_type` (`championship_type`) -) ENGINE=InnoDB AUTO_INCREMENT=908 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=935 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -478,7 +477,7 @@ CREATE TABLE `competition_delegates` ( UNIQUE KEY `index_competition_delegates_on_competition_id_and_delegate_id` (`competition_id`,`delegate_id`), KEY `index_competition_delegates_on_competition_id` (`competition_id`), KEY `index_competition_delegates_on_delegate_id` (`delegate_id`) -) ENGINE=InnoDB AUTO_INCREMENT=43834 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=45102 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -497,7 +496,7 @@ CREATE TABLE `competition_events` ( PRIMARY KEY (`id`), UNIQUE KEY `index_competition_events_on_competition_id_and_event_id` (`competition_id`,`event_id`), KEY `fk_rails_ba6cfdafb1` (`event_id`) -) ENGINE=InnoDB AUTO_INCREMENT=145730 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=148201 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -541,7 +540,7 @@ CREATE TABLE `competition_organizers` ( UNIQUE KEY `idx_competition_organizers_on_competition_id_and_organizer_id` (`competition_id`,`organizer_id`), KEY `index_competition_organizers_on_competition_id` (`competition_id`), KEY `index_competition_organizers_on_organizer_id` (`organizer_id`) -) ENGINE=InnoDB AUTO_INCREMENT=43257 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=44417 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -579,7 +578,7 @@ CREATE TABLE `competition_series` ( `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=354 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=370 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -598,7 +597,7 @@ CREATE TABLE `competition_tabs` ( PRIMARY KEY (`id`), UNIQUE KEY `index_competition_tabs_on_display_order_and_competition_id` (`display_order`,`competition_id`), KEY `index_competition_tabs_on_competition_id` (`competition_id`) -) ENGINE=InnoDB AUTO_INCREMENT=61555 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=63307 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -622,7 +621,7 @@ CREATE TABLE `competition_venues` ( PRIMARY KEY (`id`), UNIQUE KEY `index_competition_venues_on_competition_id_and_wcif_id` (`competition_id`,`wcif_id`), KEY `index_competition_venues_on_competition_id` (`competition_id`) -) ENGINE=InnoDB AUTO_INCREMENT=12166 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=12531 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -707,6 +706,7 @@ CREATE TABLE `competitions` ( `auto_close_threshold` int DEFAULT NULL, `auto_accept_registrations` tinyint(1) NOT NULL DEFAULT '0', `auto_accept_disable_threshold` int DEFAULT NULL, + `auto_accept_preference` int NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `index_competitions_on_cancelled_at` (`cancelled_at`), KEY `index_Competitions_on_countryId` (`country_id`), @@ -921,7 +921,27 @@ CREATE TABLE `delegate_reports` ( `reminder_sent_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_delegate_reports_on_competition_id` (`competition_id`) -) ENGINE=InnoDB AUTO_INCREMENT=17858 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=18176 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `duplicate_checker_job_runs` +-- + +DROP TABLE IF EXISTS `duplicate_checker_job_runs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `duplicate_checker_job_runs` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `competition_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `start_time` datetime(6) DEFAULT NULL, + `end_time` datetime(6) DEFAULT NULL, + `run_status` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` datetime(6) NOT NULL, + `updated_at` datetime(6) NOT NULL, + PRIMARY KEY (`id`), + KEY `index_duplicate_checker_job_runs_on_competition_id` (`competition_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1054,7 +1074,7 @@ CREATE TABLE `groups_metadata_translators` ( `created_at` datetime(6) NOT NULL, `updated_at` datetime(6) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=71 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1131,7 +1151,6 @@ CREATE TABLE `inbox_scramble_sets` ( `created_at` datetime(6) NOT NULL, `updated_at` datetime(6) NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `idx_on_competition_id_event_id_round_number_scrambl_d9248c75e4` (`competition_id`,`event_id`,`round_number`,`scramble_set_number`), KEY `idx_on_competition_id_event_id_round_number_063e808d5f` (`competition_id`,`event_id`,`round_number`), KEY `index_inbox_scramble_sets_on_competition_id` (`competition_id`), KEY `fk_rails_7a55abc2f3` (`event_id`), @@ -1199,7 +1218,7 @@ CREATE TABLE `incident_tags` ( UNIQUE KEY `index_incident_tags_on_incident_id_and_tag` (`incident_id`,`tag`), KEY `index_incident_tags_on_incident_id` (`incident_id`), KEY `index_incident_tags_on_tag` (`tag`) -) ENGINE=InnoDB AUTO_INCREMENT=263 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=264 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1501,7 +1520,7 @@ CREATE TABLE `persons` ( KEY `Persons_name` (`name`), KEY `index_persons_on_wca_id` (`wca_id`), FULLTEXT KEY `index_persons_on_name` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=267208 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=269777 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1555,7 +1574,7 @@ CREATE TABLE `post_tags` ( UNIQUE KEY `index_post_tags_on_post_id_and_tag` (`post_id`,`tag`), KEY `index_post_tags_on_post_id` (`post_id`), KEY `index_post_tags_on_tag` (`tag`) -) ENGINE=InnoDB AUTO_INCREMENT=22597 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=22607 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1581,7 +1600,33 @@ CREATE TABLE `posts` ( KEY `index_posts_on_world_readable_and_created_at` (`created_at`), KEY `idx_show_wr_sticky_created_at` (`show_on_homepage`,`sticky`,`created_at`), KEY `index_posts_on_world_readable_and_sticky_and_created_at` (`sticky`,`created_at`) -) ENGINE=InnoDB AUTO_INCREMENT=14205 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14211 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `potential_duplicate_persons` +-- + +DROP TABLE IF EXISTS `potential_duplicate_persons`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `potential_duplicate_persons` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `duplicate_checker_job_run_id` bigint NOT NULL, + `original_user_id` int NOT NULL, + `duplicate_person_id` int NOT NULL, + `name_matching_algorithm` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `score` int NOT NULL, + `created_at` datetime(6) NOT NULL, + `updated_at` datetime(6) NOT NULL, + PRIMARY KEY (`id`), + KEY `idx_on_duplicate_checker_job_run_id_12b05a3796` (`duplicate_checker_job_run_id`), + KEY `index_potential_duplicate_persons_on_duplicate_person_id` (`duplicate_person_id`), + KEY `index_potential_duplicate_persons_on_original_user_id` (`original_user_id`), + CONSTRAINT `fk_rails_212c95c62c` FOREIGN KEY (`duplicate_checker_job_run_id`) REFERENCES `duplicate_checker_job_runs` (`id`), + CONSTRAINT `fk_rails_7ae0e67c87` FOREIGN KEY (`duplicate_person_id`) REFERENCES `persons` (`id`), + CONSTRAINT `fk_rails_9d6e9b137a` FOREIGN KEY (`original_user_id`) REFERENCES `users` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1618,7 +1663,7 @@ CREATE TABLE `ranks_average` ( PRIMARY KEY (`id`), KEY `fk_events` (`event_id`), KEY `fk_persons` (`person_id`) -) ENGINE=InnoDB AUTO_INCREMENT=799803 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=808426 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1639,7 +1684,7 @@ CREATE TABLE `ranks_single` ( PRIMARY KEY (`id`), KEY `fk_events` (`event_id`), KEY `fk_persons` (`person_id`) -) ENGINE=InnoDB AUTO_INCREMENT=923656 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=933527 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1682,7 +1727,7 @@ CREATE TABLE `regional_organizations` ( PRIMARY KEY (`id`), KEY `index_regional_organizations_on_country` (`country`), KEY `index_regional_organizations_on_name` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=71 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=72 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1724,7 +1769,7 @@ CREATE TABLE `registration_competition_events` ( KEY `index_registration_competition_events_on_competition_event_id` (`competition_event_id`), KEY `index_reg_events_reg_id_comp_event_id` (`registration_id`,`competition_event_id`), KEY `index_registration_competition_events_on_registration_id` (`registration_id`) -) ENGINE=InnoDB AUTO_INCREMENT=6484303 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6660263 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1826,7 +1871,7 @@ CREATE TABLE `registrations` ( KEY `index_registrations_on_competition_id_and_competing_status` (`competition_id`,`competing_status`), KEY `index_registrations_on_competition_id` (`competition_id`), KEY `index_registrations_on_user_id` (`user_id`) -) ENGINE=InnoDB AUTO_INCREMENT=1172235 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1195504 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1846,7 +1891,7 @@ CREATE TABLE `result_attempts` ( PRIMARY KEY (`id`), UNIQUE KEY `index_result_attempts_on_result_id_and_attempt_number` (`result_id`,`attempt_number`), KEY `index_result_attempts_on_result_id` (`result_id`) -) ENGINE=InnoDB AUTO_INCREMENT=56021 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=83493 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1898,7 +1943,7 @@ CREATE TABLE `results` ( KEY `index_results_on_round_id` (`round_id`), KEY `Results_fk_round` (`round_type_id`), CONSTRAINT `fk_rails_8293cc5c42` FOREIGN KEY (`round_id`) REFERENCES `rounds` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=7245549 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci PACK_KEYS=1; +) ENGINE=InnoDB AUTO_INCREMENT=7368643 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci PACK_KEYS=1; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1951,7 +1996,7 @@ CREATE TABLE `roles_metadata_delegate_regions` ( `created_at` datetime(6) NOT NULL, `updated_at` datetime(6) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=1289 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1340 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1983,7 +2028,7 @@ CREATE TABLE `roles_metadata_teams_committees` ( `created_at` datetime(6) NOT NULL, `updated_at` datetime(6) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=644 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=646 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2026,7 +2071,7 @@ CREATE TABLE `rounds` ( `old_type` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_rounds_on_competition_event_id_and_number` (`competition_event_id`,`number`) -) ENGINE=InnoDB AUTO_INCREMENT=901561 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=906497 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2111,7 +2156,7 @@ CREATE TABLE `schedule_activities` ( CONSTRAINT `fk_rails_576aac0864` FOREIGN KEY (`round_id`) REFERENCES `rounds` (`id`), CONSTRAINT `fk_rails_7045722310` FOREIGN KEY (`venue_room_id`) REFERENCES `venue_rooms` (`id`), CONSTRAINT `fk_rails_999dc22d7e` FOREIGN KEY (`parent_activity_id`) REFERENCES `schedule_activities` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=770747 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=794762 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2173,7 +2218,7 @@ CREATE TABLE `scrambles` ( KEY `competitionId` (`competition_id`,`event_id`), KEY `index_scrambles_on_round_id` (`round_id`), CONSTRAINT `fk_rails_ef5833e6ef` FOREIGN KEY (`round_id`) REFERENCES `rounds` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4821678 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4915558 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2383,6 +2428,25 @@ CREATE TABLE `ticket_comments` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `ticket_log_changes` +-- + +DROP TABLE IF EXISTS `ticket_log_changes`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `ticket_log_changes` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `ticket_log_id` bigint NOT NULL, + `field_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `field_value` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` datetime(6) NOT NULL, + `updated_at` datetime(6) NOT NULL, + PRIMARY KEY (`id`), + KEY `index_ticket_log_changes_on_ticket_log_id` (`ticket_log_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `ticket_logs` -- @@ -2394,7 +2458,6 @@ CREATE TABLE `ticket_logs` ( `id` bigint NOT NULL AUTO_INCREMENT, `ticket_id` bigint NOT NULL, `action_type` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, - `action_value` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, `acting_user_id` int NOT NULL, `acting_stakeholder_id` bigint NOT NULL, `created_at` datetime(6) NOT NULL, @@ -2419,7 +2482,7 @@ CREATE TABLE `ticket_stakeholders` ( `id` bigint NOT NULL AUTO_INCREMENT, `ticket_id` bigint NOT NULL, `stakeholder_type` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, - `stakeholder_id` bigint NOT NULL, + `stakeholder_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `connection` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `is_active` tinyint(1) NOT NULL, `created_at` datetime(6) NOT NULL, @@ -2449,6 +2512,26 @@ CREATE TABLE `tickets` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `tickets_competition_result` +-- + +DROP TABLE IF EXISTS `tickets_competition_result`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `tickets_competition_result` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `status` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `competition_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `delegate_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` datetime(6) NOT NULL, + `updated_at` datetime(6) NOT NULL, + PRIMARY KEY (`id`), + KEY `index_tickets_competition_result_on_competition_id` (`competition_id`), + CONSTRAINT `fk_rails_b292c1317c` FOREIGN KEY (`competition_id`) REFERENCES `competitions` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `tickets_edit_person` -- @@ -2530,7 +2613,7 @@ CREATE TABLE `user_avatars` ( KEY `index_user_avatars_on_status` (`status`), KEY `index_user_avatars_on_user_id` (`user_id`), CONSTRAINT `fk_rails_e4b8c035c3` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=78697 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=80689 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2554,7 +2637,7 @@ CREATE TABLE `user_groups` ( PRIMARY KEY (`id`), KEY `index_user_groups_on_parent_group_id` (`parent_group_id`), CONSTRAINT `fk_rails_d1e69a9bb2` FOREIGN KEY (`parent_group_id`) REFERENCES `user_groups` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=111 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=113 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2570,7 +2653,7 @@ CREATE TABLE `user_preferred_events` ( `event_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_user_preferred_events_on_user_id_and_event_id` (`user_id`,`event_id`) -) ENGINE=InnoDB AUTO_INCREMENT=412289 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=417575 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2595,7 +2678,7 @@ CREATE TABLE `user_roles` ( KEY `index_user_roles_on_user_id` (`user_id`), CONSTRAINT `fk_rails_318345354e` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`), CONSTRAINT `fk_rails_66cd95bfa8` FOREIGN KEY (`group_id`) REFERENCES `user_groups` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2291 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2355 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2652,7 +2735,7 @@ CREATE TABLE `users` ( UNIQUE KEY `index_users_on_wca_id` (`wca_id`), KEY `index_users_on_delegate_id_to_handle_wca_id_claim` (`delegate_id_to_handle_wca_id_claim`), KEY `index_users_on_delegate_reports_region` (`delegate_reports_region_type`,`delegate_reports_region_id`) -) ENGINE=InnoDB AUTO_INCREMENT=490796 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=496845 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2673,7 +2756,7 @@ CREATE TABLE `venue_rooms` ( PRIMARY KEY (`id`), UNIQUE KEY `index_venue_rooms_on_competition_venue_id_and_wcif_id` (`competition_venue_id`,`wcif_id`), KEY `index_venue_rooms_on_competition_venue_id` (`competition_venue_id`) -) ENGINE=InnoDB AUTO_INCREMENT=15215 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15693 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2724,7 +2807,7 @@ CREATE TABLE `waiting_lists` ( `updated_at` datetime(6) NOT NULL, PRIMARY KEY (`id`), KEY `index_waiting_lists_on_holder` (`holder_type`,`holder_id`) -) ENGINE=InnoDB AUTO_INCREMENT=864 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=976 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2793,4 +2876,4 @@ CREATE TABLE `wfc_xero_users` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */; --- Dump completed on 2025-06-29 15:58:01 +-- Dump completed on 2025-08-10 17:45:27 From 788d3f8eb458da5565f3c6227749318c95959a04 Mon Sep 17 00:00:00 2001 From: Alexandre Henrique Afonso Campos Date: Sun, 10 Aug 2025 18:08:01 -0300 Subject: [PATCH 4/5] TDD to fix SOR --- .../db/query/sumofranks/continentAverageInsert.sql | 8 ++++---- .../db/query/sumofranks/continentSingleInsert.sql | 5 +++-- .../db/query/sumofranks/countryAverageInsert.sql | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/server/src/main/resources/db/query/sumofranks/continentAverageInsert.sql b/server/src/main/resources/db/query/sumofranks/continentAverageInsert.sql index 5a639cde..d035e74b 100644 --- a/server/src/main/resources/db/query/sumofranks/continentAverageInsert.sql +++ b/server/src/main/resources/db/query/sumofranks/continentAverageInsert.sql @@ -17,7 +17,7 @@ insert into coalesce(max(continent_rank), 0) from ranks_average r - inner join users u on p.wca_id = r.person_id + inner join persons p on p.wca_id = r.person_id inner join countries c on c.iso2 = p.country_id where c.continent_id = c2.id @@ -37,7 +37,7 @@ select countries c left join continents c2 on c.continent_id = c2.id where - p.country_is = c.iso2 + p.country_id = c.id ) region, ( select @@ -45,7 +45,7 @@ select ) region_type, wca_id, p.name, - country_iso2, + country_id, ( select 'Average' @@ -77,7 +77,7 @@ from left join persons p on e.`rank` < 900 -- Filter by active ranks left join ranks_average r on r.event_id = e.id and r.person_id = p.wca_id - left join countries c on c.iso2 = p.country_is + left join countries c on c.iso2 = p.country_id left join continents c2 on c.continent_id = c2.id left join default_ranks dr on dr.event_id = e.id and dr.region = c2.name diff --git a/server/src/main/resources/db/query/sumofranks/continentSingleInsert.sql b/server/src/main/resources/db/query/sumofranks/continentSingleInsert.sql index db92f55a..39fdc5eb 100644 --- a/server/src/main/resources/db/query/sumofranks/continentSingleInsert.sql +++ b/server/src/main/resources/db/query/sumofranks/continentSingleInsert.sql @@ -17,6 +17,7 @@ insert into coalesce(max(continent_rank), 0) from ranks_single r + inner join persons p on p.wca_id = r.person_id inner join countries c on c.iso2 = p.country_id where c.continent_id = c2.id @@ -36,7 +37,7 @@ select countries c left join continents c2 on c.continent_id = c2.id where - p.countr_id = c.iso2 + p.country_id = c.id ) region, ( select @@ -44,7 +45,7 @@ select ) region_type, wca_id, p.name, - country_iso2, + country_id, ( select 'Single' diff --git a/server/src/main/resources/db/query/sumofranks/countryAverageInsert.sql b/server/src/main/resources/db/query/sumofranks/countryAverageInsert.sql index 19bccdf4..4377eaa8 100644 --- a/server/src/main/resources/db/query/sumofranks/countryAverageInsert.sql +++ b/server/src/main/resources/db/query/sumofranks/countryAverageInsert.sql @@ -17,7 +17,7 @@ insert into coalesce(max(country_rank), 0) from ranks_average r - inner join users u on p.wca_id = r.person_id + inner join persons p on p.wca_id = r.person_id where r.event_id = e.id and p.country_id = c2.iso2 @@ -35,7 +35,7 @@ select from countries c where - p.country_id = c.iso2 + p.country_id = c.id ) region, ( select @@ -43,7 +43,7 @@ select ) region_type, wca_id, p.name, - country_iso2, + country_id, ( select 'Average' From 5fa10eb955ad8914e69332d7c70d43627fcba82a Mon Sep 17 00:00:00 2001 From: Alexandre Henrique Afonso Campos Date: Sun, 10 Aug 2025 18:10:49 -0300 Subject: [PATCH 5/5] Fix tests --- .../resources/db/query/sumofranks/getMeta.sql | 6 +- .../generate_0.json | 6 +- .../sum-of-ranks-controller-i-t/list_4.json | 465 ++++++++++++++++++ .../sum-of-ranks-controller-i-t/list_5.json | 465 ++++++++++++++++++ 4 files changed, 936 insertions(+), 6 deletions(-) create mode 100644 server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_4.json create mode 100644 server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_5.json diff --git a/server/src/main/resources/db/query/sumofranks/getMeta.sql b/server/src/main/resources/db/query/sumofranks/getMeta.sql index 82bf1fe5..0d6d23e3 100644 --- a/server/src/main/resources/db/query/sumofranks/getMeta.sql +++ b/server/src/main/resources/db/query/sumofranks/getMeta.sql @@ -14,7 +14,7 @@ select ) ) from - Events e + events e where e.`rank` < 900 and ( @@ -24,9 +24,9 @@ select select 1 from - RanksAverage ra + ranks_average ra where - ra.eventId = e.id + ra.event_id = e.id ) ) ) availableEvents diff --git a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/generate_0.json b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/generate_0.json index 9d7b1462..593a4915 100644 --- a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/generate_0.json +++ b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/generate_0.json @@ -1,6 +1,6 @@ { "worldRank": 68, - "continentRank": 0, - "countryRank": 34, - "meta": 4 + "continentRank": 68, + "countryRank": 68, + "meta": 10 } \ No newline at end of file diff --git a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_4.json b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_4.json new file mode 100644 index 00000000..246e3624 --- /dev/null +++ b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_4.json @@ -0,0 +1,465 @@ +{ + "page": 4, + "pageSize": 3, + "content": [ + { + "regionRank": 13, + "wcaId": "2017SOUZ10", + "name": "2017SOUZ10 Souza", + "countryIso2": "Brazil", + "overall": 2050, + "events": [ + { + "event": { + "id": "333", + "name": "3x3x3 Cube", + "rank": 10 + }, + "regionalRank": 255, + "completed": true + }, + { + "event": { + "id": "222", + "name": "2x2x2 Cube", + "rank": 20 + }, + "regionalRank": 455, + "completed": true + }, + { + "event": { + "id": "444", + "name": "4x4x4 Cube", + "rank": 30 + }, + "regionalRank": 157, + "completed": true + }, + { + "event": { + "id": "555", + "name": "5x5x5 Cube", + "rank": 40 + }, + "regionalRank": 128, + "completed": true + }, + { + "event": { + "id": "666", + "name": "6x6x6 Cube", + "rank": 50 + }, + "regionalRank": 93, + "completed": true + }, + { + "event": { + "id": "777", + "name": "7x7x7 Cube", + "rank": 60 + }, + "regionalRank": 148, + "completed": true + }, + { + "event": { + "id": "333bf", + "name": "3x3x3 Blindfolded", + "rank": 70 + }, + "regionalRank": 137, + "completed": true + }, + { + "event": { + "id": "333fm", + "name": "3x3x3 Fewest Moves", + "rank": 80 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "333oh", + "name": "3x3x3 One-Handed", + "rank": 90 + }, + "regionalRank": 45, + "completed": true + }, + { + "event": { + "id": "clock", + "name": "Clock", + "rank": 110 + }, + "regionalRank": 9, + "completed": true + }, + { + "event": { + "id": "minx", + "name": "Megaminx", + "rank": 120 + }, + "regionalRank": 191, + "completed": true + }, + { + "event": { + "id": "pyram", + "name": "Pyraminx", + "rank": 130 + }, + "regionalRank": 354, + "completed": true + }, + { + "event": { + "id": "skewb", + "name": "Skewb", + "rank": 140 + }, + "regionalRank": 61, + "completed": true + }, + { + "event": { + "id": "sq1", + "name": "Square-1", + "rank": 150 + }, + "regionalRank": 17, + "completed": true + }, + { + "event": { + "id": "444bf", + "name": "4x4x4 Blindfolded", + "rank": 160 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "555bf", + "name": "5x5x5 Blindfolded", + "rank": 170 + }, + "regionalRank": null, + "completed": false + } + ] + }, + { + "regionRank": 14, + "wcaId": "2017BORG02", + "name": "2017BORG02", + "countryIso2": "Brazil", + "overall": 2054, + "events": [ + { + "event": { + "id": "333", + "name": "3x3x3 Cube", + "rank": 10 + }, + "regionalRank": 229, + "completed": true + }, + { + "event": { + "id": "222", + "name": "2x2x2 Cube", + "rank": 20 + }, + "regionalRank": 236, + "completed": true + }, + { + "event": { + "id": "444", + "name": "4x4x4 Cube", + "rank": 30 + }, + "regionalRank": 290, + "completed": true + }, + { + "event": { + "id": "555", + "name": "5x5x5 Cube", + "rank": 40 + }, + "regionalRank": 156, + "completed": true + }, + { + "event": { + "id": "666", + "name": "6x6x6 Cube", + "rank": 50 + }, + "regionalRank": 59, + "completed": true + }, + { + "event": { + "id": "777", + "name": "7x7x7 Cube", + "rank": 60 + }, + "regionalRank": 44, + "completed": true + }, + { + "event": { + "id": "333bf", + "name": "3x3x3 Blindfolded", + "rank": 70 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "333fm", + "name": "3x3x3 Fewest Moves", + "rank": 80 + }, + "regionalRank": 78, + "completed": true + }, + { + "event": { + "id": "333oh", + "name": "3x3x3 One-Handed", + "rank": 90 + }, + "regionalRank": 136, + "completed": true + }, + { + "event": { + "id": "clock", + "name": "Clock", + "rank": 110 + }, + "regionalRank": 76, + "completed": true + }, + { + "event": { + "id": "minx", + "name": "Megaminx", + "rank": 120 + }, + "regionalRank": 146, + "completed": true + }, + { + "event": { + "id": "pyram", + "name": "Pyraminx", + "rank": 130 + }, + "regionalRank": 158, + "completed": true + }, + { + "event": { + "id": "skewb", + "name": "Skewb", + "rank": 140 + }, + "regionalRank": 60, + "completed": true + }, + { + "event": { + "id": "sq1", + "name": "Square-1", + "rank": 150 + }, + "regionalRank": 386, + "completed": true + }, + { + "event": { + "id": "444bf", + "name": "4x4x4 Blindfolded", + "rank": 160 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "555bf", + "name": "5x5x5 Blindfolded", + "rank": 170 + }, + "regionalRank": null, + "completed": false + } + ] + }, + { + "regionRank": 15, + "wcaId": "2011LIMA02", + "name": "2011LIMA02 Coelho Lima", + "countryIso2": "Brazil", + "overall": 2378, + "events": [ + { + "event": { + "id": "333", + "name": "3x3x3 Cube", + "rank": 10 + }, + "regionalRank": 234, + "completed": true + }, + { + "event": { + "id": "222", + "name": "2x2x2 Cube", + "rank": 20 + }, + "regionalRank": 120, + "completed": true + }, + { + "event": { + "id": "444", + "name": "4x4x4 Cube", + "rank": 30 + }, + "regionalRank": 179, + "completed": true + }, + { + "event": { + "id": "555", + "name": "5x5x5 Cube", + "rank": 40 + }, + "regionalRank": 237, + "completed": true + }, + { + "event": { + "id": "666", + "name": "6x6x6 Cube", + "rank": 50 + }, + "regionalRank": 198, + "completed": true + }, + { + "event": { + "id": "777", + "name": "7x7x7 Cube", + "rank": 60 + }, + "regionalRank": 206, + "completed": true + }, + { + "event": { + "id": "333bf", + "name": "3x3x3 Blindfolded", + "rank": 70 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "333fm", + "name": "3x3x3 Fewest Moves", + "rank": 80 + }, + "regionalRank": 10, + "completed": true + }, + { + "event": { + "id": "333oh", + "name": "3x3x3 One-Handed", + "rank": 90 + }, + "regionalRank": 382, + "completed": true + }, + { + "event": { + "id": "clock", + "name": "Clock", + "rank": 110 + }, + "regionalRank": 136, + "completed": true + }, + { + "event": { + "id": "minx", + "name": "Megaminx", + "rank": 120 + }, + "regionalRank": 219, + "completed": true + }, + { + "event": { + "id": "pyram", + "name": "Pyraminx", + "rank": 130 + }, + "regionalRank": 135, + "completed": true + }, + { + "event": { + "id": "skewb", + "name": "Skewb", + "rank": 140 + }, + "regionalRank": 271, + "completed": true + }, + { + "event": { + "id": "sq1", + "name": "Square-1", + "rank": 150 + }, + "regionalRank": 51, + "completed": true + }, + { + "event": { + "id": "444bf", + "name": "4x4x4 Blindfolded", + "rank": 160 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "555bf", + "name": "5x5x5 Blindfolded", + "rank": 170 + }, + "regionalRank": null, + "completed": false + } + ] + } + ] +} \ No newline at end of file diff --git a/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_5.json b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_5.json new file mode 100644 index 00000000..c0607e80 --- /dev/null +++ b/server/src/test/resources/jsons/sum-of-ranks-controller-i-t/list_5.json @@ -0,0 +1,465 @@ +{ + "page": 4, + "pageSize": 3, + "content": [ + { + "regionRank": 13, + "wcaId": "2017SOUZ10", + "name": "2017SOUZ10 Souza", + "countryIso2": "Brazil", + "overall": 461, + "events": [ + { + "event": { + "id": "333", + "name": "3x3x3 Cube", + "rank": 10 + }, + "regionalRank": 59, + "completed": true + }, + { + "event": { + "id": "222", + "name": "2x2x2 Cube", + "rank": 20 + }, + "regionalRank": 95, + "completed": true + }, + { + "event": { + "id": "444", + "name": "4x4x4 Cube", + "rank": 30 + }, + "regionalRank": 30, + "completed": true + }, + { + "event": { + "id": "555", + "name": "5x5x5 Cube", + "rank": 40 + }, + "regionalRank": 24, + "completed": true + }, + { + "event": { + "id": "666", + "name": "6x6x6 Cube", + "rank": 50 + }, + "regionalRank": 17, + "completed": true + }, + { + "event": { + "id": "777", + "name": "7x7x7 Cube", + "rank": 60 + }, + "regionalRank": 27, + "completed": true + }, + { + "event": { + "id": "333bf", + "name": "3x3x3 Blindfolded", + "rank": 70 + }, + "regionalRank": 56, + "completed": true + }, + { + "event": { + "id": "333fm", + "name": "3x3x3 Fewest Moves", + "rank": 80 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "333oh", + "name": "3x3x3 One-Handed", + "rank": 90 + }, + "regionalRank": 14, + "completed": true + }, + { + "event": { + "id": "clock", + "name": "Clock", + "rank": 110 + }, + "regionalRank": 3, + "completed": true + }, + { + "event": { + "id": "minx", + "name": "Megaminx", + "rank": 120 + }, + "regionalRank": 36, + "completed": true + }, + { + "event": { + "id": "pyram", + "name": "Pyraminx", + "rank": 130 + }, + "regionalRank": 82, + "completed": true + }, + { + "event": { + "id": "skewb", + "name": "Skewb", + "rank": 140 + }, + "regionalRank": 13, + "completed": true + }, + { + "event": { + "id": "sq1", + "name": "Square-1", + "rank": 150 + }, + "regionalRank": 5, + "completed": true + }, + { + "event": { + "id": "444bf", + "name": "4x4x4 Blindfolded", + "rank": 160 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "555bf", + "name": "5x5x5 Blindfolded", + "rank": 170 + }, + "regionalRank": null, + "completed": false + } + ] + }, + { + "regionRank": 14, + "wcaId": "2011LIMA02", + "name": "2011LIMA02 Coelho Lima", + "countryIso2": "Brazil", + "overall": 507, + "events": [ + { + "event": { + "id": "333", + "name": "3x3x3 Cube", + "rank": 10 + }, + "regionalRank": 55, + "completed": true + }, + { + "event": { + "id": "222", + "name": "2x2x2 Cube", + "rank": 20 + }, + "regionalRank": 26, + "completed": true + }, + { + "event": { + "id": "444", + "name": "4x4x4 Cube", + "rank": 30 + }, + "regionalRank": 33, + "completed": true + }, + { + "event": { + "id": "555", + "name": "5x5x5 Cube", + "rank": 40 + }, + "regionalRank": 48, + "completed": true + }, + { + "event": { + "id": "666", + "name": "6x6x6 Cube", + "rank": 50 + }, + "regionalRank": 35, + "completed": true + }, + { + "event": { + "id": "777", + "name": "7x7x7 Cube", + "rank": 60 + }, + "regionalRank": 42, + "completed": true + }, + { + "event": { + "id": "333bf", + "name": "3x3x3 Blindfolded", + "rank": 70 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "333fm", + "name": "3x3x3 Fewest Moves", + "rank": 80 + }, + "regionalRank": 9, + "completed": true + }, + { + "event": { + "id": "333oh", + "name": "3x3x3 One-Handed", + "rank": 90 + }, + "regionalRank": 89, + "completed": true + }, + { + "event": { + "id": "clock", + "name": "Clock", + "rank": 110 + }, + "regionalRank": 43, + "completed": true + }, + { + "event": { + "id": "minx", + "name": "Megaminx", + "rank": 120 + }, + "regionalRank": 39, + "completed": true + }, + { + "event": { + "id": "pyram", + "name": "Pyraminx", + "rank": 130 + }, + "regionalRank": 35, + "completed": true + }, + { + "event": { + "id": "skewb", + "name": "Skewb", + "rank": 140 + }, + "regionalRank": 41, + "completed": true + }, + { + "event": { + "id": "sq1", + "name": "Square-1", + "rank": 150 + }, + "regionalRank": 12, + "completed": true + }, + { + "event": { + "id": "444bf", + "name": "4x4x4 Blindfolded", + "rank": 160 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "555bf", + "name": "5x5x5 Blindfolded", + "rank": 170 + }, + "regionalRank": null, + "completed": false + } + ] + }, + { + "regionRank": 15, + "wcaId": "2017BORG02", + "name": "2017BORG02", + "countryIso2": "Brazil", + "overall": 512, + "events": [ + { + "event": { + "id": "333", + "name": "3x3x3 Cube", + "rank": 10 + }, + "regionalRank": 54, + "completed": true + }, + { + "event": { + "id": "222", + "name": "2x2x2 Cube", + "rank": 20 + }, + "regionalRank": 56, + "completed": true + }, + { + "event": { + "id": "444", + "name": "4x4x4 Cube", + "rank": 30 + }, + "regionalRank": 53, + "completed": true + }, + { + "event": { + "id": "555", + "name": "5x5x5 Cube", + "rank": 40 + }, + "regionalRank": 31, + "completed": true + }, + { + "event": { + "id": "666", + "name": "6x6x6 Cube", + "rank": 50 + }, + "regionalRank": 7, + "completed": true + }, + { + "event": { + "id": "777", + "name": "7x7x7 Cube", + "rank": 60 + }, + "regionalRank": 8, + "completed": true + }, + { + "event": { + "id": "333bf", + "name": "3x3x3 Blindfolded", + "rank": 70 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "333fm", + "name": "3x3x3 Fewest Moves", + "rank": 80 + }, + "regionalRank": 44, + "completed": true + }, + { + "event": { + "id": "333oh", + "name": "3x3x3 One-Handed", + "rank": 90 + }, + "regionalRank": 33, + "completed": true + }, + { + "event": { + "id": "clock", + "name": "Clock", + "rank": 110 + }, + "regionalRank": 26, + "completed": true + }, + { + "event": { + "id": "minx", + "name": "Megaminx", + "rank": 120 + }, + "regionalRank": 26, + "completed": true + }, + { + "event": { + "id": "pyram", + "name": "Pyraminx", + "rank": 130 + }, + "regionalRank": 42, + "completed": true + }, + { + "event": { + "id": "skewb", + "name": "Skewb", + "rank": 140 + }, + "regionalRank": 12, + "completed": true + }, + { + "event": { + "id": "sq1", + "name": "Square-1", + "rank": 150 + }, + "regionalRank": 120, + "completed": true + }, + { + "event": { + "id": "444bf", + "name": "4x4x4 Blindfolded", + "rank": 160 + }, + "regionalRank": null, + "completed": false + }, + { + "event": { + "id": "555bf", + "name": "5x5x5 Blindfolded", + "rank": 170 + }, + "regionalRank": null, + "completed": false + } + ] + } + ] +} \ No newline at end of file