Commit cb9f9657 authored by Danielvdh03's avatar Danielvdh03
Browse files

Updated logic error with tweet filtering

parent e131fc06
......@@ -155,7 +155,7 @@ class Database:
state = input("Enter name of state that {0} is in : ".format(county))
state = state.strip()
display = input("Enter username of the user : ")
display = input("Enter username of the user : ")
display = display.strip()
followers = input("Enter their follower count : ")
......@@ -196,8 +196,9 @@ class Database:
query = "select total_votes from state where name =\"{0}\"".format(state)
results = self.execute_query(query, False)
output = trim_string(results[0])
output = "'"
for row in results:
output = row[0]
print("Number of votes from {0} is {1}".format(state, output))
return
......@@ -304,10 +305,10 @@ class Database:
likes = likes.strip()
query = "select display_name, tweet, likes from user inner join tweet on tweet.user_id=user.id where tweet > {0} and hashtag = \"{1}\"" \
query = "select display_name, tweet, likes from user inner join tweet on tweet.user_id=user.id where likes >= {0} and hashtag = \"{1}\"" \
" and county_id = (select id from county where name = \"{2}\" and state_id = (select id from state where name = \"{3}\")) ;" .format(likes, candidate_name, region, state )
#print(query)
print(query)
results = self.execute_query(query, False)
if len(results) == 0:
......@@ -343,10 +344,10 @@ class Database:
end_date+=" 00:00:00"
query = "select count(tweet) from tweet inner join user on tweet.user_id=user.id where tweet >= {0} and hashtag = \"{1}\"" \
query = "select count(tweet) from tweet inner join user on tweet.user_id=user.id where likes >= {0} and hashtag = \"{1}\"" \
" and county_id = (select id from county where name = \"{2}\" and state_id = (select id from state where name = \"{3}\")) ;".format(likes, candidate_name, region, state )
print(query)
# print(query)
results = self.execute_query(query, False)
if len(results) == 0:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment