Commit 505509c0 authored by Danielvdh03's avatar Danielvdh03
Browse files

Bug fix on find_user. Now supports searching an entire state

parent 116dbd3c
......@@ -291,15 +291,47 @@ class Database:
max_follower_count = input("Emter maximum follower count to query by (leave blank for infinite) : ")
max_follower_count = max_follower_count.strip()
limit = input("All results or limit results (All/Limit) : ")
limit = limit.strip()
limit = limit.lower()
limit_string = ""
if limit == "limit":
limit_string += self.limit_results()
if county == "All":
if max_follower_count == "":
query = "select display_name, follower_count from user where follower_count > {0} and " \
"county_id in (select id from county where state_id = (select id from state where name=\"{1}\")) order by follower_count desc {2};".format(min_follower_count, state, limit_string)
else:
query = "select display_name, follower_count from user where follower_count between {0} and {1} and " \
"county_id in (select id from county where state_id = (select id from state where name=\"{2}\")) order by follower_count desc {3};".format(
min_follower_count, max_follower_count, state, limit_string)
print(query)
results = self.execute_query(query)
if len(results) == 0:
print("No results returned")
else:
counter = 1
for result in results:
print("{2}. Username : {0}, Follower Count : {1}".format(result[0], result[1], counter))
counter += 1
return
if max_follower_count == "":
query = "select display_name, follower_count from user where follower_count > {0} AND" \
" county_id = (select id from county where name = \"{1}\" and state_id = (select id from state where name = \"{2}\" ));"\
.format( min_follower_count, county, state)
" county_id = (select id from county where name = \"{1}\" and state_id = (select id from state where name = \"{2}\" )) order by follower_count desc {3};"\
.format( min_follower_count, county, state, limit_string)
else:
query = "select display_name, follower_count from user where follower_count between {0} and {1} AND" \
" county_id = (select id from county where name = \"{2}\" and state_id = (select id from state where name = \"{3}\" ));".format(min_follower_count, max_follower_count,
county, state)
" county_id = (select id from county where name = \"{2}\" and state_id = (select id from state where name = \"{3}\" )) order by follower_count desc {4};".format(min_follower_count, max_follower_count,
county, state , limit_string)
print(query)
results = self.execute_query(query)
......@@ -587,19 +619,19 @@ if __name__ == "__main__":
command = command.lower() # No longer case sensitive
command = command.strip()
if command == "quit": # Done
if command == "quit": # Works
break
elif command == "help": # Done
elif command == "help": # Works
client.display_command_list()
elif command == "state_votes":
elif command == "state_votes": # Works
client.get_votes_state()
elif command == "find_user":
elif command == "find_user": # Works
client.find_user()
......
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