Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tiny PR #112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This project is done for Altech (Schneider Electric Iran) as an educational seri
کل ویدئوها رو می تونین از لینک های زیر ببینین.
</div>

Every single step of this project is screen captures and you can follow them [On youtube](https://www.youtube.com/playlist?list=PL-tKrPVkKKE1vAT_rgjnvL_RgFUI9oJ9a) or [On Aparat](https://www.aparat.com/v/fAZSV?playlist=288572).
Every single step of this project is screen captured and you can follow them [On youtube](https://www.youtube.com/playlist?list=PL-tKrPVkKKE1vAT_rgjnvL_RgFUI9oJ9a) or [On Aparat](https://www.aparat.com/v/fAZSV?playlist=288572).

## How to run
1. Install python3, pip3, virtualenv, MySQL in your system.
Expand Down
36 changes: 16 additions & 20 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,25 @@ def home():
smss.append({'status': status, 'sender': sender, 'message': message, 'answer': answer, 'date': date})

# collect some stats for the GUI
num_ok = 'error'
num_failure = 'error'
num_double = 'error'
num_notfound = 'error'
try:
cur.execute("SELECT count(*) FROM PROCESSED_SMS WHERE status = 'OK'")
num_ok = cur.fetchone()[0]
except:
num_ok = 'error'

try:
cur.execute("SELECT count(*) FROM PROCESSED_SMS WHERE status = 'FAILURE'")
num_failure = cur.fetchone()[0]
except:
num_failure = 'error'
cur.execute("SELECT status, COUNT(*) FROM PROCESSED_SMS GROUP BY status")
all_stats = cur.fetchall()
for stat in all_stats:
if stat[0] == 'OK':
num_ok = stat[1]
elif stat[0] == 'FAILURE':
num_failure = stat[1]
elif stat[0] == 'DOUBLE':
num_double = stat[1]
elif stat[0] == 'NOT-FOUND':
num_notfound = stat[1]

try:
cur.execute("SELECT count(*) FROM PROCESSED_SMS WHERE status = 'DOUBLE'")
num_double = cur.fetchone()[0]
except:
num_double = 'error'

try:
cur.execute("SELECT count(*) FROM PROCESSED_SMS WHERE status = 'NOT-FOUND'")
num_notfound = cur.fetchone()[0]
except:
num_notfound = 'error'
pass

return render_template('index.html', data={'smss': smss, 'ok': num_ok, 'failure': num_failure, 'double': num_double,
'notfound': num_notfound})
Expand Down