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

Migrate TanStack queries to query composables #748

Merged
merged 309 commits into from
Oct 15, 2024
Merged

Conversation

maximilianoertel
Copy link
Collaborator

@maximilianoertel maximilianoertel commented Aug 17, 2024

Proposed changes

This PR migrates the existing TanStack queries defined throughout the codebase to re-usable query composables.

Caution

Due to the extent of the changes, this PR should be heavily tested on the ephemeral environment before merging.

Key Highlights:

  • The primary focus of this PR (and its chained PR) is the migration of queries to composables, which includes some initial optimizations but leaves room for future enhancements.
  • In a subsequent step, we aim to improve the current data fetching layer residing in utils, refactoring it into distinct service and data access layers. This will allow for further optimization and reduction of complexity within the query composables. There is also potential to enhance the mutation logic, particularly by exploring more granular query invalidation and introducing additional opportunities for optimistic updates.

Additional Notes

  • This PR includes a regenerated package-lock file due to build failures in the CI caused by npm/cli#4828.
  • Updated @tanstack/vue-query to the latest version, which introduces some deprecations.
  • Installed the official TanStack dev tools, which will only be available in non-production environments.
  • Configured global settings for garbage collection (formerly known as cacheTime) and stale time.
  • Extended the getAxiosInstance helper with a baseUrl check to ensure it is always set, addressing an issue that appears to stem from the initialization process.
  • Simplified certain queries by adjusting field selection. For instance, fetching districts and district tags is now unified into a single useDistrictsQuery composable to enable data caching and reuse.
  • The <HomeSelector /> component now lazy loads the homepage and consent modal components.
  • Refactored SSO landing pages into a single page for improved maintainability.

Chained Pull Requests:

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (non-breaking change that does not add functionality but makes code cleaner or more efficient)
  • Documentation Update
  • Tests (new or updated tests)
  • Style (changes to code styling)
  • CI (continuous integration changes)
  • Repository Maintenance
  • Other (please describe below)

Checklist

  • I have read the guidelines for contributing.
  • The changes in this PR are as small as they can be. They represent one and only one fix or enhancement.
  • Linting checks pass with my changes.
  • Any existing unit tests pass with my changes.
  • Any existing end-to-end tests pass with my changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • If this PR fixes an existing issue, I have added a unit or end-to-end test that will detect if this issue reoccurs.
  • I have added JSDoc comments as appropriate.
  • I have added the necessary documentation to the roar-docs repository.
  • I have shared this PR on the roar-pr-reviews channel (if I have access)
  • I have linked relevant issues (if any)

Justification of missing checklist items

n/a

Further comments

n/a

Resolves https://github.com/yeatmanlab/roar/issues/318
Resolves https://github.com/yeatmanlab/roar/issues/376

@maximilianoertel maximilianoertel added the enhancement New feature or request label Aug 17, 2024
@maximilianoertel maximilianoertel self-assigned this Aug 17, 2024
Copy link

github-actions bot commented Aug 17, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 1% 73 / 7291
🔵 Statements 0.92% 74 / 8013
🔵 Functions 0.79% 14 / 1757
🔵 Branches 0.45% 20 / 4365
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/App.vue 0% 0% 0% 0% 37, 37, 43-44, 46-47, 49-53, 50-52, 55, 55, 57, 59-85, 87-100, 88-98, 91-97, 92-96, 99
src/main.js 0% 0% 0% 0% 109-111, 113, 115-117, 119, 121-141, 143-175, 177-241, 243, 246, 248-251, 249-250, 255, 257
src/components/CreateOrgs.vue 0% 0% 0% 0% 216-222, 224-233, 236-239, 237, 237-238, 241-243, 242, 242, 245-247, 246, 246, 249-251, 253, 253-254, 254, 256, 256, 258-264, 260, 266-272, 268, 274-276, 275, 278, 278, 280-286, 282, 288-290, 289, 292-294, 293, 296, 296, 298-304, 300, 306-312, 309-311, 314-315, 317-322, 324, 326-332, 328-330, 329, 331, 334, 334, 336-352, 354-360, 355, 355-356, 356-357, 357-358, 358-359, 362-369, 363-367, 364-367, 366, 368, 371-381, 373-374, 374-379, 376, 378, 378, 380, 383-390, 384-389, 392-394, 393, 396-447, 397-446, 400-403, 405, 405-406, 406-407, 407-408, 408, 410-415, 411-415, 414, 417-443, 418-429, 421-423, 426-428, 431-442, 434-436, 439-441, 445, 449-456, 450-455, 2-3, 1, 15-17, 35, 72-73, 76, 76, 81, 84, 84, 107, 110, 120, 124-126, 154, 168, 172-173, 177, 185-186, 1-20, 1-38, 1-56, 1-75, 1-83, 1-92, 1-114, 1-158, 1-174, 1-178
src/components/EditUsersForm.vue 0% 0% 0% 0% 214, 230, 232-234, 236-244, 237, 240-242, 241, 247-267, 270-293, 271-292, 296-300, 297, 297-298, 298-299, 302-306, 303-305, 304-305, 308-314, 316-320, 322-334, 323, 325, 325, 327-331, 328, 330, 330, 333, 337-340, 338, 338-339, 342-344, 343, 343, 346-350, 347-348, 348-349, 349, 355-361, 356, 358, 364-366, 368-371, 369, 369-370, 3-4, 9, 14, 20, 36, 1, 51, 51, 55, 55, 59-60, 66, 77, 88, 100, 114, 130-131, 136, 141, 151, 158, 164-165, 182, 190, 2-1, 1-7, 1-12, 1-17, 1-28, 1-43, 1-50, 1-54, 1-63, 1-71, 1-82, 1-93, 1-107, 1-121, 1-134, 1-139, 1-144, 1-149, 1-156, 1-175, 1-187, 1-197
src/components/ListOrgs.vue 0% 0% 0% 0% 136-143, 145-150, 146-148, 147, 149, 152-157, 153-155, 154, 156, 160-161, 163-165, 167, 167-168, 168, 170-197, 171-176, 178, 178, 180-185, 182-184, 186-189, 187-188, 190-192, 191, 193-195, 194, 196, 199, 201, 201, 203-209, 205, 212-229, 215-220, 223-228, 232-234, 233, 236-242, 238, 248-264, 251-260, 266-276, 267-275, 278-317, 279-284, 286-291, 287-290, 293-296, 294-295, 298-316, 319-332, 320, 320-331, 322-330, 334-340, 335-339, 337-338, 342-344, 343, 347-350, 348, 348-349, 352-354, 353, 353, 356-358, 357, 357, 360-362, 361, 364-366, 365, 368-371, 370, 3-4, 1, 22, 39, 55, 77, 85, 87, 99, 102, 109, 112, 1-14, 1-29, 1-45, 1-79, 97, 107
src/components/NavBar.vue 0% 0% 0% 0% 82-88, 91-94, 92, 92-93, 96-98, 97, 97, 100-103, 101, 101-102, 105-107, 106, 109-111, 113-115, 114, 117-140, 118-138, 121-131, 122, 124-130, 128, 132-137, 133-136, 139, 142-145, 143-144, 147-164, 148-163, 149, 151-154, 153, 155-162, 159, 161, 166-170, 167, 167-168, 168-169, 172, 172, 174-176, 175, 178-184, 179-183, 186-201, 191, 198, 203-229, 204-228, 211, 218, 225, 231-233, 232, 3, 5, 9, 25, 27, 1, 48, 57
src/components/OrgPicker.vue 0% 0% 0% 0% 110-112, 114-115, 117, 133-139, 141-150, 142, 144-148, 152-154, 156, 156-157, 157, 159-186, 160-165, 167, 167, 169-174, 171-173, 175-178, 176-177, 179-181, 180, 182-184, 183, 185, 188-193, 189-191, 190, 192, 195-200, 196-198, 197, 199, 202-205, 204, 207, 207, 209-215, 211, 217-219, 218, 221-227, 223, 229-243, 232-239, 245-247, 246, 246, 249-252, 250-251, 251, 255-258, 256, 256-257, 260-262, 261, 261, 264-266, 265, 265, 268-270, 269, 272-274, 273, 276, 278-280, 279, 2-3, 13, 31, 48, 52, 63, 65, 75, 1, 1-21, 1-38, 1-54, 87
src/components/modals/EditUsers.vue 0% 0% 0% 0% 208, 225, 227-229, 231-241, 232, 234-239, 236-238, 243, 246-253, 247-252, 255-270, 256-269, 261-263, 266-268, 272-295, 273-276, 274-275, 277-280, 278-279, 281, 283-294, 286-288, 291-293, 297-299, 298, 302-308, 310-332, 311-331, 334-338, 335, 335-336, 336-337, 340-346, 348-352, 354-366, 355, 357, 357, 359-363, 360, 362, 362, 365, 369-372, 370, 370-371, 374-376, 375, 375, 378-380, 379, 379, 383-385, 387-390, 388, 388-389, 4-7, 11, 20-22, 25-26, 29-30, 34, 48, 1, 64-65, 70-71, 76-78, 82-83, 91-92, 100-101, 110-111, 120-121, 142, 149, 161, 186, 1-23, 1-27, 1-31, 1-40, 1-54, 1-63, 1-69, 1-79, 1-85, 1-94, 1-103, 1-113, 1-123, 135, 1-143, 1-150
src/components/views/OfflineSettings.vue 0% 0% 0% 0% 181-184, 189, 191-194, 192, 192-193, 198-199, 199-200, 200-203, 202, 204, 204, 209-216, 212, 218-220, 222-228, 224, 230-236, 232, 238-246, 239, 239-245, 241-244, 248-253, 255-264, 257-258, 261-263, 266-268, 267, 270-283, 271-282, 272-278, 280-281, 285-298, 286-297, 287-293, 295-296, 300-303, 301-302, 302, 305-308, 306-307, 307, 310-312, 311, 311, 314-317, 315, 315-316, 319-343, 320-339, 328-329, 332-338, 342, 8, 1, 11, 27, 34, 52, 71, 79, 87-88, 108, 127, 142, 1-23, 1-36, 69, 1-92, 125
src/constants/firebase.js 0% 100% 100% 0% 4-7
src/constants/queryKeys.js 0% 100% 100% 0% 1-2
src/pages/AdminProfile.vue 0% 0% 0% 0% 57-59, 61-66, 62-65, 64, 68-70, 69, 75, 77-80, 78, 78-79, 82-84, 83, 83, 86-88, 87, 87, 90-92, 95-99, 96, 96-97, 97-98, 5, 7-8, 1, 12-13, 19-20, 24-25, 44, 33
src/pages/HomeAdministrator.vue 0% 0% 0% 0% 131-138, 140, 142, 144-146, 149-152, 150, 150-151, 154-156, 155, 155, 158-160, 159, 159, 162, 162-163, 163-164, 164-168, 167, 174-194, 176, 182-184, 183, 186-192, 187, 189-191, 190, 196, 198-202, 199-201, 204-213, 205-212, 206, 208-210, 209, 211, 215-219, 216-218, 217, 221-298, 300-319, 301-304, 306-311, 308, 310, 312-316, 313, 315, 318, 2-3, 5-6, 1, 14-18, 37-38, 81, 114, 1-21, 1-40, 45
src/pages/HomeSelector.vue 0% 0% 0% 0% 35-37, 39-41, 43-44, 46-52, 47-52, 50-51, 54-55, 57, 59-62, 60, 60-61, 64-66, 65, 65, 68-70, 72-74, 76, 76, 78-82, 79, 79-80, 80-81, 84-90, 85-89, 86, 88, 91-93, 96-99, 97-98, 103, 107-110, 109, 112-120, 113-119, 117-118, 123-139, 124-126, 128-131, 129-130, 132, 132-138, 134-137, 136, 141-145, 142-144, 143, 1, 3, 5
src/pages/ProgressReport.vue 0% 0% 0% 0% 177, 179, 181, 196, 198-202, 204-209, 205-207, 206, 208, 211-213, 212, 215-228, 230-237, 231-236, 239-241, 244-246, 248, 248-249, 249-250, 250, 252-259, 255, 261-270, 263, 268, 272-278, 274, 281-287, 283, 289, 289, 295-301, 297, 303-312, 304-311, 305-308, 306-307, 310, 314-387, 315, 315, 317, 319-384, 321, 323-327, 326, 328-340, 342-382, 345-346, 348-376, 349-376, 356-376, 363-368, 370-375, 377, 380, 383, 386, 389-392, 390-391, 394-416, 395-413, 396-405, 404, 406-408, 407, 409-411, 410, 412, 414-415, 418-445, 419-437, 420-429, 428, 430-432, 431, 433-435, 434, 436, 438-444, 447-536, 448, 448, 450-460, 451-459, 461-470, 461-469, 471-473, 471-472, 474-476, 474-475, 478, 480-493, 481-484, 482-483, 485-492, 495-497, 496, 499, 499-506, 501-505, 502, 504, 508-509, 511-515, 512-514, 513, 517-521, 518-520, 519, 523-534, 524-533, 535, 538, 540-543, 542, 545-563, 546-562, 548-553, 550-552, 551, 554-558, 555-557, 556, 559, 561, 566-573, 568-569, 569, 571-572, 575-577, 576, 576, 579-581, 580, 580, 2-4, 1, 6, 8-9, 14-15, 21-22, 38, 45-46, 69-73, 134, 137, 150, 1-24, 1-125, 1-141
src/pages/RegisterFamilyUsers.vue 0% 0% 0% 0% 67-69, 72, 76-78, 80, 80, 82-83, 85-88, 90, 92-94, 93, 96-99, 97-98, 102-109, 103-104, 106-108, 113-119, 114, 116-118, 123-129, 124, 126-128, 133, 137-141, 138, 140, 144-193, 145-192, 146-177, 156-176, 178-191, 187-190, 195-197, 196, 199-201, 200, 2-3, 5, 11-12, 15-16, 1, 28, 35, 41, 20, 34, 1-44
src/pages/ScoreReport.vue 0% 0% 0% 0% 372, 330, 332, 334, 349, 351-356, 352-354, 353, 355, 358-362, 364-366, 365, 368, 370, 373, 373, 375-424, 376-378, 381-384, 383, 387, 389-408, 390-391, 391, 394-395, 397-400, 399, 402-404, 403, 405-407, 406, 411-414, 413, 415-421, 423, 426-439, 441-448, 442-447, 449-451, 454-457, 457-458, 458-459, 459, 461-467, 463, 469-475, 471, 478-484, 480, 486-495, 487-494, 488-491, 489-490, 493, 497-506, 498-505, 499-502, 500-501, 504, 508, 508, 515-521, 517, 525-556, 526-555, 527-555, 529-555, 531-555, 533-555, 538-544, 543, 545-555, 547-552, 549, 551, 553-555, 554, 557, 560-604, 572-575, 577-591, 582-588, 583-584, 586-587, 590, 593, 593-594, 594, 596-603, 609-831, 610-830, 611, 614, 616, 618-820, 620, 622-626, 625, 628, 630-650, 652-813, 656-663, 660, 662, 664-668, 665, 667, 670-677, 671-677, 674, 676, 679-681, 680, 684, 687-696, 698-704, 699-704, 701-704, 703, 706, 709-720, 722-756, 723-756, 732-733, 735-756, 744, 746-755, 757-775, 758-768, 766, 769, 771-774, 776-789, 777-781, 781-782, 782-783, 783-788, 792-806, 808-812, 809, 811, 816-817, 819, 823, 823, 825-827, 826, 829, 833, 836, 838-841, 840, 843-869, 845-847, 846, 848-868, 849, 851, 853-857, 854-856, 855, 858-862, 859-861, 860, 863, 865, 867, 871-877, 872, 874-876, 878, 880-885, 887-957, 888-949, 889-897, 896, 898-900, 899, 901-947, 902-923, 904-923, 908-923, 913-923, 916, 918-919, 921-922, 924-946, 925-943, 927-940, 928-930, 929, 931-936, 932, 934, 934-935, 938, 938-939, 942, 945, 948, 950-956, 959-1031, 960-1023, 961-970, 969, 971-973, 972, 974-1021, 975-996, 977-996, 981-996, 986-996, 989, 991-992, 994-995, 998-1020, 999-1017, 1001-1014, 1002-1004, 1003, 1005-1010, 1006, 1008, 1008-1009, 1012, 1012-1013, 1016, 1019, 1022, 1024-1030, 1034-1035, 1038, 1040-1078, 1041-1047, 1049-1055, 1051-1054, 1052-1053, 1057, 1057, 1059-1060, 1062-1063, 1063, 1065-1076, 1066-1076, 1073-1076, 1075, 1077, 1082-1262, 1083, 1083-1108, 1098-1107, 1109-1118, 1109-1117, 1119-1132, 1119-1131, 1121-1128, 1130, 1133-1135, 1133-1134, 1137, 1139-1147, 1140-1146, 1149-1151, 1150, 1153-1159, 1154-1158, 1155, 1157, 1161-1167, 1170-1176, 1171-1175, 1172-1174, 1173, 1179-1184, 1187-1191, 1188-1190, 1189, 1193-1260, 1195, 1198-1226, 1199-1226, 1206-1226, 1213, 1215-1225, 1216-1225, 1218-1225, 1220-1225, 1222, 1224, 1228, 1230-1240, 1237, 1239, 1242-1259, 1254-1256, 1255, 1257, 1261, 1264-1268, 1265-1267, 1266, 1266-1267, 1270-1281, 1271-1272, 1272-1273, 1273, 1275-1277, 1276, 1279-1280, 1283-1287, 1284-1286, 1285, 1290-1296, 1291-1292, 1292, 1294-1295, 1298-1300, 1299, 1299, 1302-1307, 1303-1306, 1306, 2-3, 5, 8, 11-12, 14-15, 20-21, 26, 28, 1, 55, 58-59, 61, 70-71, 74, 88-89, 95, 101, 108, 116, 134, 148, 151, 164, 170, 183, 189, 195, 201, 217, 271-272, 1-30, 1-139, 1-155, 1-173
src/queries/useUserClaimsQuery.js 0% 0% 0% 0% 15-24, 16-17, 19-23, 21
src/queries/useUserDataQuery.js 0% 0% 0% 0% 14-20, 15-19, 17
Generated in workflow #25

Copy link

github-actions bot commented Aug 17, 2024

Visit the preview URL for this PR (updated for commit 368a986):

https://roar-staging--pr748-ref-318-query-compos-licip3pp.web.app

(expires Tue, 22 Oct 2024 22:12:49 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 2631e9c58fd0104ecbfddd72a62245ddac467460

Copy link

cypress bot commented Aug 17, 2024

roar-dashboard-e2e    Run #8431

Run Properties:  status check passed Passed #8431  •  git commit 368a98652e: E2E Tests for PR 748 "`CU-8689c0g67` Migrate TanStack queries to query composabl...
Project roar-dashboard-e2e
Run status status check passed Passed #8431
Run duration 03m 28s
Commit git commit 368a98652e: E2E Tests for PR 748 "`CU-8689c0g67` Migrate TanStack queries to query composabl...
Committer Adam Richie-Halford
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 14

maximilianoertel and others added 24 commits October 11, 2024 19:27
Resolve merge conflicts for TanStack composables
* Fix SWR task loading

* Fix Vocab task loading

* Fix SRE task loading

* Fix Ran task loading

* Fix PA task loading

* Fix Multichoice task loading

* Fix MEP task loading

* Fix Levante task loading

* Fix Letter task loading

* Fix Fluency task loading

* Fix Crowding task loading
…in-selection

Fix administration selection
* Fix flashing loading states on participant homepage

* Fix refs
@maximilianoertel maximilianoertel changed the title CU-8689c0g67 Migrate TanStack queries to query composables Migrate TanStack queries to query composables Oct 15, 2024
@richford richford merged commit e40b8cc into main Oct 15, 2024
24 checks passed
@richford richford deleted the ref/318/query-composables branch October 15, 2024 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants