Skip to content

Conversation

@kcagran
Copy link
Contributor

@kcagran kcagran commented Oct 24, 2025

This pull request refactors the backend API to provide dedicated endpoints for listing labels, projects, organizations, and job templates, instead of returning these lists as part of the template options endpoint. It introduces new serializers, views, and URL routes for these resources, updates related tests, and removes their serialization from the template options logic. The frontend is also updated to handle the new data format for filters.

Backend API restructuring:

  • Added new serializers (LabelSerializer, ProjectSerializer, OrganizationSerializer, JobTemplateSerializer) and corresponding views and URL routes for labels, projects, organizations, and job templates, enabling paginated listing via dedicated endpoints. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
  • Removed generic model serializers and related imports for these resources from template_options/serializers.py and template_options/views.py. The template options endpoint no longer returns lists of labels, projects, organizations, or job templates. [1] [2] [3]

Testing updates:

  • Updated unit tests to expect the new data structure, removed checks for lists in template options, and added new tests for the dedicated endpoints for labels, organizations, projects, and job templates. [1] [2] [3] [4] [5]

Frontend compatibility:

  • Modified the frontend to map filter options to their keys to match the new backend response format for filters. [1] [2]

These changes improve API clarity, maintainability, and scalability by separating concerns and providing paginated access to key resources.


Note

Introduce separate paginated endpoints for labels, organizations, projects, and templates, remove these from template_options, and update the frontend filters to fetch/search/paginate options via the new APIs; tests updated accordingly.

  • Backend/API:
    • Add paginated endpoints with search/ordering for labels, organizations, projects, and templates (serializers, views, urls), and wire them in api/v1/urls.py.
    • Refactor TemplateView to support list/retrieve with search/ordering and split TemplatesSerializer vs JobTemplateSerializer.
    • Remove label/org/project/template option lists from template_options serializers/views; endpoint now returns only meta (dates, currencies, costs, settings, filter sets).
  • Frontend/UI:
    • Refactor Filters to load options from new endpoints with pagination, infinite scroll, and search; map selections to key values when saving/applying filters.
    • Add filterOptionsStore (zustand) and selectors for fetching, paging, searching, and retrieving single options; update types to use FilterOptionWithId.
    • Enhance MultiChoiceDropdown with async search, loading indicator, and bottom-reach fetch; update BaseTable and Dashboard to use external pagination state and reset on filter/sort changes.
    • Update AddEditView to await saves and convert selections to ids; add minor styling (.dropdown-loader).
  • Tests:
    • Update unit tests to new template_options shape and add coverage for new list endpoints.
    • Extend Playwright fixtures and interceptors; update specs to mock new endpoints and validate filter behavior.

Written by Cursor Bugbot for commit ad511ab. This will update automatically on new commits. Configure here.

@kcagran kcagran requested review from abwalczyk and matburt October 24, 2025 09:42
@kcagran kcagran self-assigned this Oct 24, 2025
@github-actions
Copy link

github-actions bot commented Oct 24, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
5010 3857 77% 0% 🟢

New Files

File Coverage Status
src/backend/api/v1/labels/_init_.py 100% 🟢
src/backend/api/v1/labels/serializers.py 100% 🟢
src/backend/api/v1/labels/urls.py 100% 🟢
src/backend/api/v1/labels/views.py 100% 🟢
src/backend/api/v1/organizations/_init_.py 100% 🟢
src/backend/api/v1/organizations/serializers.py 100% 🟢
src/backend/api/v1/organizations/urls.py 100% 🟢
src/backend/api/v1/organizations/views.py 100% 🟢
src/backend/api/v1/projects/_init_.py 100% 🟢
src/backend/api/v1/projects/serializers.py 100% 🟢
src/backend/api/v1/projects/urls.py 100% 🟢
src/backend/api/v1/projects/views.py 100% 🟢
TOTAL 100% 🟢

Modified Files

File Coverage Status
src/backend/api/v1/report/views.py 94% 🟢
src/backend/api/v1/template/serializers.py 100% 🟢
src/backend/api/v1/template/views.py 100% 🟢
src/backend/api/v1/template_options/serializers.py 100% 🟢
src/backend/api/v1/template_options/views.py 96% 🟢
src/backend/api/v1/urls.py 100% 🟢
src/backend/tests/unit/test_views.py 99% 🟢
TOTAL 98% 🟢

updated for commit: ec66d6e by action🐍

@AlexSCorey
Copy link
Member

@kcagran do you have an issue that is tracking this work?

@AlexSCorey AlexSCorey self-requested a review October 26, 2025 16:11
Copy link
Member

@AlexSCorey AlexSCorey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start. I haven't spun up the code locally yet, as I just had time to look at the code. I've left a few questions, and found some things in the code we need to address.

@kcagran
Copy link
Contributor Author

kcagran commented Oct 27, 2025

@kcagran do you have an issue that is tracking this work?

No, we don't have any at the moment, This PR is a result of https://aap2-prod-bastion-us-west-2.ops.demo.redhat.com:8447/, where initial loading takes 30+s. At the previous sync it was announced that @Priya would create a jira ticket regarding this.

@kcagran kcagran requested a review from AlexSCorey October 27, 2025 09:50
@kcagran kcagran changed the title Optimize initial loading AAP-57069 Optimize initial loading Oct 29, 2025
@kcagran
Copy link
Contributor Author

kcagran commented Oct 29, 2025

@kcagran do you have an issue that is tracking this work?

AAP-57069

@SherinV SherinV requested a review from cshiels-ie October 29, 2025 12:36
@kcagran kcagran force-pushed the optimize-initial-loading branch 7 times, most recently from ff086f8 to 627bee6 Compare November 5, 2025 04:56
@kcagran kcagran force-pushed the optimize-initial-loading branch from 627bee6 to 3173dad Compare November 6, 2025 05:46
@kcagran kcagran force-pushed the optimize-initial-loading branch from 3173dad to ad511ab Compare November 6, 2025 05:57
@AlexSCorey
Copy link
Member

cursor review

@kcagran kcagran force-pushed the optimize-initial-loading branch from 5caec20 to ec66d6e Compare November 11, 2025 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants