feat: stats, log, export + CSV and JSON Data Exports#3
Merged
Conversation
Implements GetEntries, GetEntriesByProject, GetEntriesByDateRange, and GetAllProjects methods for retrieving time entries and distinct project names from the database. These methods support filtering by project, date range, and limiting results, improving data access flexibility.
Introduces a new 'log' command to display time tracking history with filtering options for limit, project, today, and week. Integrates with storage to fetch and format entries, showing total tracked time and entry details.
Added detailed comments to the TimeEntry struct and its methods Duration and IsRunning to clarify their purpose and usage.
Introduces an 'export' CLI command to export time entries in CSV or JSON format. Implements internal/export/csv.go and internal/export/json.go for file generation, supporting filtering by date and project.
Introduces a new 'stats' command to display time tracking statistics by day, week, or all-time. Also includes minor formatting fixes in export.go and log.go command definitions.
Added detailed doc comments for ShowPeriodStats and ShowAllTimeStats functions in cmd/stats.go, describing their behavior, aggregation logic, and output. This improves code readability and helps future maintainers understand the purpose and implementation details of these functions.
stats, log, export + CSV and JSON Data Exportsstats, log, export + CSV and JSON Data Exports
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.
This pull request introduces three major new CLI commands—
export,log, andstats—to enhance time tracking functionality, and adds supporting database query methods and export utilities for CSV and JSON formats. It also includes documentation and utility improvements for theTimeEntrymodel. These changes enable users to view, filter, and export their time tracking data with flexible options.New CLI Commands:
exportcommand to output time entries in CSV or JSON format, with options to filter by date or project (cmd/export.go).logcommand to display time entry history, supporting filters for project, today, week, and entry limit (cmd/log.go).statscommand to show time tracking statistics for today, this week, or all time, including per-project breakdown and estimated earnings (cmd/stats.go).Database and Query Enhancements:
Database:GetEntries,GetEntriesByProject,GetEntriesByDateRange, andGetAllProjectsto support flexible data retrieval for the new commands (internal/storage/db.go).Export Utilities:
ToCSVandToJsonfunctions for exporting time entries to CSV and JSON files, respectively (internal/export/csv.go,internal/export/json.go). [1] [2]Model Documentation and Utilities:
TimeEntrystruct and addedIsRunningand improvedDurationmethods for better code clarity and utility (internal/storage/models.go). [1] [2] [3]