Skip to content

Conversation

@vakac995
Copy link
Contributor

feat(donations): add sorting support for public donations endpoint

Closes #{issue number}

Motivation and context

In order to be able to sort on the backend side full data and not only fetched data to the frontend side

In order to be able to sort on the backend side full data and not only fetched data to the frontend side

By adding two new parameters, sortBy and sortDir to the API

Testing

Steps to test

New endpoints

Environment

New environment variables:

  • NEW_ENV_VAR: env var details

New or updated dependencies:

Dependency name Previous version Updated version Details
dependency/name v1.0.0 v2.0.0

Refactor code structure for improved readability and maintainability
- Add sortBy and sortOrder query parameters to listDonationsPublic endpoint
- Support sorting by 'createdAt' or 'amount' fields with 'asc'/'desc' order
- Default sorting: createdAt desc
- Add Swagger API documentation for new parameters

Relates to: #2027
Copilot AI review requested due to automatic review settings January 20, 2026 14:24
@github-actions
Copy link

github-actions bot commented Jan 20, 2026

✅ Tests will run for this PR. Once they succeed it can be merged.

Copy link

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 upgrades the Yarn package manager from version 3.3.0 to 4.12.0 and adds sorting support to the public donations endpoint.

Changes:

  • Updated Yarn package manager to version 4.12.0
  • Added sorting parameters (sortBy and sortOrder) to the donations API endpoint
  • Updated Yarn configuration files to align with the new version

Reviewed changes

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

Show a summary per file
File Description
package.json Updated packageManager field to yarn@4.12.0
apps/api/src/donations/donations.service.ts Added sortBy and sortOrder parameters with validation logic to enable sorting donations
apps/api/src/donations/donations.controller.ts Added API query parameters for sortBy and sortOrder
.yarnrc.yml Updated Yarn configuration for version 4.12.0
.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs Removed plugin file (replaced by version 4.12.0 plugin)
.yarn/plugins/@yarnpkg/plugin-typescript.cjs Removed plugin file (replaced by version 4.12.0 plugin)
.env Removed trailing whitespace from CORPORATE_DONORS_EMAIL line

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// Build orderBy based on sortBy parameter
const validSortFields = ['createdAt', 'amount']
const validSortOrders = ['asc', 'desc']
const orderField = validSortFields.includes(sortBy || '') ? sortBy : 'createdAt'
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

If sortBy is undefined or an empty string, the ternary will evaluate the empty string case and incorrectly assign it to orderField. This should check if sortBy is a valid field or fallback to 'createdAt'.

Copilot uses AI. Check for mistakes.
const validSortFields = ['createdAt', 'amount']
const validSortOrders = ['asc', 'desc']
const orderField = validSortFields.includes(sortBy || '') ? sortBy : 'createdAt'
const orderDirection = validSortOrders.includes(sortOrder || '') ? sortOrder : 'desc'
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

If sortOrder is undefined or an empty string, the ternary will evaluate the empty string case and incorrectly assign it to orderDirection. This should check if sortOrder is a valid direction or fallback to 'desc'.

Copilot uses AI. Check for mistakes.
Copy link
Member

@sashko9807 sashko9807 left a comment

Choose a reason for hiding this comment

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

Would you please revert any yarn changes? If update is needed(not saying it is), lets do so in a separate build

Copy link
Member

Choose a reason for hiding this comment

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

Lets not update/change anything yarn related in this PR.

@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Jan 25, 2026
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Jan 25, 2026
@sashko9807 sashko9807 merged commit 891eb23 into podkrepi-bg:master Jan 26, 2026
9 of 10 checks passed
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.

New design payment drawer

2 participants