diff --git a/contrib/backends/srndv2/src/srnd/database.go b/contrib/backends/srndv2/src/srnd/database.go index b456487..dca83ca 100644 --- a/contrib/backends/srndv2/src/srnd/database.go +++ b/contrib/backends/srndv2/src/srnd/database.go @@ -341,7 +341,7 @@ type Database interface { FindHeaders(group, headername string, lo, hi int64) (ArticleHeaders, error) // count ukko pages - GetUkkoPageCount() (int64, error) + GetUkkoPageCount(perpage int) (int64, error) } func NewDatabase(db_type, schema, host, port, user, password string) Database { diff --git a/contrib/backends/srndv2/src/srnd/null_cache.go b/contrib/backends/srndv2/src/srnd/null_cache.go index 0b2319d..15fcbe6 100644 --- a/contrib/backends/srndv2/src/srnd/null_cache.go +++ b/contrib/backends/srndv2/src/srnd/null_cache.go @@ -137,10 +137,12 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } if page == 0 { - template.genUkko(self.prefix, self.name, w, self.database, isjson, i18n, self.invertPagination) - } else { - template.genUkkoPaginated(self.prefix, self.name, w, self.database, page, isjson, i18n, self.invertPagination) + if self.invertPagination { + pages, _ := self.database.GetUkkoPageCount(10) + page = int(pages) + } } + template.genUkkoPaginated(self.prefix, self.name, w, self.database, page, isjson, i18n, self.invertPagination) return } diff --git a/contrib/backends/srndv2/src/srnd/postgres.go b/contrib/backends/srndv2/src/srnd/postgres.go index 2bd7b3b..3bdf825 100644 --- a/contrib/backends/srndv2/src/srnd/postgres.go +++ b/contrib/backends/srndv2/src/srnd/postgres.go @@ -2001,8 +2001,9 @@ func (self *PostgresDatabase) FindCitesInText(text string) (msgids []string, err return } -func (self *PostgresDatabase) GetUkkoPageCount() (count int64, err error) { +func (self *PostgresDatabase) GetUkkoPageCount(perpage int) (count int64, err error) { err = self.conn.QueryRow(self.stmt[CountUkko]).Scan(&count) + count /= int64(perpage) return } diff --git a/contrib/backends/srndv2/src/srnd/templates_impl.go b/contrib/backends/srndv2/src/srnd/templates_impl.go index 9a26ed8..f103c39 100644 --- a/contrib/backends/srndv2/src/srnd/templates_impl.go +++ b/contrib/backends/srndv2/src/srnd/templates_impl.go @@ -263,8 +263,7 @@ func (self *templateEngine) genUkko(prefix, frontend string, wr io.Writer, datab var page int64 var err error if invertPagination { - page, err = database.GetUkkoPageCount() - page /= 10 + page, err = database.GetUkkoPageCount(10) } if err == nil { self.genUkkoPaginated(prefix, frontend, wr, database, int(page), json, i18n, invertPagination)