Better use of history

This commit is contained in:
Rémi Oudin 2018-02-26 10:05:33 +01:00
parent 8f5c4f3f0f
commit d6b26c0a46

View file

@ -8,6 +8,7 @@ from math import floor
from queue import Queue from queue import Queue
from django.db import models from django.db import models
import profiles.models as profiles import profiles.models as profiles
from tor_runner import TorInstance
from crawl import crawl from crawl import crawl
from pinocchio.settings import HISTORY_MIN from pinocchio.settings import HISTORY_MIN
@ -47,6 +48,7 @@ class History(models.Model):
""" Returns the history, sorted by increasing timestamps """ Returns the history, sorted by increasing timestamps
""" """
history_set = self.history_set.order_by('timestamp') history_set = self.history_set.order_by('timestamp')
history_set = [(item.search, item.timestamp.date()) for item in history_set]
return history_set return history_set
def __str__(self): def __str__(self):
@ -57,10 +59,11 @@ class History(models.Model):
return header + "\n".join(history_set) return header + "\n".join(history_set)
def play_history(self): def play_histories(self):
""" Actually plays the history. """ Actually plays the history.
""" """
self.played = True self.played = True
runner = TorInstance(self.history)
self.save() self.save()