Skip to content

Commit 02bd9ec

Browse files
committed
fixed dockerfile [17]
1 parent 3caab12 commit 02bd9ec

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

scheme.sql

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ALTER DATABASE db_forum OWNER TO forum_admin;
77
\connect db_forum
88

99
CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public;
10+
CREATE EXTENSION IF NOT EXISTS intarray WITH SCHEMA public;
1011

1112
SET ROLE forum_admin;
1213

src/github.com/pdmitrya/goExample/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ func main() {
3232
router.POST("/service/clear", routes.ClearService)
3333
router.GET("/service/status", routes.StatusService)
3434

35-
log.Fatal(http.ListenAndServe(":5000", router))
35+
log.Fatal(http.ListenAndServe(":5001", router))
3636
}

src/github.com/pdmitrya/goExample/routes/threadPosts.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func ThreadPosts(w http.ResponseWriter, r *http.Request, p map[string]string) {
6868
P.thread_id,
6969
P.parent AS parentId,
7070
P.id,
71-
P.id::text AS path
71+
intset(P.id) AS path
7272
FROM Post P
7373
JOIN Forum_User U on P.user_id = U.id
7474
JOIN Thread T on P.thread_id = T.id
@@ -89,7 +89,7 @@ func ThreadPosts(w http.ResponseWriter, r *http.Request, p map[string]string) {
8989
P.thread_id,
9090
P.parent,
9191
P.id,
92-
CONCAT_WS('.', PT.path, P.id::text)
92+
PT.path + P.id
9393
FROM Post P
9494
INNER JOIN PostParentTree PT ON P.parent = PT.id
9595
JOIN Forum_User U on P.user_id = U.id
@@ -113,9 +113,9 @@ func ThreadPosts(w http.ResponseWriter, r *http.Request, p map[string]string) {
113113
}
114114

115115
if desc == "true" {
116-
queryBuilder.WriteString(`ORDER BY substring(path from '^\d+') DESC, substring(path from '\..*$') DESC NULLS LAST, path COLLATE "C" DESC `)
116+
queryBuilder.WriteString(`ORDER BY subarray(path, 1, 1) DESC, subarray(path, 2) DESC NULLS LAST, path DESC `)
117117
} else {
118-
queryBuilder.WriteString(`ORDER BY path COLLATE "C" ASC, created ASC, id ASC `)
118+
queryBuilder.WriteString(`ORDER BY path ASC, created ASC, id ASC `)
119119
}
120120

121121
if len(limit) > 0 {
@@ -195,7 +195,7 @@ func ThreadPosts(w http.ResponseWriter, r *http.Request, p map[string]string) {
195195
if desc == "true" {
196196
queryBuilder.WriteString(`ORDER BY substring(path from '^\d+') DESC, substring(path from '\..*$') ASC NULLS FIRST, path COLLATE "C" DESC `)
197197
} else {
198-
queryBuilder.WriteString("ORDER BY path ASC, created ASC, id ASC ")
198+
queryBuilder.WriteString(`ORDER BY path COLLATE "C" ASC, created ASC, id ASC `)
199199
}
200200

201201
}

0 commit comments

Comments
 (0)