##// END OF EJS Templates
Merge pull request #13657 from Carreau/fix-mix-history...
Matthias Bussonnier -
r27647:4d97ab19 merge
parent child Browse files
Show More
@@ -296,8 +296,8 b' class HistoryAccessor(HistoryAccessorBase):'
296 toget = "history.%s, output_history.output" % toget
296 toget = "history.%s, output_history.output" % toget
297 if latest:
297 if latest:
298 toget += ", MAX(session * 128 * 1024 + line)"
298 toget += ", MAX(session * 128 * 1024 + line)"
299 cur = self.db.execute("SELECT session, line, %s FROM %s " %\
299 this_querry = "SELECT session, line, %s FROM %s " % (toget, sqlfrom) + sql
300 (toget, sqlfrom) + sql, params)
300 cur = self.db.execute(this_querry, params)
301 if latest:
301 if latest:
302 cur = (row[:-1] for row in cur)
302 cur = (row[:-1] for row in cur)
303 if output: # Regroup into 3-tuples, and parse JSON
303 if output: # Regroup into 3-tuples, and parse JSON
@@ -344,6 +344,11 b' class HistoryAccessor(HistoryAccessorBase):'
344 def get_tail(self, n=10, raw=True, output=False, include_latest=False):
344 def get_tail(self, n=10, raw=True, output=False, include_latest=False):
345 """Get the last n lines from the history database.
345 """Get the last n lines from the history database.
346
346
347 Most recent entry last.
348
349 Completion will be reordered so that that the last ones are when
350 possible from current session.
351
347 Parameters
352 Parameters
348 ----------
353 ----------
349 n : int
354 n : int
@@ -362,11 +367,31 b' class HistoryAccessor(HistoryAccessorBase):'
362 self.writeout_cache()
367 self.writeout_cache()
363 if not include_latest:
368 if not include_latest:
364 n += 1
369 n += 1
365 cur = self._run_sql("ORDER BY session DESC, line DESC LIMIT ?",
370 # cursor/line/entry
366 (n,), raw=raw, output=output)
371 this_cur = list(
372 self._run_sql(
373 "WHERE session == ? ORDER BY line DESC LIMIT ? ",
374 (self.session_number, n),
375 raw=raw,
376 output=output,
377 )
378 )
379 other_cur = list(
380 self._run_sql(
381 "WHERE session != ? ORDER BY session DESC, line DESC LIMIT ?",
382 (self.session_number, n),
383 raw=raw,
384 output=output,
385 )
386 )
387
388 everything = this_cur + other_cur
389
390 everything = everything[:n]
391
367 if not include_latest:
392 if not include_latest:
368 return reversed(list(cur)[1:])
393 return list(everything)[:0:-1]
369 return reversed(list(cur))
394 return list(everything)[::-1]
370
395
371 @catch_corrupt_db
396 @catch_corrupt_db
372 def search(self, pattern="*", raw=True, search_raw=True,
397 def search(self, pattern="*", raw=True, search_raw=True,
General Comments 0
You need to be logged in to leave comments. Login now