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
10 changes: 10 additions & 0 deletions .idea/bvcodingchallenge-sampleapp.iml

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

4 changes: 4 additions & 0 deletions .idea/misc.xml

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

5 changes: 4 additions & 1 deletion application.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
@app.route('/')
def homepage():
# HINT: Pass variables through to the HTML using Flask - https://flask.palletsprojects.com/en/1.1.x/quickstart/#rendering-templates
return render_template('index.html', todays_date=datetime.now())
title = '1 Star Reviews VS Beer abv (%)'
labels = stats_helper.get_1star_reviews_name()
values = stats_helper.get_1star_reviews_abv()
return render_template('index.html', todays_date=datetime.now(), title= title, labels=labels, values=values)

# HINT: This could be your first statistic!
def get_average_overall_rating():
Expand Down
33 changes: 33 additions & 0 deletions helpers/stats_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,36 @@ def caculate_ave_overall_rating(self):
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_top3_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

def get_1star_reviews_name(self):
all_rows = self.database.fetch_all('SELECT DISTINCT beer_abv FROM reviews WHERE review_overall = 1 AND beer_abv IS NOT NULL GROUP BY beer_abv ORDER BY AVG(beer_abv) ASC')
return all_rows

def get_1star_reviews_abv(self):
all_rows = self.database.fetch_all('SELECT DISTINCT beer_name FROM reviews WHERE review_overall = 1 AND beer_abv IS NOT NULL GROUP BY beer_abv ORDER BY AVG(beer_abv) ASC')
return all_rows

'''
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.
'''