From 8463ce58ce8b0c9dea5e7f6a79f565fbf2647b20 Mon Sep 17 00:00:00 2001
From: alex501212 <56118464+alex501212@users.noreply.github.com>
Date: Fri, 16 Oct 2020 22:57:38 +0100
Subject: [PATCH 1/2] final
---
.idea/bvcodingchallenge-sampleapp.iml | 10 ++++++++
.idea/misc.xml | 4 +++
application.py | 5 +++-
helpers/stats_helper.py | 36 +++++++++++++++++++++++++++
4 files changed, 54 insertions(+), 1 deletion(-)
create mode 100644 .idea/bvcodingchallenge-sampleapp.iml
create mode 100644 .idea/misc.xml
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..39a4a98 100644
--- a/helpers/stats_helper.py
+++ b/helpers/stats_helper.py
@@ -12,6 +12,42 @@ def caculate_ave_overall_rating(self):
return result[0]
# HINT: You can define more queries here, along with some python logic to calculate!
+<<<<<<< Updated upstream
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.
+'''
+>>>>>>> Stashed changes
From c0663a6143b72b0921cc5bcbac6e887ee2dc185f Mon Sep 17 00:00:00 2001
From: alex501212 <56118464+alex501212@users.noreply.github.com>
Date: Fri, 16 Oct 2020 22:58:23 +0100
Subject: [PATCH 2/2] final
---
helpers/stats_helper.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/helpers/stats_helper.py b/helpers/stats_helper.py
index 39a4a98..af20276 100644
--- a/helpers/stats_helper.py
+++ b/helpers/stats_helper.py
@@ -12,11 +12,9 @@ def caculate_ave_overall_rating(self):
return result[0]
# HINT: You can define more queries here, along with some python logic to calculate!
-<<<<<<< Updated upstream
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
@@ -49,5 +47,4 @@ def get_1star_reviews_abv(self):
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.
-'''
->>>>>>> Stashed changes
+'''
\ No newline at end of file