<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import json <EOL> import logging <EOL> import os <EOL> import time <EOL> from tornado import gen <EOL> from viewfinder . backend . base import constants , util <EOL> from viewfinder . backend . base . dotdict import DotDict <EOL> from viewfinder . backend . db import vf_schema <EOL> from viewfinder . backend . db . base import DBObject <EOL> from viewfinder . backend . db . range_base import DBRangeObject <EOL> class Analytics ( DBRangeObject ) : <EOL> USER_CREATE_PROSPECTIVE = '<STR_LIT>' <EOL> USER_REGISTER = '<STR_LIT>' <EOL> USER_TERMINATE = '<STR_LIT>' <EOL> _table = DBObject . _schema . GetTable ( vf_schema . ANALYTICS ) <EOL> def __init__ ( self ) : <EOL> super ( Analytics , self ) . __init__ ( ) <EOL> @ classmethod <EOL> def CreateSortKey ( cls , timestamp , entry_type ) : <EOL> """<STR_LIT>""" <EOL> prefix = util . CreateSortKeyPrefix ( timestamp , randomness = False ) <EOL> return prefix + entry_type <EOL> @ classmethod <EOL> def Create ( cls , ** analytics_dict ) : <EOL> """<STR_LIT>""" <EOL> create_dict = analytics_dict <EOL> if '<STR_LIT>' not in create_dict : <EOL> create_dict [ '<STR_LIT>' ] = util . GetCurrentTimestamp ( ) <EOL> entity = create_dict [ '<STR_LIT>' ] <EOL> entry_type = create_dict [ '<STR_LIT:type>' ] <EOL> if entry_type . startswith ( '<STR_LIT>' ) : <EOL> assert entity . startswith ( '<STR_LIT>' ) , '<STR_LIT>' % create_dict <EOL> create_dict [ '<STR_LIT>' ] = int ( create_dict [ '<STR_LIT>' ] ) <EOL> create_dict [ '<STR_LIT>' ] = Analytics . CreateSortKey ( create_dict [ '<STR_LIT>' ] , create_dict [ '<STR_LIT:type>' ] ) <EOL> return cls . CreateFromKeywords ( ** create_dict ) </s>
