From 685a85ca335fe9c9b11f1ab86bb651ebfd993444 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 26 Jul 2023 11:23:40 +0300 Subject: bug: Fix bug where diffs were not computing correctly. --- wqflask/wqflask/metadata_edits.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py index b198c4ad..109ed65e 100644 --- a/wqflask/wqflask/metadata_edits.py +++ b/wqflask/wqflask/metadata_edits.py @@ -586,20 +586,20 @@ def show_history(dataset_id: str = "", name: str = ""): author=author, diff=Edit( field, - data_.get("old"), - data_.get("new"), - "\n".join( - difflib.ndiff( - [data_.get("old") or ""], - [data_.get("new")], - ) - ), - ), - timestamp=timestamp, - ) - ) - if len(diff_data) > 0: - diff_data_ = groupby(diff_data, lambda x: x.timestamp) + data_.get("old") or "", + data_.get("new") or "", + "\n".join(difflib.ndiff( + [str(data_.get("old")) or ""], + [str(data_.get("new")) or ""], + ))), + timestamp=timestamp)) + + if len(diff_data) > 0: + diff_data_ = groupby( + (diff for diff in diff_data if ( + diff.diff.diff.startswith("-") or + diff.diff.diff.startswith("+"))), + lambda x: x.timestamp) return render_template( "edit_history.html", diff=diff_data_, -- cgit v1.2.3