diff --git a/.idea/bvcodingchallenge-sampleapp.iml b/.idea/bvcodingchallenge-sampleapp.iml
new file mode 100644
index 0000000..155650d
--- /dev/null
+++ b/.idea/bvcodingchallenge-sampleapp.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..3e46745
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/application.py b/application.py
index 3c7a40f..6a18466 100644
--- a/application.py
+++ b/application.py
@@ -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():
diff --git a/helpers/stats_helper.py b/helpers/stats_helper.py
index a68dcdb..af20276 100644
--- a/helpers/stats_helper.py
+++ b/helpers/stats_helper.py
@@ -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.
+'''
\ No newline at end of file