Skip to content
This repository was archived by the owner on Jan 26, 2023. It is now read-only.

Commit 9f818b6

Browse files
author
irsol
committed
Get rid of like in sql queries
1 parent 33a3139 commit 9f818b6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

log-analysis/logdb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def top_three_articles():
4040
select
4141
articles.title as "Title",
4242
count(*) as "Views"
43-
from articles, log
44-
where log.path like concat('%', articles.slug)
45-
group by articles.title
43+
from log join articles
44+
on log.path = concat('/article/', articles.slug)
45+
group by "Title"
4646
order by "Views" desc
4747
limit 3;
4848
"""
@@ -65,7 +65,7 @@ def top_authors():
6565
count(*) as "Views"
6666
from authors, articles, log
6767
where authors.id = articles.author
68-
and log.path like concat('%', articles.slug)
68+
and log.path = concat('/article/', articles.slug)
6969
group by authors.name
7070
order by "Views" desc
7171
limit 4;

0 commit comments

Comments
 (0)