1337.
This commit is contained in:
parent
eb4ec7208f
commit
9849b6ea12
@ -58,12 +58,15 @@ class BaseView(web.View):
|
|||||||
class EventView(BaseView):
|
class EventView(BaseView):
|
||||||
|
|
||||||
document_fields = ['title','html','domain','href']
|
document_fields = ['title','html','domain','href']
|
||||||
|
click_fields = ["event", "target"]
|
||||||
event_fields = ['target','event','tag','scroll_height','scroll_left','scroll_top','client_width','client_height','page_x','page_y','screen_x','screen_y','client_x','client_y','target_x','target_y']
|
event_fields = ['target','event','tag','scroll_height','scroll_left','scroll_top','client_width','client_height','page_x','page_y','screen_x','screen_y','client_x','client_y','target_x','target_y']
|
||||||
|
|
||||||
def is_document_record(self, data):
|
def is_document_record(self, data):
|
||||||
return data.get('html') and True or False
|
return data.get('html') and True or False
|
||||||
|
|
||||||
|
def is_click_record(self,data):
|
||||||
|
return data.get('event') == 'click'
|
||||||
|
|
||||||
def get_record(self, data):
|
def get_record(self, data):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -86,6 +89,16 @@ class EventView(BaseView):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
record = {}
|
||||||
|
for field in self.click_fields:
|
||||||
|
if field in data:
|
||||||
|
record[field] = data[field]
|
||||||
|
if len(record.keys()) == len(self.click_fields):
|
||||||
|
return record
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def get(self):
|
async def get(self):
|
||||||
@ -123,6 +136,10 @@ class EventView(BaseView):
|
|||||||
)
|
)
|
||||||
self.insert('visit', record)
|
self.insert('visit', record)
|
||||||
self.app.view_count += 1
|
self.app.view_count += 1
|
||||||
|
elif self.is_click_record(data):
|
||||||
|
data['visit_id'] = visit_id
|
||||||
|
record = data
|
||||||
|
self.insert('click', record)
|
||||||
else:
|
else:
|
||||||
data['visit_id'] = visit_id
|
data['visit_id'] = visit_id
|
||||||
record = data
|
record = data
|
||||||
|
Loading…
Reference in New Issue
Block a user