Skip to content

feat: show more detailed information about stacks before studying - #48

Merged
Dejmenek merged 9 commits into
mainfrom
46-show-stack-info-before-studying
Sep 5, 2025
Merged

Dejmenek merged 9 commits into
mainfrom
46-show-stack-info-before-studying

Conversation

@Dejmenek

@Dejmenek Dejmenek commented Sep 5, 2025

Copy link
Copy Markdown
Owner

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: Added GetAllStackSummariesAsync and GetStackToStudyAsync methods.
  • IStacksRepository: Introduced GetAllStackSummariesAsync method for stack summary retrieval.
  • StacksRepository: Implemented GetAllStackSummariesAsync with logging and error handling.
  • DataVisualizer: Added ShowStacksSummary method to display stack summaries in a table format.
  • Stack: Created StackSummaryDto record class to encapsulate stack summary information.

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.
@Dejmenek Dejmenek linked an issue Sep 5, 2025 that may be closed by this pull request
@Dejmenek
Dejmenek merged commit 4730945 into main Sep 5, 2025
2 checks passed
@Dejmenek
Dejmenek deleted the 46-show-stack-info-before-studying branch September 5, 2025 15:29
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.

Show Stack Info Before Studying

1 participant