aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2024-01-22 18:08:12 +0100
committerPřemysl Eric Janouch <p@janouch.name>2024-01-22 19:51:13 +0100
commit4f174972e3f3040f78f87f2b96a0e7bfc94fed6e (patch)
treed0a748e90d93a6e2399ff28162543b9fa9e9eedd
parentf9f22ba42c1f72540fd28576eb568142da7cd03c (diff)
downloadgallery-4f174972e3f3040f78f87f2b96a0e7bfc94fed6e.tar.gz
gallery-4f174972e3f3040f78f87f2b96a0e7bfc94fed6e.tar.xz
gallery-4f174972e3f3040f78f87f2b96a0e7bfc94fed6e.zip
gallery: move out a query from CTE
-rw-r--r--main.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/main.go b/main.go
index 408b7ea..7c9aceb 100644
--- a/main.go
+++ b/main.go
@@ -964,13 +964,6 @@ const searchCTE = `WITH
FROM tag_assignment AS ta
JOIN image AS i ON i.sha1 = ta.sha1
WHERE ta.tag = ?
- ),
- supertags(tag, space, name) AS (
- SELECT DISTINCT ta.tag, ts.name, t.name
- FROM tag_assignment AS ta
- JOIN matches AS m ON m.sha1 = ta.sha1
- JOIN tag AS t ON ta.tag = t.id
- JOIN tag_space AS ts ON ts.id = t.space
)
`
@@ -1010,7 +1003,11 @@ type webTagSupertag struct {
func getTagSupertags(tag int64) (result map[int64]*webTagSupertag, err error) {
rows, err := db.Query(searchCTE+`
- SELECT tag, space, name FROM supertags`, tag)
+ SELECT DISTINCT ta.tag, ts.name, t.name
+ FROM tag_assignment AS ta
+ JOIN matches AS m ON m.sha1 = ta.sha1
+ JOIN tag AS t ON ta.tag = t.id
+ JOIN tag_space AS ts ON ts.id = t.space`, tag)
if err != nil {
return nil, err
}