Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 AGAIN checkboxes only processing number of page instead of selected #51

Open
immarisabel opened this issue Jul 3, 2023 · 2 comments
Assignees
Labels
⏸ on hold to work on later, no priority

Comments

@immarisabel
Copy link
Owner

immarisabel commented Jul 3, 2023

it is weird... very random.
To revisit later.

@immarisabel immarisabel self-assigned this Jul 3, 2023
@immarisabel immarisabel added the 🐞 bug Something isn't working label Jul 3, 2023
@immarisabel
Copy link
Owner Author

Controller:

            transactionService.batchUpdateCategory(categoryId, transactionsId, pageNumber, pageSize);

@immarisabel
Copy link
Owner Author

Working code on commit fd102b9

 // MANIPULATION

 @Transactional
 public void batchUpdateCategory(Long categoryId, List<Long> transactionIds

/// DELETED.....................................
, int pageNumber, int pageSize
//.............................................................

) {
  CategoryEntity category = categoryRepository.findById(categoryId)
          .orElseThrow(() -> new RuntimeException("Category not found with id " + categoryId));

/// DELETED.....................................
  int startIndex = pageNumber * pageSize;
  int endIndex = Math.min(startIndex + pageSize, transactionIds.size());
  List<Long> paginatedTransactionIds = transactionIds.subList(startIndex, endIndex);
//.............................................................

  List<TransactionEntity> transactions = transactionRepository.findAllById(paginatedTransactionIds);

  log.info("....transactions updated: " + transactions.size());

  for (TransactionEntity transaction : transactions) {
   transaction.getCategories().clear();
   transaction.addCategory(category);
   transactionRepository.save(transaction);
  }
 }

@immarisabel immarisabel added ⏸ on hold to work on later, no priority and removed 🐞 bug Something isn't working labels Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏸ on hold to work on later, no priority
Development

No branches or pull requests

1 participant