Add added option to _print_edited_summary (#1366)

* Add added option to _print_edited_summary

* Add tests for counts of entries added, modified, and deleted

* Add test for modifying an entry rather than replacing it

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
Piero Lescano 2021-11-20 14:47:56 -05:00 committed by GitHub
parent ffc8bdd5f1
commit ba3fd2202f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 92 additions and 1 deletions

View file

@ -275,13 +275,18 @@ def _edit_search_results(config, journal, old_entries, **kwargs):
def _print_edited_summary(journal, old_stats, **kwargs):
stats = {
"added": len(journal) - old_stats["count"],
"deleted": old_stats["count"] - len(journal),
"modified": len([e for e in journal.entries if e.modified]),
}
prompts = []
if stats["deleted"]:
if stats["added"] > 0:
prompts.append(f"{stats['added']} {_pluralize_entry(stats['added'])} added")
stats["modified"] -= stats["added"]
if stats["deleted"] > 0:
prompts.append(
f"{stats['deleted']} {_pluralize_entry(stats['deleted'])} deleted"
)