commit a2607cd721bf2828c29b3b0dc65573f8bc1fb753
parent 6ea24fffbb8968a5cb606fd9fd09dc918310dc10
Author: Natalie Pendragon <natpen@natpen.net>
Date: Tue, 28 Jul 2020 08:56:01 -0400
[threads] Fix thread ordering
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/build_threads.py b/scripts/build_threads.py
@@ -51,7 +51,7 @@ ORDER BY l.is_cross_host_like, p_to.url ASC""", u, f"{u}/", resource.normalized_
return
except ThreadPage.DoesNotExist:
pass
- full_thread = recurse_thread(resource, "1", first_seen, page_id, content)
+ full_thread = recurse_thread(resource, "001", first_seen, page_id, content)
# Deduplicate
full_thread.reverse()
@@ -74,7 +74,7 @@ ORDER BY l.is_cross_host_like, p_to.url ASC""", u, f"{u}/", resource.normalized_
friendly_author=m[0].get_friendly_author(m[4]),
friendly_title=m[0].get_friendly_title(m[4]),
)
- print(" -> [{:<11}] [{}] {}".format(m[1], m[2], m[0].fetchable_url))
+ print(" -> [{:<15}] [{}] {}".format(m[1], m[2], m[0].fetchable_url))
def recurse_thread(resource, path, first_seen, page_id, content, current_chain=[]):
@@ -96,7 +96,7 @@ WHERE p_to.url IN (?, ?)
AND p_from.normalized_url != ?
AND c.status == 20
GROUP BY p_from.normalized_url
-ORDER BY l.is_cross_host_like, p_from.url ASC""", u, f"{u}/", resource.normalized_url)
+ORDER BY l.is_cross_host_like, first_seen ASC""", u, f"{u}/", resource.normalized_url)
threadable_child_index = 1
new_thread_members = [(
resource,
@@ -112,7 +112,7 @@ ORDER BY l.is_cross_host_like, p_from.url ASC""", u, f"{u}/", resource.normalize
# stack - it means they're circular linking
if any(r for r in current_chain if r.normalized_url == resource.normalized_url):
continue
- child_path = f"{path}.{threadable_child_index}"
+ child_path = f"{path:0>3}.{threadable_child_index:03}"
new_thread_members.extend(recurse_thread(
child_resource,
child_path,