Comments (5)
I guess if you do this it works:
def index(conn, params) do
page =
MyApp.Person
|> where([p], p.age > 30)
|> order_by(desc: :age)
|> preload(:friends)
|> MyApp.Repo.paginate(params)
meow = %Scrivener.Page{entries: page.entries,
page_number: page.page_number,
page_size: page.page_size,
total_pages: new_total_pages,
total_entries: new_total_entries}
render conn, :index, properties: meow
from scrivener_html.
Yes you could do that. However, I suppose this is more for the Scrivener project to tackle than here.
I'd just update the values rather than creating a new page...
render conn, :index, page: %{page | total_pages: new_total_pages, total_entries: new_total_entries}
But first, think about the fact that you're doing this before you do it. If the paginate
function isnt giving you the data you want in those fields, ask yourself if maybe you're doing something wrong. I'd bet that @drewolson likely would want to know more about your use case in changing these values.
from scrivener_html.
The reason for this is to get around the limitation of Scrivener.Ecto when not selecting * and needing an accurate result count.
My queries are more complex than usual, with 6 joins, a where and a select on 10 columns across 7 tables. The count distinct can't be on *.
from scrivener_html.
either way, I'm not sure how this project should change to help you. You can already override the total_pages and total_entries like I showed, and then the helper function this project exposes will work just the same...
from scrivener_html.
@coreyk the newest release of scrivener_ecto
uses subquery
to produce accurate counts. Please take a look. This issue is unrelated to this project.
from scrivener_html.
Related Issues (20)
- Scrivener HTML 1.8 Displaying as Unordered List HOT 2
- Maintenance Help HOT 11
- Add helper to display item count information HOT 3
- bootstrap 4 support? HOT 1
- SEO header links not taking non-existing pages into account HOT 3
- issue with paginate url params HOT 7
- Customization of wrapper classes HOT 2
- Link to first page without page paramter
- Most config options don't work in `config.exs`? HOT 4
- Option to not display anything if there is only 1 page of elements? HOT 3
- Update for phoenix 1.4.0 HOT 3
- Adding a pagination_info helper HOT 1
- Altering the order of first/previous and last/next HOT 5
- Bug in find_path_fn HOT 2
- Style not applied HOT 1
- Milligram view styles? HOT 4
- Query string parameters name clashes HOT 1
- Link closing tag is forbidden HOT 1
- all links in pagination marked as canonical except for next, prev HOT 1
- Phoenix 1.5.0 Compatibility HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scrivener_html.