Skip to content

use batch get event donors by id#57

Merged
PCBZ merged 3 commits intomainfrom
optimize_export_donor
Apr 23, 2025
Merged

use batch get event donors by id#57
PCBZ merged 3 commits intomainfrom
optimize_export_donor

Conversation

@PCBZ
Copy link
Copy Markdown
Owner

@PCBZ PCBZ commented Apr 23, 2025

No description provided.

@PCBZ PCBZ self-assigned this Apr 23, 2025
@PCBZ PCBZ added the bug Something isn't working label Apr 23, 2025
@PCBZ PCBZ merged commit d128bf2 into main Apr 23, 2025
2 checks passed
github-actions Bot pushed a commit that referenced this pull request Apr 23, 2025
PCBZ added a commit that referenced this pull request Apr 24, 2025
use batch get event donors by id
@PCBZ PCBZ requested a review from Copilot April 28, 2025 18:20
@PCBZ PCBZ added enhancement New feature or request and removed bug Something isn't working labels Apr 28, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a batch retrieval mechanism for event donor data by ID to improve performance and consistency. Key changes include:

  • Updating the donor export service to fetch donor IDs first and then retrieve donor data in one batch.
  • Adding new server endpoints: one for obtaining donor IDs for an event and another for fetching donor data in batch.
  • Minor UI refinement in the donors component to trim organization names before display.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
client/src/services/donorService.js Refactored exportEventDonorsToCsv to use batch donor fetching via a new helper.
client/src/components/donors/Donors.jsx Updated organization name rendering to trim whitespace before display.
Server/src/routes/event.js Added a new GET endpoint to retrieve donor IDs for a given event.
Server/src/routes/donor.js Added a new POST endpoint to fetch donors in batch based on provided donor IDs.

<div className="donor-profile-simple">
<h4>{selectedDonor.donor?.firstName || selectedDonor.firstName} {selectedDonor.donor?.lastName || selectedDonor.lastName}</h4>
{(selectedDonor.donor?.organizationName || selectedDonor.organizationName) && (
{((selectedDonor.donor?.organizationName || selectedDonor.organizationName)?.trim()) && (
Copy link

Copilot AI Apr 28, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider handling the case where the organization name consists only of whitespace. If the trimmed value is an empty string, you might want to provide a fallback or avoid rendering the element.

Suggested change
{((selectedDonor.donor?.organizationName || selectedDonor.organizationName)?.trim()) && (
{((selectedDonor.donor?.organizationName || selectedDonor.organizationName)?.trim().length > 0) && (

Copilot uses AI. Check for mistakes.
export const getBatchDonors = async (donorIds) => {
try {
const result = await fetchWithAuth(`/api/donors/batch`, {
method: 'POST',
Copy link

Copilot AI Apr 28, 2025

Choose a reason for hiding this comment

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

Ensure that fetchWithAuth includes the appropriate 'Content-Type': 'application/json' header for POST requests so that the JSON payload is processed correctly by the server.

Suggested change
method: 'POST',
method: 'POST',
headers: {
'Content-Type': 'application/json'
},

Copilot uses AI. Check for mistakes.
@PCBZ PCBZ added optimization An optimization and removed enhancement New feature or request labels Apr 28, 2025
@PCBZ PCBZ deleted the optimize_export_donor branch April 29, 2025 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimization An optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants