@@ -186,13 +186,13 @@ def submit():
186
186
), 200
187
187
188
188
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 ):
190
190
"""Return a query based on the args, with vote count attached to the quotes"""
191
191
# Get all the quotes with their votes
192
192
quote_query = db .session .query (Quote ,
193
193
func .sum (Vote .direction ).label ('votes' )).outerjoin (Vote ).group_by (Quote )
194
194
# 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 ())
196
196
# Filter hidden quotes
197
197
if not include_hidden :
198
198
quote_query = quote_query .filter (Quote .hidden == False )
@@ -201,6 +201,8 @@ def get_quote_query(speaker: str = "", submitter: str = "", include_hidden: bool
201
201
quote_query = quote_query .filter (Quote .speaker == request .args .get ('speaker' ))
202
202
if request .args .get ('submitter' ):
203
203
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 )
204
206
return quote_query
205
207
206
208
# display first 20 stored quotes
@@ -216,38 +218,42 @@ def get():
216
218
quotes = get_quote_query (speaker = request .args .get ('speaker' ),
217
219
submitter = request .args .get ('submitter' )).limit (20 ).all ()
218
220
221
+ last_id = list (quotes )[- 1 ][0 ].id
222
+
219
223
#tie any votes the user has made to their uid
220
224
user_votes = Vote .query .filter (Vote .voter == metadata ['uid' ]).all ()
221
225
return render_template (
222
226
'bootstrap/storage.html' ,
223
227
quotes = quotes ,
224
228
metadata = metadata ,
225
- user_votes = user_votes
229
+ user_votes = user_votes ,
230
+ last_id = last_id
226
231
)
227
232
228
233
229
234
# display ALL stored quotes
230
- @app .route ('/additional ' , methods = ['GET' ])
235
+ @app .route ('/storage/<last_id> ' , methods = ['GET' ])
231
236
@auth .oidc_auth
232
- def additional_quotes ():
237
+ def additional_quotes (last_id ):
233
238
"""
234
239
Show beyond the first 20 quotes
235
240
"""
236
-
237
241
metadata = get_metadata ()
238
242
239
- # Get all the quotes
243
+ # Get the most recent 20 quotes
240
244
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 ()
242
246
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
245
248
249
+ #tie any votes the user has made to their uid
250
+ user_votes = Vote .query .filter (Vote .voter == metadata ['uid' ]).all ()
246
251
return render_template (
247
- 'bootstrap/additional_quotes .html' ,
248
- quotes = quotes [ 20 :] ,
252
+ 'bootstrap/storage .html' ,
253
+ quotes = quotes ,
249
254
metadata = metadata ,
250
- user_votes = user_votes
255
+ user_votes = user_votes ,
256
+ last_id = last_id
251
257
)
252
258
253
259
@app .route ('/report/<quote_id>' , methods = ['POST' ])
0 commit comments