File tree Expand file tree Collapse file tree 1 file changed +8
-19
lines changed
Expand file tree Collapse file tree 1 file changed +8
-19
lines changed Original file line number Diff line number Diff line change @@ -82,47 +82,36 @@ impl QueryResponseBuilder {
8282 pub fn add_id ( & mut self , id : Id ) -> bool {
8383 let document_id = id. document_id ( ) ;
8484
85- // Pagination
8685 if !self . has_anchor {
86+ // By position
8787 if self . position >= 0 {
8888 if self . position > 0 {
8989 self . position -= 1 ;
9090 } else {
9191 self . response . ids . push ( id) ;
92- if self . response . ids . len ( ) == self . limit {
93- return false ;
94- }
9592 }
9693 } else {
9794 self . response . ids . push ( id) ;
9895 }
99- } else if self . anchor_offset >= 0 {
96+ } else {
97+ // By anchor
10098 if !self . anchor_found {
101- if document_id != self . anchor {
99+ self . position += 1 ;
100+ self . anchor_found = document_id == self . anchor ;
101+ if !self . anchor_found {
102102 return true ;
103103 }
104- self . anchor_found = true ;
105104 }
106105
107106 if self . anchor_offset > 0 {
108107 self . anchor_offset -= 1 ;
108+ self . position += 1 ;
109109 } else {
110110 self . response . ids . push ( id) ;
111- if self . response . ids . len ( ) == self . limit {
112- return false ;
113- }
114- }
115- } else {
116- self . anchor_found = document_id == self . anchor ;
117- self . response . ids . push ( id) ;
118-
119- if self . anchor_found {
120- self . position = self . anchor_offset ;
121- return false ;
122111 }
123112 }
124113
125- true
114+ self . response . ids . len ( ) != self . limit
126115 }
127116
128117 pub fn is_full ( & self ) -> bool {
You can’t perform that action at this time.
0 commit comments