Load status ancestors
This commit is contained in:
parent
14ac8bb1b5
commit
c821aaa18e
|
@ -11,6 +11,13 @@
|
||||||
|
|
||||||
<div class="thread-parent is-relative block">
|
<div class="thread-parent is-relative block">
|
||||||
<div class="thread">
|
<div class="thread">
|
||||||
|
{% for parent in ancestors %}
|
||||||
|
{% if parent %}
|
||||||
|
<div class="block">
|
||||||
|
{% include 'snippets/status/status.html' with status=parent %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
<div class="is-main block">
|
<div class="is-main block">
|
||||||
{% include 'snippets/status/status.html' with status=status main=True %}
|
{% include 'snippets/status/status.html' with status=status main=True %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -114,6 +114,27 @@ class Status(View):
|
||||||
).values_list("id", flat=True)
|
).values_list("id", flat=True)
|
||||||
visible_thread = list(visible_thread)
|
visible_thread = list(visible_thread)
|
||||||
|
|
||||||
|
ancestors = models.Status.objects.select_subclasses().raw(
|
||||||
|
"""
|
||||||
|
WITH RECURSIVE get_thread(depth, id, path) AS (
|
||||||
|
|
||||||
|
SELECT 1, st.id, ARRAY[st.id]
|
||||||
|
FROM bookwyrm_status st
|
||||||
|
WHERE id = '%s' AND id = ANY(%s)
|
||||||
|
|
||||||
|
UNION
|
||||||
|
|
||||||
|
SELECT (gt.depth + 1), st.reply_parent_id, path || st.id
|
||||||
|
FROM get_thread gt, bookwyrm_status st
|
||||||
|
|
||||||
|
WHERE st.id = gt.id AND depth < 5 AND st.id = ANY(%s)
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
SELECT * FROM get_thread ORDER BY path DESC;
|
||||||
|
""",
|
||||||
|
params=[status.reply_parent_id or 0, visible_thread, visible_thread],
|
||||||
|
)
|
||||||
children = models.Status.objects.select_subclasses().raw(
|
children = models.Status.objects.select_subclasses().raw(
|
||||||
"""
|
"""
|
||||||
WITH RECURSIVE get_thread(depth, id, path) AS (
|
WITH RECURSIVE get_thread(depth, id, path) AS (
|
||||||
|
@ -141,6 +162,7 @@ class Status(View):
|
||||||
**{
|
**{
|
||||||
"status": status,
|
"status": status,
|
||||||
"children": children,
|
"children": children,
|
||||||
|
"ancestors": ancestors,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "feed/status.html", data)
|
return TemplateResponse(request, "feed/status.html", data)
|
||||||
|
|
Loading…
Reference in New Issue