Skip to content

feat: adapt repositories for spaced repetition system - #38

Merged
Dejmenek merged 6 commits into
mainfrom
35-update-repositories
Sep 3, 2025
Merged

Dejmenek merged 6 commits into
mainfrom
35-update-repositories

Conversation

@Dejmenek

@Dejmenek Dejmenek commented Sep 3, 2025

Copy link
Copy Markdown
Owner

Summary

This pull request introduces new methods for updating card progress and retrieving cards to study based on stack ID.

Changes

  • ICardsRepository.cs: Added UpdateCardProgress method for updating card progress.
  • IStacksRepository.cs: Added GetCardsToStudyByStackIdAsync method for retrieving cards due for study.
  • CardsRepository.cs: Implemented UpdateCardProgress with logging and exception handling.
  • StacksRepository.cs: Implemented GetCardsToStudyByStackIdAsync with appropriate error handling.
  • SqlScripts.resx: Updated to include new SQL scripts for the added functionalities.

Added a new method `UpdateCardProgress` to the `ICardsRepository` interface, enabling updates to a card's progress with the card ID, new box number, and next review date. Implemented the method in the `CardsRepository` class, which includes logging, SQL execution for updating the database, and error handling for both SQL and general exceptions, ensuring appropriate results are returned based on the operation's success or failure.
Added a new method `GetCardsToStudyByStackIdAsync` to the `IStacksRepository` interface and implemented it in the `StacksRepository` class. This method retrieves a list of cards to study based on a specified stack ID. It handles various card types (Flashcard, Cloze, FillIn, MultipleChoice) and includes error handling for SQL exceptions and general exceptions, logging relevant information throughout the process.
Added a new SQL query to select all columns from the `Cards` table. This query filters results based on a specified `StackId` and ensures that only cards with a `NextReviewDate` that is less than or equal to the current date are retrieved. This enhancement improves the ability to study relevant cards based on their review schedule.
Added an SQL update statement to the `Cards` table that sets the `Box` and `NextReviewDate` fields based on the provided parameters. This change allows for updating card progress effectively by specifying the card's `Id`.
Added a new error constant `UpdateCardProgressFailed` to the `CardsErrors` class in the `FlashcardsErrors.cs` file. This constant provides a specific error message for failures encountered when updating card progress, enhancing error handling and user feedback in the application.
Added two new localized string properties, `GetCardsToStudyByStackId` and `UpdateCardProgress`, to the `SqlScripts.Designer.cs` file. Each property includes a summary comment detailing the corresponding SQL query. The `GetCardsToStudyByStackId` property retrieves a command to select cards by stack ID, while `UpdateCardProgress` updates a card's progress. Corresponding entries were also added to the `SqlScripts.resx` file to link these properties to their respective SQL script files.
@Dejmenek Dejmenek linked an issue Sep 3, 2025 that may be closed by this pull request
@Dejmenek
Dejmenek merged commit 2bf7f93 into main Sep 3, 2025
2 checks passed
@Dejmenek
Dejmenek deleted the 35-update-repositories branch September 3, 2025 19:11
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.

Update Repositories

1 participant