Rename func

This commit is contained in:
Jan-Lukas Else 2021-01-30 19:35:48 +01:00
parent a9e22fc267
commit a840879d48
2 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import (
func serveBlogStats(blog, statsPath string) func(w http.ResponseWriter, r *http.Request) { func serveBlogStats(blog, statsPath string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
// Build query // Build query
query, params := buildQuery(&postsRequestConfig{ query, params := buildPostsQuery(&postsRequestConfig{
blog: blog, blog: blog,
status: statusPublished, status: statusPublished,
}) })

View File

@ -272,7 +272,7 @@ type postsRequestConfig struct {
randomOrder bool randomOrder bool
} }
func buildQuery(config *postsRequestConfig) (query string, args []interface{}) { func buildPostsQuery(config *postsRequestConfig) (query string, args []interface{}) {
args = []interface{}{} args = []interface{}{}
defaultSelection := "select p.path as path, coalesce(content, '') as content, coalesce(published, '') as published, coalesce(updated, '') as updated, coalesce(blog, '') as blog, coalesce(section, '') as section, coalesce(status, '') as status, coalesce(parameter, '') as parameter, coalesce(value, '') as value " defaultSelection := "select p.path as path, coalesce(content, '') as content, coalesce(published, '') as published, coalesce(updated, '') as updated, coalesce(blog, '') as blog, coalesce(section, '') as section, coalesce(status, '') as status, coalesce(parameter, '') as parameter, coalesce(value, '') as value "
postsTable := "posts" postsTable := "posts"
@ -344,7 +344,7 @@ func buildQuery(config *postsRequestConfig) (query string, args []interface{}) {
} }
func getPosts(config *postsRequestConfig) (posts []*post, err error) { func getPosts(config *postsRequestConfig) (posts []*post, err error) {
query, queryParams := buildQuery(config) query, queryParams := buildPostsQuery(config)
rows, err := appDbQuery(query, queryParams...) rows, err := appDbQuery(query, queryParams...)
if err != nil { if err != nil {
return nil, err return nil, err
@ -378,7 +378,7 @@ func getPosts(config *postsRequestConfig) (posts []*post, err error) {
} }
func countPosts(config *postsRequestConfig) (count int, err error) { func countPosts(config *postsRequestConfig) (count int, err error) {
query, params := buildQuery(config) query, params := buildPostsQuery(config)
query = "select count(distinct path) from (" + query + ")" query = "select count(distinct path) from (" + query + ")"
row, err := appDbQueryRow(query, params...) row, err := appDbQueryRow(query, params...)
if err != nil { if err != nil {