Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗃️(api) make location coordinates unique #330

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

jmaupetit
Copy link
Member

@jmaupetit jmaupetit commented Jan 10, 2025

Purpose

Instead of having a unique Localisation.adresse_station field, let's be more pedantic and refuse to have two locations with the same coordinates.

Proposal

  • add localisation_coordonneesXY_key constraint to the Localisation table
  • add database migration
  • fix development dataset

Remark

This is an alternative implementation to fix issue #309 (see also #329).

@jmaupetit jmaupetit marked this pull request as draft January 10, 2025 16:53
@jmaupetit jmaupetit self-assigned this Jan 10, 2025
@jmaupetit jmaupetit added WIP schema Discussions around data schemas API Item related to the API service improvement labels Jan 10, 2025
@jmaupetit jmaupetit linked an issue Jan 10, 2025 that may be closed by this pull request
@jmaupetit jmaupetit force-pushed the api-remove-localisation-adresse-field-uniqueness-alt branch from 590af3b to e9e227e Compare January 13, 2025 17:59
@jmaupetit jmaupetit marked this pull request as ready for review January 13, 2025 18:00
@jmaupetit jmaupetit removed the WIP label Jan 13, 2025
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Jan 14, 2025
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Jan 14, 2025
@jmaupetit jmaupetit force-pushed the api-remove-localisation-adresse-field-uniqueness-alt branch 2 times, most recently from 3d32594 to 0d5a2c6 Compare January 14, 2025 10:37
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Jan 14, 2025
Copy link

Current benchmark

Type Name Request Count Failure Count Median Response Time Average Response Time Min Response Time Max Response Time Average Content Size Requests/s Failures/s 50% 66% 75% 80% 90% 95% 98% 99% 99.9% 99.99% 100% git timestamp version
GET /auth/whoami 3 0 23.0 142.49235466665291 21.22233500000448 382.7953039999557 160.0 0.3095250347802994 0.0 23 23 380 380 380 380 380 380 380 380 380 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
POST /dynamique/session/ 4 0 410.0 386.8779374999747 12.235558999975638 687.6364639999792 45.0 0.4127000463737325 0.0 440 440 690 690 690 690 690 690 690 690 690 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
POST /dynamique/session/bulk 10 0 180.0 324.8128538999936 15.825172999996084 695.6486689999792 411.0 1.0317501159343314 0.0 330 460 670 670 700 700 700 700 700 700 700 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
GET /dynamique/status/ 12 0 370.0 269.93988724999934 24.641167999959634 686.7385729999569 285.0 1.2381001391211977 0.0 370 380 420 420 440 690 690 690 690 690 690 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
POST /dynamique/status/ 5 0 550.0 657.5606993999827 17.019998999955988 1469.6703200000345 45.0 0.5158750579671657 0.0 550 700 700 1500 1500 1500 1500 1500 1500 1500 1500 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
GET /dynamique/status/FRALLEGO002006P3 7 0 34.0 128.12135114285184 9.374766999997064 444.318485999986 191.28571428571428 0.722225081154032 0.0 34 50 320 320 440 440 440 440 440 440 440 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
GET /dynamique/status/FRALLEGO002006P3/history 10 0 42.0 428.2229550999887 9.273749000044518 1602.1837159999563 8229.0 1.0317501159343314 0.0 300 370 390 1500 1600 1600 1600 1600 1600 1600 1600 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
POST /dynamique/status/bulk 7 0 420.0 299.12174242856184 22.25405699999783 675.3376890000027 411.0 0.722225081154032 0.0 420 430 470 470 680 680 680 680 680 680 680 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
POST /statique/ 7 3 180.0 208.5807994285704 28.86761600001364 439.87959300000057 57.285714285714285 0.722225081154032 0.3095250347802994 180 320 400 400 440 440 440 440 440 440 440 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
GET /statique/?limit=10 4 0 330.0 623.50586674998 21.26078599997072 1466.3364759999808 13826.0 0.4127000463737325 0.0 680 680 1500 1500 1500 1500 1500 1500 1500 1500 1500 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
GET /statique/?limit=100 4 0 440.0 662.8493637499986 416.614691999996 1183.3150520000115 129006.0 0.4127000463737325 0.0 610 610 1200 1200 1200 1200 1200 1200 1200 1200 1200 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
PUT /statique/FR073EP7QU5233 4 0 37.0 104.0135445000061 30.547196999975768 299.838646000012 1371.0 0.4127000463737325 0.0 49 49 300 300 300 300 300 300 300 300 300 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
GET /statique/FRALLEGO002006P3 7 0 150.0 223.67791500001235 23.509579000005942 608.1658470000093 1202.0 0.722225081154032 0.0 150 320 390 390 610 610 610 610 610 610 610 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
POST /statique/bulk 11 0 670.0 779.5255421818297 373.7480690000439 1602.1837960000198 1113.909090909091 1.1349251275277643 0.0 670 740 840 840 1500 1600 1600 1600 1600 1600 1600 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0
Aggregated 95 3 370.0 380.8968186105224 9.273749000044518 1602.1837960000198 7292.642105263158 9.801626101376147 0.3095250347802994 370 440 550 670 700 1500 1600 1600 1600 1600 1600 30e51d0 2025-01-14 10:42:49.318071+00:00 0.16.0

Comparison with the latest previous benchmark

A lower (negative) value means the current version performs better than the previous one.

Type Name Request Count Failure Count Median Response Time Average Response Time Min Response Time Max Response Time Average Content Size Requests/s
GET /auth/whoami
POST /dynamique/session/
POST /dynamique/session/bulk
GET /dynamique/status/
POST /dynamique/status/
GET /dynamique/status/FRALLEGO002006P3
GET /dynamique/status/FRALLEGO002006P3/history
POST /dynamique/status/bulk
POST /statique/
GET /statique/?limit=10
GET /statique/?limit=100
PUT /statique/FR073EP7QU5233
GET /statique/FRALLEGO002006P3
POST /statique/bulk
Aggregated

@jmaupetit jmaupetit added the blocked Task depends on another task label Jan 14, 2025
@jmaupetit
Copy link
Member Author

⚠️ DO NOT MERGE ME ⚠️

Staging database duplicated Localisation.coordonneesXY entries should be fixed first.

@jmaupetit
Copy link
Member Author

Should be ok to merge now!

@jmaupetit jmaupetit force-pushed the api-remove-localisation-adresse-field-uniqueness-alt branch from 0d5a2c6 to 9ba6d37 Compare January 17, 2025 15:18
@jmaupetit jmaupetit removed the blocked Task depends on another task label Jan 17, 2025
Instead of having a unique Localisation.adresse_station field, let's be
more pedantic and refuse to have two locations with the same
coordinates.
Yeah, it disturbed me.
@jmaupetit jmaupetit force-pushed the api-remove-localisation-adresse-field-uniqueness-alt branch from 9ba6d37 to 86ec927 Compare January 17, 2025 15:24
Copy link

Current benchmark

Type Name Request Count Failure Count Median Response Time Average Response Time Min Response Time Max Response Time Average Content Size Requests/s Failures/s 50% 66% 75% 80% 90% 95% 98% 99% 99.9% 99.99% 100% git timestamp version
GET /auth/whoami 25 0 540.0 601.5258504400014 2.020175000012614 1953.292380000022 160.0 0.8657349798746686 0.0 540 650 770 890 1400 1600 2000 2000 2000 2000 2000 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
POST /dynamique/session/ 28 0 840.0 964.4848363571408 10.195498000001637 2701.1238850000154 45.0 0.9696231774596288 0.0 910 930 1100 1100 2600 2700 2700 2700 2700 2700 2700 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
POST /dynamique/session/bulk 24 0 680.0 771.7004192916689 17.099470999994537 2637.091561999995 411.0 0.8311055806796819 0.0 700 800 1100 1200 1400 1500 2600 2600 2600 2600 2600 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
GET /dynamique/status/ 20 0 520.0 556.8910766499955 7.702434999998786 1110.6421970000042 285.0 0.692587983899735 0.0 580 810 930 940 1100 1100 1100 1100 1100 1100 1100 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
POST /dynamique/status/ 25 0 930.0 968.7107309199996 35.08210799998324 2699.759099000005 45.0 0.8657349798746686 0.0 930 1100 1300 1600 2500 2700 2700 2700 2700 2700 2700 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
GET /dynamique/status/FRALLEGO002006P3 24 0 1100.0 1196.0564182916662 23.31757799998968 2911.954633000022 283.0 0.8311055806796819 0.0 1200 1700 2100 2300 2500 2500 2900 2900 2900 2900 2900 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
GET /dynamique/status/FRALLEGO002006P3/history 30 0 840.0 1090.1124178666655 32.51484399999072 3300.3323370000144 49417.0 1.0388819758496024 0.0 1100 1200 1500 1600 2400 2500 3300 3300 3300 3300 3300 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
POST /dynamique/status/bulk 26 0 670.0 823.8212943846107 99.1285380000022 2701.393938000024 411.0 0.9003643790696554 0.0 670 900 930 1200 2300 2500 2700 2700 2700 2700 2700 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
POST /statique/ 14 5 690.0 906.057863428572 20.694816999991872 2669.923893999993 58.285714285714285 0.4848115887298144 0.1731469959749337 770 800 1100 1200 2500 2700 2700 2700 2700 2700 2700 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
GET /statique/?limit=10 24 0 920.0 1013.0124513333338 21.496062000011307 2945.1897779999854 13826.583333333334 0.8311055806796819 0.0 930 1200 1500 1600 2100 2300 2900 2900 2900 2900 2900 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
GET /statique/?limit=100 25 0 900.0 1124.9483819600005 141.34062099998346 2885.9380190000084 129006.6 0.8657349798746686 0.0 900 1400 1600 1900 2200 2400 2900 2900 2900 2900 2900 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
PUT /statique/FR073EP7QU5233 22 0 760.0 901.370943454548 32.43651599998998 2669.932500000016 1371.0 0.7618467822897084 0.0 800 930 1100 1200 2200 2200 2700 2700 2700 2700 2700 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
GET /statique/FRALLEGO002006P3 31 0 840.0 1010.2869084193542 26.373038999992104 3453.5900399999946 1202.0 1.073511375044589 0.0 840 1100 1500 1700 1700 2500 3500 3500 3500 3500 3500 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
POST /statique/bulk 33 0 1300.0 1456.8294167272743 393.967334999985 2673.684406999996 1114.5151515151515 1.1427701734345626 0.0 1300 1700 2000 2200 2600 2700 2700 2700 2700 2700 2700 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0
Aggregated 351 5 800.0 977.4742048860394 2.020175000012614 3453.5900399999946 14769.11396011396 12.154919117440349 0.1731469959749337 800 1100 1300 1500 2200 2600 2700 2900 3500 3500 3500 33c811a 2025-01-17 15:27:42.772103+00:00 0.16.0

Comparison with the latest previous benchmark

A lower (negative) value means the current version performs better than the previous one.

Type Name Request Count Failure Count Median Response Time Average Response Time Min Response Time Max Response Time Average Content Size Requests/s
GET /auth/whoami
POST /dynamique/session/
POST /dynamique/session/bulk
GET /dynamique/status/
POST /dynamique/status/
GET /dynamique/status/FRALLEGO002006P3
GET /dynamique/status/FRALLEGO002006P3/history
POST /dynamique/status/bulk
POST /statique/
GET /statique/?limit=10
GET /statique/?limit=100
PUT /statique/FR073EP7QU5233
GET /statique/FRALLEGO002006P3
POST /statique/bulk
Aggregated

@jmaupetit jmaupetit merged commit 9006650 into main Jan 17, 2025
15 checks passed
@jmaupetit jmaupetit deleted the api-remove-localisation-adresse-field-uniqueness-alt branch January 17, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Item related to the API service improvement schema Discussions around data schemas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Localisation.adresse field should not be unique
1 participant