Typos + improvements

This commit is contained in:
Rémi Oudin 2018-02-22 11:06:45 +01:00
parent ad0ad0a783
commit 5decd205fb

View file

@ -10,6 +10,7 @@ import profiles.models as profiles
from crawl import crawl
from pinocchio.settings import HISTORY_MIN
class HistoryEntry(models.Model):
""" A history entry, aka a url, and a timestamp.
"""
@ -62,12 +63,16 @@ class History(models.Model):
self.save()
def generate_partial_history(user, t_start, url, history):
def generate_partial_history(user, t_start, history):
""" Generate the part of the history resulting from the crawl starting at
the given url.
"""
result = []
basis = generate_first_url(user)
result.append((basis, t_start))
t_start += 5* random.weibullvariate(1, 1.5)
#crawler = crawl.CrawlingThread()
return []
return result
def generate_first_url(user):
""" Generate the first url of a partial history, based on the user
@ -77,7 +82,7 @@ def generate_first_url(user):
user.interests.websites.all(), user.interests.events.all()
]
)
search_term = random.choice(interset)
search_term = random.choice(interest)
url = search_term.generate_url(user)
return url
@ -98,12 +103,13 @@ def generate_history(user, ts_start):
history_line = 0
while history_line < length:
ts_start += random.uniform(1, 10)
history = generate_partial_history(user, ts_start, url)
ts_start = history[-1].timestamp + 5 * weilbullvariate(1, 5)
for (url, ts) in history:
ts_start += 5 * random.weibullvariate(1, 2.8)
history_list = generate_partial_history(user, ts_start, history)
ts_start = history_list[-1].timestamp + 5 * random.weibullvariate(1, 5)
for (url, timestamp) in history_list:
new_line = HistoryEntry(
search=url,
timestamp=ts,
timestamp=timestamp,
history=history
)
new_line.save()