change_reports
¶
CSV/HTML report generation and track data management for music library operations.
Handles change reports (genres, years, naming), track list persistence with synchronization, and HTML analytics with performance metrics. Uses CacheServiceProtocol for album year caching.
ChangeType
¶
Enumeration of change types.
Key
¶
Enumeration of key names for CSV fields.
Format
¶
Enumeration of formatting constants.
Misc
¶
Enumeration of miscellaneous constants.
save_html_report
¶
save_html_report(
events,
call_counts,
success_counts,
decorator_overhead,
config,
console_logger=None,
error_logger=None,
group_successful_short_calls=False,
force_mode=False,
)
Generate an HTML report from the provided analytics data.
Source code in src/metrics/html_reports.py
load_track_list
¶
Load the track list from the CSV file into a dictionary.
The track ID is used as the key. Reads columns: id, name, artist, album, genre, date_added, track_status, year_before_mgu, year_set_by_mgu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_path
|
str
|
Path to the CSV file. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, TrackDict]
|
Dictionary of track dictionaries. |
Source code in src/metrics/track_sync.py
save_track_map_to_csv
¶
Persist the provided track map to CSV using standard field ordering.
Source code in src/metrics/track_sync.py
sync_track_list_with_current
async
¶
sync_track_list_with_current(
all_tracks,
csv_path,
cache_service,
console_logger,
error_logger,
partial_sync=False,
applescript_client=None,
)
Synchronize the current track list with the data in a CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
all_tracks
|
Sequence[TrackDict]
|
List of track dictionaries to sync. |
required |
csv_path
|
str
|
Path to the CSV file. |
required |
cache_service
|
CacheServiceProtocol
|
Cache service protocol for album year caching. |
required |
console_logger
|
Logger
|
Logger for console output. |
required |
error_logger
|
Logger
|
Logger for error output. |
required |
partial_sync
|
bool
|
Whether to perform a partial sync (only update year_set_by_mgu if missing). |
False
|
applescript_client
|
AppleScriptClientProtocol | None
|
AppleScript client for fetching missing track fields. |
None
|
Source code in src/metrics/track_sync.py
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | |
save_to_csv
¶
Save the list of track dictionaries to a CSV file.
Source code in src/metrics/change_reports.py
save_unified_changes_report
¶
save_unified_changes_report(
changes,
file_path,
console_logger,
error_logger,
compact_mode=False,
)
Pretty-print change summary to console and optionally persist full CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
changes
|
list[dict[str, Any]]
|
List of change records |
required |
file_path
|
str | None
|
Path to save CSV report (None to skip file saving) |
required |
console_logger
|
Logger
|
Logger for console output |
required |
error_logger
|
Logger
|
Logger for errors |
required |
compact_mode
|
bool
|
If True, display changes in compact format with arrows |
False
|
Source code in src/metrics/change_reports.py
save_changes_report
¶
save_changes_report(
changes,
file_path,
console_logger=None,
error_logger=None,
add_timestamp=False,
compact_mode=True,
)
Save the list of change dictionaries to a CSV file.
By default, it overwrites the specified file. If add_timestamp is True,
it appends a timestamp to the filename to preserve previous reports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
changes
|
Sequence[dict[str, Any] | ChangeLogEntry]
|
List of change dictionaries or ChangeLogEntry objects |
required |
file_path
|
str | None
|
Path to save the CSV file (None to skip file saving) |
required |
console_logger
|
Logger | None
|
Logger for console output |
None
|
error_logger
|
Logger | None
|
Logger for errors |
None
|
add_timestamp
|
bool
|
If True, add timestamp to filename |
False
|
compact_mode
|
bool
|
If True, display changes in compact format with yellow highlighting |
True
|