Repository navigation
feat: show more detailed information about stacks before studying - #48
Merged
Merged
Conversation
Added a new method `GetAllStackSummariesAsync` to the `IStacksRepository` interface for asynchronously retrieving all stack summaries. Implemented the method in the `StacksRepository` class with logging for successful retrieval and error handling for SQL and general exceptions, ensuring robust failure management.
Updated the IUserInteractionService interface to include a new method, GetStack(List<StackSummaryDto> stackSummaryDtos), for retrieving a stack based on a list of StackSummaryDto objects. The UserInteractionService class has been modified to implement this method, allowing users to select a stack from the provided list and returning the selected stack's name.
Updated the `IStacksService` interface to include a new method, `GetAllStackSummariesAsync`, which returns a `Task<Result<List<StackSummaryDto>>>` for fetching stack summaries. Implemented this method in the `StacksService` class, which logs the operation's start, retrieves stack summaries from the repository, handles potential errors, and logs the count of retrieved summaries before returning the result.
Added a new method `GetStackToStudyAsync` to the `IStacksService` interface, enabling retrieval of a user-selected stack for study. Implemented the method in the `StacksService` class, which includes logging, error handling for stack retrieval, and user interaction for stack selection. This enhances the functionality of the service by allowing users to easily choose and set a stack for their study sessions.
The method `StudyAsync` in the `Menu` class has been modified to change the way stack data is retrieved. It now calls `_stacksController.GetAllStackSummariesAsync()` to obtain and display a summary of all stacks using `DataVisualizer.ShowStacksSummary()`. After displaying the summaries, it retrieves a specific stack to study with `_stacksController.GetStackToStudyAsync()`.
Introduces a new localized string resource for SQL queries related to stack summaries. A new property `GetAllStackSummaries` is added in `SqlScripts.Designer.cs` to retrieve a SQL query string that summarizes the number of due cards and total cards for each stack. The corresponding entry is added in `SqlScripts.resx`, linking it to the new SQL script file `GetAllStackSummaries.sql`.
The code in `DataVisualizer.cs` has been updated to include a new method called `ShowStacksSummary`. This method takes a list of `StackSummaryDto` objects and displays a summary of stacks in a formatted table using the Spectre.Console library. If the list is empty, it outputs a message indicating that no stacks were found. Additionally, the method adds columns for "Name", "Due Cards", and "Total Cards" to the table and populates it with data from the provided stack summaries.
The `StacksController` class in `StacksController.cs` has been updated to include two new asynchronous methods: `GetAllStackSummariesAsync` and `GetStackToStudyAsync`. These methods call corresponding methods in the `_stacksService` to retrieve stack summaries and a stack to study, respectively.
Introduced a new record class `StackSummaryDto` with properties for `Name`, `TotalCards`, and `DueCards` to enhance the data structure for stack information.
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 retrieving stack summaries and a specific stack to study. Additionally. users can see more detailed information about stacks before studying (due and total cards).
Changes
StacksController: AddedGetAllStackSummariesAsyncandGetStackToStudyAsyncmethods.IStacksRepository: IntroducedGetAllStackSummariesAsyncmethod for stack summary retrieval.StacksRepository: ImplementedGetAllStackSummariesAsyncwith logging and error handling.DataVisualizer: AddedShowStacksSummarymethod to display stack summaries in a table format.Stack: CreatedStackSummaryDtorecord class to encapsulate stack summary information.