amuse.git

commit af9bffd10e0d353ba05da2b9d93cd8f8700d9e24

Author: Adam <git@apiote.tk>

show page i of N in lists

 db/db.go | 16 ++++++++--------
 templates/experiences.html | 1 +
 templates/readlist.html | 1 +
 templates/tvqueue.html | 1 +
 templates/watchlist.html | 1 +


diff --git a/db/db.go b/db/db.go
index 743d306f07a2ecef6adcfc349085c94df36c9f47..d1bd3e7d5a51b61dc8861241e5e80e9f63121415 100644
--- a/db/db.go
+++ b/db/db.go
@@ -716,14 +716,6 @@ 	if page <= 0 {
 		page = 1
 	}
 
-	var pages float64
-	row := db.QueryRow(`select count(*) from wantlist where item_type = 'film' and username = ?`, username)
-	err = row.Scan(&pages)
-	if err != nil {
-		return watchlist, err
-	}
-	watchlist.Pages = int(math.Ceil(pages / 18))
-
 	offset := (page - 1) * 18
 
 	//todo filter, order by
@@ -732,6 +724,14 @@ 	var whereClause string
 	if filter != "" {
 		whereClause = "and c1.title like '%" + filter + "%'"
 	}
+
+	var pages float64
+	row := db.QueryRow(`select distinct count(*) from wantlist w natural join item_cache c1 where c1.item_type = 'film' and w.username = ? `+whereClause, username)
+	err = row.Scan(&pages)
+	if err != nil {
+		return watchlist, err
+	}
+	watchlist.Pages = int(math.Ceil(pages / 18))
 
 	rows, err := db.Query(`select distinct c1.item_id, c1.cover, c1.status, c1.title, c1.year_start, c1.based_on, c1.genres, c1.runtime, c1.part, c2.part from (wantlist w natural join item_cache c1) left join (experiences e natural join item_cache c2) on(c1.part-1 = c2.part and c1.collection = c2.collection and e.username = w.username) where c1.item_type = 'film' and w.username = ? `+whereClause+` order by c1.title limit ?,18`, username, offset)
 




diff --git a/templates/experiences.html b/templates/experiences.html
index b2bb9cad4eea95fea29c10a9853d3f0704041211..57031cdea75772cd463e0a0dc0df51a4e021fc89 100644
--- a/templates/experiences.html
+++ b/templates/experiences.html
@@ -49,6 +49,7 @@ 					{{if gt .Data.Page 1}}
 					<a href="/users/{{.State.User.Username}}/experiences?filter={{.Data.Query}}&page={{.Data.PrevPage}}" class="decoration-none" title="{{.Strings.Search.prev_link_title}}"><span class="material-icon font-2">&#xe408;</span></a>
 					{{end}}
 				</div>
+				<div>Page {{.Data.Page}}/{{.Data.Pages}}</div>
 				<div>
 					{{if lt .Data.Page .Data.Pages}}
 					<a href="/users/{{.State.User.Username}}/experiences?filter={{.Data.Query}}&page={{.Data.NextPage}}" class="decoration-none" title="{{.Strings.Search.next_link_title}}"><span class="material-icon font-2">&#xe409;</span></a>




diff --git a/templates/readlist.html b/templates/readlist.html
index 5daea2845574ec0973fb98d9e1e3e8e8b1d223f1..12f9bd066a4bcd73187715a5c72afbdb34a04a89 100644
--- a/templates/readlist.html
+++ b/templates/readlist.html
@@ -49,6 +49,7 @@ 					{{if gt .Data.Page 1}}
 					<a href="/users/{{.State.User.Username}}/readlist?filter={{.Data.Query}}&page={{.Data.PrevPage}}" class="decoration-none" title="{{.Strings.Search.prev_link_title}}"><span class="material-icon font-2">&#xe408;</span></a>
 					{{end}}
 				</div>
+				<div>Page {{.Data.Page}}/{{.Data.Pages}}</div>
 				<div>
 					{{if lt .Data.Page .Data.Pages}}
 					<a href="/users/{{.State.User.Username}}/readlist?filter={{.Data.Query}}&page={{.Data.NextPage}}" class="decoration-none" title="{{.Strings.Search.next_link_title}}"><span class="material-icon font-2">&#xe409;</span></a>




diff --git a/templates/tvqueue.html b/templates/tvqueue.html
index 859fc23a82acf44b862c5ddaaa26c7c8375319da..4a1cabe2d3f359a487d668331a7e378c3b785c33 100644
--- a/templates/tvqueue.html
+++ b/templates/tvqueue.html
@@ -49,6 +49,7 @@ 					{{if gt .Data.Page 1}}
 					<a href="/users/{{.State.User.Username}}/tvqueue?filter={{.Data.Query}}&page={{.Data.PrevPage}}" class="decoration-none" title="{{.Strings.Search.prev_link_title}}"><span class="material-icon font-2">&#xe408;</span></a>
 					{{end}}
 				</div>
+				<div>Page {{.Data.Page}}/{{.Data.Pages}}</div>
 				<div>
 					{{if lt .Data.Page .Data.Pages}}
 					<a href="/users/{{.State.User.Username}}/tvqueue?filter={{.Data.Query}}&page={{.Data.NextPage}}" class="decoration-none" title="{{.Strings.Search.next_link_title}}"><span class="material-icon font-2">&#xe409;</span></a>




diff --git a/templates/watchlist.html b/templates/watchlist.html
index 2ed4995f012d800c6caf04484a20ce58855cdc7a..c2f3f16a8ecb77f8012b7f22e5491c800c3116cc 100644
--- a/templates/watchlist.html
+++ b/templates/watchlist.html
@@ -49,6 +49,7 @@ 					{{if gt .Data.Page 1}}
 					<a href="/users/{{.State.User.Username}}/watchlist?filter={{.Data.Query}}&page={{.Data.PrevPage}}" class="decoration-none" title="{{.Strings.Search.prev_link_title}}"><span class="material-icon font-2">&#xe408;</span></a>
 					{{end}}
 				</div>
+				<div>Page {{.Data.Page}}/{{.Data.Pages}}</div>
 				<div>
 					{{if lt .Data.Page .Data.Pages}}
 					<a href="/users/{{.State.User.Username}}/watchlist?filter={{.Data.Query}}&page={{.Data.NextPage}}" class="decoration-none" title="{{.Strings.Search.next_link_title}}"><span class="material-icon font-2">&#xe409;</span></a>