Repository navigation
feat: adapt repositories for spaced repetition system - #38
Merged
Merged
Conversation
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.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces new methods for updating card progress and retrieving cards to study based on stack ID.
Changes
ICardsRepository.cs: AddedUpdateCardProgressmethod for updating card progress.IStacksRepository.cs: AddedGetCardsToStudyByStackIdAsyncmethod for retrieving cards due for study.CardsRepository.cs: ImplementedUpdateCardProgresswith logging and exception handling.StacksRepository.cs: ImplementedGetCardsToStudyByStackIdAsyncwith appropriate error handling.SqlScripts.resx: Updated to include new SQL scripts for the added functionalities.