Example #1
0
def get_original_answer_and_mark(id):
    original_id = []
    db=SqliteDatabase('retention.db')
    db.connect()
    #get the original tweet id for each short_id
    answer = ShortTweetID.select(ShortTweetID.original_tweet_id).distinct().where(ShortTweetID.short_tweet_id == id)
    for a in answer:
        print("original tweetid: ",a.original_tweet_id.tweet_id)
        original_id.append(a.original_tweet_id.tweet_id)
         #marcar la pregunta como verificada, quiere decir que esa pregunta ya no se vuelve a mandar a los usuarios

    #get the original answer that belongs to that tweetid
        for oid in original_id:
            original_answer =AnswerTweets.select(AnswerTweets.user,AnswerTweets.woman,AnswerTweets.reason).where(AnswerTweets.tweet_message_answer ==oid)
            mark_as_verified =  AnswerTweets.update(has_been_verified=True).where(AnswerTweets.tweet_message_answer ==oid)
            mark_as_verified.execute()
            return original_answer
Example #2
0
def voting(the_bot,user):
    users = []
    tweet_to_verify = {}

    db=SqliteDatabase('retention.db')
    db.connect()
    print("Initiating Voting")
    #from the answertweets table make a select  to get tweets with answers
    ##################Pendientes###

    #cuando se corre el programa, debe de checar si esa pregunta ya fue hecha al usuario,
    #se debe guardar la fecha en que se le envio a que usuarios
    #si aun no se ha enviado entonces se recluta a los usuarios del leaderboard para las sigueintes preguntas y se crea el shortid
    #tambien se debe de tomar en cuenta que si el tweet aun no tiene los sufientes votos se deben de mandar a otras personas diferentes para que voten
    #saves the answers from answer_users that has not been verified
    answers = AnswerTweets.select().where(AnswerTweets.has_been_verified == False)

    #this for creates the short id table
    #the variable answer has all the information from the answer_user table
    ###############check that does not create duplicate rows , maybe unique = true?###
    for a in answers:
        #gets the original tweet id
        originalid= (a.tweet_message_answer.tweet_id)

        tweetid = str(originalid)
        #creates the short id
        answerid = tweetid[-5:]
        ShortTweetID.create(original_tweet_id = int(originalid),short_tweet_id = answerid)

        print("tweet:",answerid,a.woman, a.reason)
        tweets[tweetid] = answerid + ": " + a.woman + ", " + a.reason

    #this will create the users to target
    #get the 10 most participative users
    sorted_dict = get_leaderboard()
    count=0
    for k,v in sorted_dict:
            if count < 3:
                count += 1
                username = the_bot.get_screen_name(k)

                tpoints = v
                player = "|" + str(username) + ": " + str(tpoints)+ "|"
                users.append(username)
                print ("player: ",player)

    for u in users:
        print("the users to target: ",u)
        #and constructs a tweet  [@verifier 1023: Answer to verify- "Fridah Kahlo" "www.kahlo.com"]

        for  vv in tweets.values():
            message=('@'+u +' help us decide Y or N, ID'+ vv)
            tweet= User_Asked_toVerify.create(user_who_verified = id_user_who_verified,verfied_short_id = itemr['screen_name'])
            the_bot.update_status(message)