##// END OF EJS Templates
This fixed the mixing of multiple history seen in #13631...
Matthias Bussonnier -
Show More
@@ -296,8 +296,8 b' class HistoryAccessor(HistoryAccessorBase):'
296 296 toget = "history.%s, output_history.output" % toget
297 297 if latest:
298 298 toget += ", MAX(session * 128 * 1024 + line)"
299 cur = self.db.execute("SELECT session, line, %s FROM %s " %\
300 (toget, sqlfrom) + sql, params)
299 this_querry = "SELECT session, line, %s FROM %s " % (toget, sqlfrom) + sql
300 cur = self.db.execute(this_querry, params)
301 301 if latest:
302 302 cur = (row[:-1] for row in cur)
303 303 if output: # Regroup into 3-tuples, and parse JSON
@@ -344,6 +344,11 b' class HistoryAccessor(HistoryAccessorBase):'
344 344 def get_tail(self, n=10, raw=True, output=False, include_latest=False):
345 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 352 Parameters
348 353 ----------
349 354 n : int
@@ -362,11 +367,31 b' class HistoryAccessor(HistoryAccessorBase):'
362 367 self.writeout_cache()
363 368 if not include_latest:
364 369 n += 1
365 cur = self._run_sql("ORDER BY session DESC, line DESC LIMIT ?",
366 (n,), raw=raw, output=output)
370 # cursor/line/entry
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 392 if not include_latest:
368 return reversed(list(cur)[1:])
369 return reversed(list(cur))
393 return list(everything)[:0:-1]
394 return list(everything)[::-1]
370 395
371 396 @catch_corrupt_db
372 397 def search(self, pattern="*", raw=True, search_raw=True,
General Comments 0
You need to be logged in to leave comments. Login now