@@ -186,13 +186,13 @@ def submit():
186186 ), 200
187187
188188
189- def get_quote_query (speaker : str = "" , submitter : str = "" , include_hidden : bool = False ):
189+ def get_quote_query (speaker : str = "" , submitter : str = "" , last_id = None , include_hidden : bool = False ):
190190 """Return a query based on the args, with vote count attached to the quotes"""
191191 # Get all the quotes with their votes
192192 quote_query = db .session .query (Quote ,
193193 func .sum (Vote .direction ).label ('votes' )).outerjoin (Vote ).group_by (Quote )
194194 # Put the most recent first
195- quote_query = quote_query .order_by (Quote .quote_time .desc ())
195+ quote_query = quote_query .order_by (Quote .id .desc ())
196196 # Filter hidden quotes
197197 if not include_hidden :
198198 quote_query = quote_query .filter (Quote .hidden == False )
@@ -201,6 +201,8 @@ def get_quote_query(speaker: str = "", submitter: str = "", include_hidden: bool
201201 quote_query = quote_query .filter (Quote .speaker == request .args .get ('speaker' ))
202202 if request .args .get ('submitter' ):
203203 quote_query = quote_query .filter (Quote .submitter == request .args .get ('submitter' ))
204+ if last_id :
205+ quote_query = quote_query .filter (Quote .id < last_id )
204206 return quote_query
205207
206208# display first 20 stored quotes
@@ -216,38 +218,42 @@ def get():
216218 quotes = get_quote_query (speaker = request .args .get ('speaker' ),
217219 submitter = request .args .get ('submitter' )).limit (20 ).all ()
218220
221+ last_id = list (quotes )[- 1 ][0 ].id
222+
219223 #tie any votes the user has made to their uid
220224 user_votes = Vote .query .filter (Vote .voter == metadata ['uid' ]).all ()
221225 return render_template (
222226 'bootstrap/storage.html' ,
223227 quotes = quotes ,
224228 metadata = metadata ,
225- user_votes = user_votes
229+ user_votes = user_votes ,
230+ last_id = last_id
226231 )
227232
228233
229234# display ALL stored quotes
230- @app .route ('/additional ' , methods = ['GET' ])
235+ @app .route ('/storage/<last_id> ' , methods = ['GET' ])
231236@auth .oidc_auth
232- def additional_quotes ():
237+ def additional_quotes (last_id ):
233238 """
234239 Show beyond the first 20 quotes
235240 """
236-
237241 metadata = get_metadata ()
238242
239- # Get all the quotes
243+ # Get the most recent 20 quotes
240244 quotes = get_quote_query (speaker = request .args .get ('speaker' ),
241- submitter = request .args .get ('submitter' )).all ()
245+ submitter = request .args .get ('submitter' ), last_id = last_id ). limit ( 20 ).all ()
242246
243- #tie any votes the user has made to their uid
244- user_votes = db .session .query (Vote ).filter (Vote .voter == metadata ['uid' ]).all ()
247+ last_id = list (quotes )[- 1 ][0 ].id
245248
249+ #tie any votes the user has made to their uid
250+ user_votes = Vote .query .filter (Vote .voter == metadata ['uid' ]).all ()
246251 return render_template (
247- 'bootstrap/additional_quotes .html' ,
248- quotes = quotes [ 20 :] ,
252+ 'bootstrap/storage .html' ,
253+ quotes = quotes ,
249254 metadata = metadata ,
250- user_votes = user_votes
255+ user_votes = user_votes ,
256+ last_id = last_id
251257 )
252258
253259@app .route ('/report/<quote_id>' , methods = ['POST' ])
0 commit comments