Skip to content

Commit cb62b8a

Browse files
committed
Neater indentation of SQL query, refs simonw#50
1 parent 06e970a commit cb62b8a

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

plugins/template_vars.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,21 @@ async def related_tils(til):
2626
text = multi_spaces.sub(" ", text)
2727
words = list(set(text.lower().strip().split()))
2828
sql = """
29-
select til.topic, til.slug, til.title, til.created, til.html
30-
from til join til_fts on til.rowid = til_fts.rowid
31-
where til_fts match :words
32-
and not (til.slug = :slug and til.topic = :topic)
33-
order by til_fts.rank limit 5
29+
select
30+
til.topic, til.slug, til.title, til.created
31+
from
32+
til
33+
join til_fts on til.rowid = til_fts.rowid
34+
where
35+
til_fts match :words
36+
and not (
37+
til.slug = :slug
38+
and til.topic = :topic
39+
)
40+
order by
41+
til_fts.rank
42+
limit
43+
5
3444
"""
3545
result = await datasette.get_database().execute(
3646
sql,

0 commit comments

Comments
 (0)