diff --git a/pkg/building/building.go b/pkg/building/building.go index 6d43f678..f9f760d8 100644 --- a/pkg/building/building.go +++ b/pkg/building/building.go @@ -42,13 +42,17 @@ func getRecentPosts() ([]recentPost, error) { SELECT id, board_id FROM DBPREFIXthreads ) t ON t.id = DBPREFIXposts.thread_id LEFT JOIN ( - select post_id, filename FROM DBPREFIXfiles + select post_id, COALESCE(filename,'') as filename FROM DBPREFIXfiles ) f on f.post_id = DBPREFIXposts.id INNER JOIN ( SELECT id, thread_id FROM DBPREFIXposts WHERE is_top_post ) op ON op.thread_id = DBPREFIXposts.thread_id - WHERE DBPREFIXposts.is_deleted = FALSE LIMIT ` + strconv.Itoa(siteCfg.MaxRecentPosts) + WHERE DBPREFIXposts.is_deleted = FALSE` + if !siteCfg.RecentPostsWithNoFile { + query += ` AND f.filename != '' AND f.filename != 'deleted'` + } + query += ` LIMIT ` + strconv.Itoa(siteCfg.MaxRecentPosts) rows, err := gcsql.QuerySQL(query) if err != nil { return nil, err diff --git a/pkg/config/config.go b/pkg/config/config.go index 59e50229..51fdc5d7 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -30,7 +30,7 @@ var ( "SiteName": "Gochan", "MinifyHTML": true, "MinifyJS": true, - "MaxRecentPosts": 3, + "MaxRecentPosts": 12, "EnableAppeals": true, "MaxLogDays": 14, diff --git a/pkg/config/jsonvars_test.go b/pkg/config/jsonvars_test.go index e56b2055..835aa3ad 100644 --- a/pkg/config/jsonvars_test.go +++ b/pkg/config/jsonvars_test.go @@ -107,7 +107,7 @@ const ( "EnableGeoIP": true, "_comment": "set GeoIPDBlocation to cf to use Cloudflare's GeoIP", "GeoIPDBlocation": "/usr/share/GeoIP/GeoIP.dat", - "MaxRecentPosts": 3, + "MaxRecentPosts": 12, "RecentPostsWithNoFile": false, "Verbosity": 0, "EnableAppeals": true, diff --git a/pkg/config/util.go b/pkg/config/util.go index 8212ba66..ee68c928 100644 --- a/pkg/config/util.go +++ b/pkg/config/util.go @@ -160,7 +160,7 @@ func InitConfig(versionStr string) { MaxLogDays: 14, Verbosity: 1, - MaxRecentPosts: 3, + MaxRecentPosts: 12, RecentPostsWithNoFile: false, }, BoardConfig: BoardConfig{ diff --git a/sample-configs/gochan.example.json b/sample-configs/gochan.example.json index 8c14f44f..42181414 100644 --- a/sample-configs/gochan.example.json +++ b/sample-configs/gochan.example.json @@ -88,7 +88,7 @@ "EnableGeoIP": true, "_comment": "set GeoIPDBlocation to cf to use Cloudflare's GeoIP", "GeoIPDBlocation": "/usr/share/GeoIP/GeoIP.dat", - "MaxRecentPosts": 3, + "MaxRecentPosts": 12, "RecentPostsWithNoFile": false, "Verbosity": 0, "EnableAppeals": true,