wip

parent 0ca4469b
......@@ -42,19 +42,20 @@ class GoalVisits(Goal):
if data['returnvalue'] == '200':
# if this host has not visited yet
if data['host'] not in self.visits:
self.visits[data['host']] = {'number':1, 'timestamp': logdate}
self.visits[data['host']] = {'number':1, 'timestamp': logdate, 'user-agent': data['user-agent']}
print(data['request'])
else:
# we need to check if it is still the same visit
if not self.is_still_visiting(logdate, self.visits[data['host']]['timestamp']):
if not self.is_still_visiting(logdate, self.visits[data['host']]['timestamp'], data['user-agent'], self.visits[data['host']]['user-agent']):
# visit_duration is not respected, it is a new visit
self.visits[data['host']]['timestamp'] = logdate
self.visits[data['host']]['number'] += 1
self.visits[data['host']]['user-agent'] = data['user-agent']
print(data['request'])
def is_still_visiting(self, logdate, previouslogdate):
def is_still_visiting(self, logdate, previouslogdate, usagent, previoususagent):
'''is it still an ongoing visit or not'''
if previouslogdate >= (logdate - self.visitdelta):
if (previouslogdate >= (logdate - self.visitdelta)) and previoususagent == usagent:
return True
else:
return False
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment