Skip to content
This repository was archived by the owner on Mar 4, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .idea/bvcodingchallenge-sampleapp.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 26 additions & 4 deletions helpers/stats_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,33 @@ def __init__(self):
self.database = Database()
print("Stats Helping initialising!")

def caculate_ave_overall_rating(self):
def calculate_ave_overall_rating(self):
result = self.database.fetch_one("SELECT AVG(review_overall) FROM reviews")
return result[0]

# HINT: You can define more queries here, along with some python logic to calculate!
def calculate_another_stat(self):
# all_rows = self.database.fetch_all("")
return None
def get_top5(self):
all_rows = self.database.fetch_all('SELECT DISTINCT beer_name FROM reviews GROUP BY beer_name ORDER BY "review_taste" DESC LIMIT 5')
return all_rows

def get_low5_ave_taste(self):
all_rows = self.database.fetch_all(
'SELECT DISTINCT beer_name, AVG(review_taste) FROM reviews GROUP BY beer_name ORDER BY AVG(review_overall) ASC LIMIT 5')
return all_rows

def get_top5_ave_overall_rating_brewerys(self):
all_rows = self.database.fetch_all('SELECT DISTINCT brewery_name FROM reviews GROUP BY brewery_name ORDER BY AVG(review_overall) DESC LIMIT 3')
return all_rows

def low5_first_val(self):
all_rows = self.database.fetch_all(
'SELECT DISTINCT beer_name, AVG(review_taste) FROM reviews GROUP BY beer_name ORDER BY AVG(review_overall) ASC LIMIT 5')
first_value = all_rows[0]
return first_value

'''
Level 1 optional
I feel that it would be a good idea to look at the top 3 brewery names ordered by average overall review ratings, as
this would allow the drinks retailer to select a brewery to produce their beer based on the the previously mentioned
requirements and would potentially let the company produce the most likely to succeed beer.
'''
Binary file added img/BeerCo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading