From 778879a3fde2de98dc6ea9664b544057cf0f552c Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Thu, 21 Dec 2023 19:04:09 +0100 Subject: [PATCH] fix: Fixes the thread sorting algorithm --- src/app/services/github.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/services/github.py b/src/app/services/github.py index 9a79c94..4501f94 100644 --- a/src/app/services/github.py +++ b/src/app/services/github.py @@ -266,13 +266,14 @@ def arrange_in_threads(comments: List[Dict[str, Any]]) -> List[List[int]]: _thread = [_id] unused_nodes.remove(_id) while isinstance(next_map.get(_thread[-1]), int): - _thread.append(next_map[_thread[-1]]) unused_nodes.remove(next_map[_thread[-1]]) + _thread.append(next_map[_thread[-1]]) while isinstance(prev_map.get(_thread[0]), int): - _thread.insert(0, prev_map[_thread[0]]) unused_nodes.remove(prev_map[_thread[0]]) + _thread.insert(0, prev_map[_thread[0]]) threads.append(_thread) + # Sort threads by the ID of the first comment return sorted(threads, key=itemgetter(0)) def fetch_pull_comments_from_repo(