<div>Dear all,<br clear="all"></div><div><br></div><div>I&#39;ve been using the MagmaCollectionReader to develop a paged view over some collection. I&#39;m using this paged view in a seaside app. This shows if there is a previous or a next page and the number of items being shown now: 1 - 21 of 2867. </div>

<div><br></div><div>If I do a query on a MagmaCollection using a sortBy: clause; some things go sometimes a bit wrong.</div><div><br></div><div>If I do a query using a sortBy: ; then i can check if sortComplete. Using a query without sortBy:, I can know the total number of items by calling lastKnownSize. If I do a sortBy: query, the lastKnownSize returns the max number already sorted (which is not ok in my gui; I need the total of that query). However I noticed that u can also use fractionSorted to know how much items already have been sorted, and derived from that how much items there are in total. <br>

<br>For instance: <br><br>        Last known size: 2249<br>        Fraction Sorted:(2249/6065)<br><br>So I wrote code like this to already know and show the total numbers of the search, even if the search is still going on on the server, like this I can then already show the first page with the result, while the server is still creating further pages<br>

<br>totalNumberOfElements<br>   ^(magmaCollectionReader sortComplete) <br>        ifTrue: [magmaCollectionReader lastKnownSize]<br>        ifFalse: [|fractionSorted|<br>                   fractionSorted := magmaCollectionReader fractionSorted.<br>

                   (fractionSorted = 0) <br>                              ifTrue: [self totalNumberOfElements].<br>                   (fractionSorted isFraction)<br>                              ifTrue: [fractionSorted denominator]<br>                              ifFalse: [magmaCollectionReader lastKnownSize]]].<br>

<br>This works mostly. If the fraction gets reduced however, the denominator returns a too low number off course. Is there any other way to know the total number of items in the search, even if it is still going on the server? <br>

<br>If I follow the code into <br>MaQueryExecutor&gt;&gt;fractionComplete<br>    ^ trunkPosition <br>                 ifNil: [ 0 ]<br>                 ifNotNil: <br>                            [ | trunkSize |<br>                              trunkSize _ self trunk trunkSize.<br>

                              trunkSize = 0 <br>                                         ifTrue: [ 1 ]<br>                                         ifFalse: [ trunkPosition / self trunk trunkSize ] ]<br><br>I understand where the 0 can come from &amp; where the reduction comes from. Integer/anotherInteger automatically does a reduce.<br>

<br>If I on the server Image change<br>MaQueryExecutor&gt;&gt;fractionComplete<br>       ^ trunkPosition <br>                    ifNil: [ 0 ]<br>                    ifNotNil: <br>                                [ | trunkSize |<br>                                   trunkSize _ self trunk trunkSize.<br>

                                   trunkSize = 0 <br>                                               ifTrue: [ 1 ]<br>                                               ifFalse: [<b> Fraction numerator: trunkPosition denominator: self trunk trunkSize</b> ] ]<br><br>It works because the reduce is then not done. This is a bit of hack off course. <br>

<br>Is there any other way of doing this?<br><br><br>Thanks for any help.</div><div><br></div><div>Kind Regards </div><div><br></div><div>Bart</div><div><br></div><div>-- <br></div>imagination is more important than knowledge - Albert Einstein<br>

Logic will get you from A to B. Imagination will take you everywhere - Albert Einstein<br>Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Albert Einstein<br>The true sign of intelligence is not knowledge but imagination. - Albert Einstein<br>

Gravitation is not responsible for people falling in love. - Albert Einstein<br>