def demo_random_subs(amount): all_p = Person.select() count = all_p.count() - 1 for _ in range(amount): owner = all_p[random.randint(0, count)] follower = all_p[random.randint(0, count)] if owner.vkid != follower.vkid: subscribe_on_target_person(owner_id=owner.vkid, follower_id=follower.vkid) else: print "LOL, owner==follower"
def demo_random_subs(amount): all_p = Person.select() count = all_p.count() - 1 for _ in range(amount): owner = all_p[random.randint(0, count)] follower = all_p[random.randint(0, count)] if owner.vkid != follower.vkid: subscribe_on_target_person(owner_id=owner.vkid, follower_id=follower.vkid) else: print "LOL, owner==follower"
def demo_add_post(person_id): _, words_amount, text = generate_sentence() # Piter coordinates: # lat, lon # 59.93900, 30.325896 latitude = 59.0 + 1.0 * random.randint(850000, 999999) / 1000000 longitude = 30.0 + 1.0 * random.randint(200000, 399999) / 1000000 pic_url = "http://lorempixel.com/300/300/" try: if person_id: Person.get(Person.vkid == person_id) else: all_p = Person.select(Person.vkid) count = all_p.count() - 1 person_id = all_p[random.randint(0, count)] Post.create(author=person_id, text=text, pic_url=pic_url, latitude=latitude, longitude=longitude) return True except DoesNotExist: return False
def demo_add_comment(author_id, post_id): _, words_amount, text = generate_sentence() try: if author_id: Person.get(Person.vkid == author_id) else: all_pers = Person.select(Person.vkid) count = all_pers.count() - 1 author_id = all_pers[random.randint(0, count)] if post_id: p = Post.get(Post.post_id == post_id) else: all_posts = Post.select() count = all_posts.count() - 1 p = all_posts[random.randint(0, count)] p.comments += 1 p.save() Comment.create(post=p, author=author_id, text=text) return True except DoesNotExist: return False
def demo_add_comment(author_id, post_id): _, words_amount, text = generate_sentence() try: if author_id: Person.get(Person.vkid == author_id) else: all_pers = Person.select(Person.vkid) count = all_pers.count() - 1 author_id = all_pers[random.randint(0, count)] if post_id: p = Post.get(Post.post_id == post_id) else: all_posts = Post.select() count = all_posts.count() - 1 p = all_posts[random.randint(0, count)] p.comments += 1 p.save() Comment.create(post=p, author=author_id, text=text) return True except DoesNotExist: return False
def demo_add_post(person_id): _, words_amount, text = generate_sentence() # Piter coordinates: # lat, lon # 59.93900, 30.325896 latitude = 59.0 + 1.0 * random.randint(850000, 999999) / 1000000 longitude = 30.0 + 1.0 * random.randint(200000, 399999) / 1000000 pic_url = "http://lorempixel.com/300/300/" try: if person_id: Person.get(Person.vkid == person_id) else: all_p = Person.select(Person.vkid) count = all_p.count() - 1 person_id = all_p[random.randint(0, count)] Post.create(author=person_id, text=text, pic_url=pic_url, latitude=latitude, longitude=longitude) return True except DoesNotExist: return False