-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport_tool.py
More file actions
38 lines (25 loc) · 828 Bytes
/
Copy pathreport_tool.py
File metadata and controls
38 lines (25 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python2.7
import dbmanager
def run():
""" Start the reporting tool """
question_1()
print "\n"
question_2()
print "\n"
question_3()
def question_1():
print "Q1. What are the most popular three articles of all time?\n"
rows = dbmanager.get_most_popular_articles()
for row in rows:
print "\t%s - %d views" % (row[0], row[1])
def question_2():
print "Q2. Who are the most popular article authors of all time?\n"
rows = dbmanager.get_most_popular_authors()
for row in rows:
print "\t%s - %d views" % (row[0], row[1])
def question_3():
print "Q3. On which days did more than 1% of requests lead to errors?\n"
rows = dbmanager.get_days_with_more_errors()
for row in rows:
print "\t%s - %s errors" % (row[0], row[1])
run()