def create_entity2user(enti_uid, user_id, user_ip): ''' create entity2user record in the database. ''' TabEntity2User.create(uid=tools.get_uuid(), entity_id=enti_uid, user_id=user_id, user_ip=user_ip, timestamp=time.time())
def create_entity2user(enti_uid, user_id): ''' create entity2user record in the database. ''' record = TabEntity2User.select().where( (TabEntity2User.entity_id == enti_uid) & (TabEntity2User.user_id == user_id)) if record.count() > 0: record = record.get() MEntity2User.count_increate(record.uid, record.count) else: TabEntity2User.create(uid=tools.get_uuid(), entity_id=enti_uid, user_id=user_id, count=1, timestamp=time.time())