Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
refactor: Sort by processedAt and createdAt
Browse files Browse the repository at this point in the history
  • Loading branch information
tklein1801 committed Dec 5, 2023
1 parent d49ed7b commit a179dc4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public ResponseEntity<ApiResponse<List<Transaction>>> getTransactionsByUuid(@Req
}
}

List<Transaction> transactions = transactionRepository.findAllByOwnerOrderByProcessedAtDesc(user.get());
List<Transaction> transactions = transactionRepository.findAllByOwnerOrderByProcessedAtDescAndCreatedAtDesc(user.get());
return ResponseEntity
.status(HttpStatus.OK)
.body(new ApiResponse<>(transactions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public interface TransactionRepository extends JpaRepository<Transaction, Long> {
List<Transaction> findAllByOwner(User owner);
List<Transaction> findAllByOwnerOrderByProcessedAtDesc(User owner);
List<Transaction> findAllByOwnerOrderByProcessedAtDescAndCreatedAtDesc(User owner);
@Query(value = "select * from f_get_daily_transactions(:start_date, :end_date, :requested_data, :user_id)", nativeQuery = true)
List<Object[]> fetchDailyTransactions(
@Param("start_date") LocalDate startDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void testGetTransaction_WithSupportUserSuccess() throws JsonProcessingException

when(userRepository.findById(uuid))
.thenReturn(Optional.of(owner));
when(transactionRepository.findAllByOwner(owner))
when(transactionRepository.findAllByOwnerOrderByProcessedAtDescAndCreatedAtDesc(owner))
.thenReturn(transactionList);

ResponseEntity<ApiResponse<List<Transaction>>> response = transactionController.getTransactionsByUuid(uuid, session);
Expand All @@ -310,7 +310,7 @@ void testGetTransaction_Success() throws JsonProcessingException {

when(userRepository.findById(uuid))
.thenReturn(Optional.of(owner));
when(transactionRepository.findAllByOwner(owner))
when(transactionRepository.findAllByOwnerOrderByProcessedAtDescAndCreatedAtDesc(owner))
.thenReturn(transactionList);

ResponseEntity<ApiResponse<List<Transaction>>> response = transactionController.getTransactionsByUuid(uuid, session);
Expand Down

0 comments on commit a179dc4

Please sign in to comment.