Pages for requests are only calulated for items not yet downloaded and use ceil isteadof floor to get last items on a page
This commit is contained in:
@@ -13,7 +13,7 @@ class RequestRepository {
|
|||||||
this.queries = {
|
this.queries = {
|
||||||
add: 'insert into requests (id,title,year,poster_path,background_path,requested_by,ip,user_agent,type) values(?,?,?,?,?,?,?,?,?)',
|
add: 'insert into requests (id,title,year,poster_path,background_path,requested_by,ip,user_agent,type) values(?,?,?,?,?,?,?,?,?)',
|
||||||
fetchAll: 'select * from requests where status != "downloaded" order by date desc LIMIT 25 OFFSET ?*25-25',
|
fetchAll: 'select * from requests where status != "downloaded" order by date desc LIMIT 25 OFFSET ?*25-25',
|
||||||
totalRequests: 'select count(*) as totalRequests from requests',
|
totalRequests: 'select count(*) as totalRequests from requests where status != "downloaded"',
|
||||||
fetchAllSort: `select id, type from request order by ? ?`,
|
fetchAllSort: `select id, type from request order by ? ?`,
|
||||||
fetchAllFilter: `select id, type from request where ? is "?"`,
|
fetchAllFilter: `select id, type from request where ? is "?"`,
|
||||||
fetchAllQuery: `select id, type from request where title like "%?%" or year like "%?%"`,
|
fetchAllQuery: `select id, type from request where title like "%?%" or year like "%?%"`,
|
||||||
@@ -129,7 +129,7 @@ class RequestRepository {
|
|||||||
.then(async (rows) => {
|
.then(async (rows) => {
|
||||||
const sqliteResponse = await this.database.get(this.queries.totalRequests)
|
const sqliteResponse = await this.database.get(this.queries.totalRequests)
|
||||||
const totalRequests = sqliteResponse['totalRequests']
|
const totalRequests = sqliteResponse['totalRequests']
|
||||||
const totalPages = Math.floor(totalRequests / 25)
|
const totalPages = Math.ceil(totalRequests / 25)
|
||||||
|
|
||||||
return [ rows.map(item => { item.poster = item.poster_path; return item }), totalPages ]
|
return [ rows.map(item => { item.poster = item.poster_path; return item }), totalPages ]
|
||||||
return Promise.all(this.mapToTmdbByType(rows))
|
return Promise.all(this.mapToTmdbByType(rows))
|
||||||
|
|||||||
Reference in New Issue
Block a user