Skip to content

Conversation

@JadeCara
Copy link
Contributor

@JadeCara JadeCara commented Dec 1, 2025

Ticket ENG-1974

Description Of Changes

🎯 As a Fides user I want to be able to filter my results and then act on them, so that I can perform actions on many pages of results instead of having to go 1 by 1.

AC:

  • Existing bulk action endpoints accept all the same filters as the search endpoint and apply the actions to the results.
  • Existing bulk action endpoints accept a list of exclude_ids to be excluded from the actions
  • Implementation reuses patterns for bulk actions used in the action center

This PR adds helper functions get the request ids from either a list or the filters being passed in. There is also a small re-organization of some functionality with the goal of providing better separation of concerns.

Code Changes

  • src/fides/api/api/v1/endpoints/privacy_request_endpoints.py: adds the helper functions
  • src/fides/service/privacy_request/privacy_request_filter_query_util.py
  • src/fides/service/privacy_request/privacy_request_download_csv.py
  • tests/serive/privacy_request/test_privacy_request_filter_query_utility.py tests the new helper functions

PRs in this chain:

Steps to Confirm

  1. There should be no change in current functionality. Right now the front end passes back a list for all bulk functions so any tests with the front end should work exactly the same.

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

@vercel
Copy link

vercel bot commented Dec 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
fides-plus-nightly Ignored Ignored Preview Dec 8, 2025 8:19pm
fides-privacy-center Ignored Ignored Dec 8, 2025 8:19pm

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 91.48936% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.30%. Comparing base (366b798) to head (821e823).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ice/privacy_request/privacy_request_query_utils.py 88.17% 9 Missing and 2 partials ⚠️
.../api/api/v1/endpoints/privacy_request_endpoints.py 92.30% 1 Missing and 1 partial ⚠️
...ce/privacy_request/privacy_request_csv_download.py 96.42% 0 Missing and 2 partials ⚠️
...service/privacy_request/privacy_request_service.py 92.30% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (91.48%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7051      +/-   ##
==========================================
+ Coverage   87.29%   87.30%   +0.01%     
==========================================
  Files         530      532       +2     
  Lines       34890    34936      +46     
  Branches     4046     4048       +2     
==========================================
+ Hits        30457    30502      +45     
- Misses       3551     3552       +1     
  Partials      882      882              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

JadeCara and others added 7 commits December 1, 2025 13:39
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@JadeCara JadeCara marked this pull request as ready for review December 1, 2025 20:43
@JadeCara JadeCara requested a review from a team as a code owner December 1, 2025 20:43
@JadeCara JadeCara requested review from erosselli and removed request for a team December 1, 2025 20:43
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 1, 2025

Greptile Overview

Greptile Summary

Extracts privacy request filtering, sorting, and CSV download logic from endpoints into service layer utilities, following architectural best practices.

Major changes:

  • Created privacy_request_query_utils.py with filter_privacy_request_queryset(), sort_privacy_request_queryset(), and resolve_request_ids_from_filters() helper functions
  • Created privacy_request_csv_download.py to isolate CSV generation logic
  • Added facade methods in PrivacyRequestService to provide clean API for endpoints
  • Refactored endpoint functions to use service layer, removing ~400 lines of duplicated code
  • Added comprehensive unit tests for new utility functions

The refactoring maintains backward compatibility and sets foundation for bulk filtered DSR actions in subsequent PRs.

Confidence Score: 5/5

  • This PR is safe to merge - clean refactoring that extracts business logic to service layer with comprehensive test coverage
  • Well-structured refactoring following established patterns, moving logic from endpoints to service layer. No functionality changes, only reorganization. Comprehensive unit tests verify helper functions work correctly.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/fides/service/privacy_request/privacy_request_query_utils.py 5/5 Extracted filtering, sorting, and ID resolution logic from endpoints into reusable utility functions - clean refactoring following the service layer pattern
src/fides/service/privacy_request/privacy_request_csv_download.py 5/5 Extracted CSV download logic from endpoints into dedicated module - clean separation of concerns
src/fides/service/privacy_request/privacy_request_service.py 5/5 Added facade methods to delegate to utility functions, providing a clean API for endpoints to use service layer
src/fides/api/api/v1/endpoints/privacy_request_endpoints.py 5/5 Refactored to use service layer instead of direct DB access, removing ~400 lines of duplicated filtering/sorting/CSV logic
tests/service/privacy_request/test_privacy_request_query_utility.py 5/5 Comprehensive unit tests for resolve_request_ids_from_filters covering explicit IDs, filters, exclusions, and edge cases

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@JadeCara
Copy link
Contributor Author

JadeCara commented Dec 1, 2025

@greptile please review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Base automatically changed from ENG-1974-update-service-to-handle-bulk-ops to main December 8, 2025 15:42
@JadeCara
Copy link
Contributor Author

JadeCara commented Dec 8, 2025

@greptile please review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@JadeCara JadeCara requested a review from erosselli December 8, 2025 19:30
Copy link
Contributor

@erosselli erosselli left a comment

Choose a reason for hiding this comment

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

Thanks for tackling the refactor!! ❤️

@@ -1,10 +1,8 @@
# pylint: disable=too-many-branches,too-many-lines, too-many-statements
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can remove any of these or if they're still needed.... maybe one day we'll be able to remove them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed two of them!

@JadeCara JadeCara enabled auto-merge December 8, 2025 20:23
@JadeCara JadeCara added this pull request to the merge queue Dec 8, 2025
@JadeCara JadeCara removed this pull request from the merge queue due to a manual request Dec 8, 2025
@JadeCara JadeCara added this pull request to the merge queue Dec 9, 2025
Merged via the queue into main with commit 326a4cc Dec 9, 2025
67 of 69 checks passed
@JadeCara JadeCara deleted the 1974-helper-functions branch December 9, 2025 12:34
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