Skip to content

Commit b696327

Browse files
committed
updates from the last deployment
1 parent 17d62b1 commit b696327

File tree

5 files changed

+32
-41
lines changed

5 files changed

+32
-41
lines changed

app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def app_page(name):
3131
abort(404)
3232
if app.name != name:
3333
return redirect(f"/{app.name}")
34+
35+
site = Site(app.name)
36+
status = site.get_status()
37+
app.update_status(status)
3438
return render_template("app.html", app=app, tasks=TASKS)
3539

3640
@app.route("/<name>/deploy", methods=["POST"])
@@ -52,4 +56,4 @@ def app_deploy(name):
5256
return jsonify(status)
5357

5458
if __name__ == "__main__":
55-
app.run()
59+
app.run(port=5050)

db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _update(self, **kwargs):
6464
db.update("app", **kwargs, where="id=$id", vars={"id": self.id})
6565

6666
def update_score(self):
67-
rows = db.where("task", app_id=self.id).list()
67+
rows = db.where("task", app_id=self.id, status='pass').list()
6868
score = len(rows)
6969
self._update(score=score)
7070

tasks.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def login(self, email):
7575

7676
def sync(self):
7777
try:
78-
hamr.sync_app(self.name)
78+
#hamr.sync_app(self.name)
79+
pass
7980
except HamrError as e:
8081
return HamrResponse(ok=False, message=str(e))
8182

@@ -167,6 +168,8 @@ def validate(self, site):
167168
except CheckFailed as e:
168169
return status.fail(str(e))
169170
except Exception as e:
171+
import traceback
172+
traceback.print_exc()
170173
return status.error(str(e))
171174

172175
def do_validate(self, site):
@@ -327,12 +330,26 @@ def do_validate(self, site):
327330
response = site.post("/book-ticket", data=data)
328331
response.raise_for_status()
329332

333+
334+
q = """SELECT * FROM booking ORDER BY id DESC LIMIT 1"""
335+
result = site.query(q)
336+
if not result:
337+
raise CheckFailed("Could not find any bookings")
338+
339+
row = result[0]
340+
341+
342+
for k in "train_number ticket_class date passenger_name passenger_email".split():
343+
if k not in row:
344+
raise CheckFailed(f"Missing {k!r} column in table booking")
345+
330346
q = """
331347
SELECT
332-
train_number, ticket_class, date,
333-
from_station_code, to_station_code,
334-
passenger_name, passenger_email
335-
FROM booking
348+
b.train_number, b.ticket_class, b.date,
349+
b.passenger_name, b.passenger_email,
350+
t.from_station_code, t.to_station_code
351+
FROM booking b
352+
JOIN train t ON b.train_number=t.number
336353
ORDER BY id DESC
337354
LIMIT 1
338355
"""
@@ -389,7 +406,7 @@ def __init__(self, bookings):
389406
self.passenger_email = "[email protected]"
390407

391408
def get_bookings_from_html(self, html):
392-
soup = BeautifulSoup(html)
409+
soup = BeautifulSoup(html, "lxml")
393410
booking_cards = soup.find_all("div", class_="card")
394411
for card in booking_cards:
395412
card_header = card.find("div", class_="card-header").get_text()

tasks.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@ description: |
282282
and passenger details and books a ticket by adding an entry
283283
in the database table.
284284
285-
After booking a ticket, the number of available seats for that
286-
train in the booked ticket class should be reduced by one.
287-
288285
File: `rajdhani/db.py` <br>
289286
Function: `book_ticket`
290287
checks:
@@ -300,35 +297,6 @@ checks:
300297
date: "2022-12-01"
301298

302299

303-
---
304-
name: email-conformation
305-
title: Send an email to confirm the successful booking
306-
description: |
307-
Send an email to the passenger confirming the reservation.
308-
You can use the SMTP credentials from `config.py` to do that.
309-
310-
The booking argument is a dict with keys: `id`, `passenger_name`,
311-
`passenger_email`, `train_number`, `train_name`, `ticket_class`, and `date`.
312-
313-
Note: For testing locally, you can install the
314-
[aiosmtpd](https://aiosmtpd.readthedocs.io/en/latest/) package with pip
315-
and start an SMTP server on port 8025 with `python3 -m aiosmtpd -n`.
316-
317-
File: `rajdhani/notifications.py` <br>
318-
Function: `send_booking_confirmation`
319-
checks:
320-
- check_ticket_confirmation_email:
321-
train: "12028"
322-
ticket_class: "CC"
323-
date: "2022-09-30"
324-
passenger_name: "Eva Lu Ator"
325-
passenger_email: "[email protected]"
326-
- check_ticket_confirmation_email:
327-
train: "16227"
328-
ticket_class: "FC"
329-
date: "2022-09-28"
330-
passenger_name: "Lem E Tweakit"
331-
passenger_email: "[email protected]"
332300
---
333301
name: login-and-trips
334302
title: Enable login and show trips for the user

templates/app.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ <h1 class="mb-0">{{app.name}}</h1>
3434
<a href="https://{{ app.name }}.rajdhani.pipal.in" class="text-decoration-none" target="_blank">
3535
Visit website
3636
</a>
37+
<!--
3738
| <a href="https://github.com/{{app.name}}/rajdhani">Github</a>
39+
-->
3840
</div>
3941
<div>{{app.score}} tasks completed | Current Task: {{ app.current_task }} | Last updated {{datestr(app.last_updated) }}</div>
4042
</div>
@@ -93,7 +95,7 @@ <h5>Checks</h5>
9395

9496
<div class="my-3">
9597
<h2>Change Log</h2>
96-
{% for entry in app.get_changelog() %}
98+
{% for entry in app.get_changelog()[:10] %}
9799
<div>{{datestr(entry.timestamp)}} - {{entry.type}} - {{entry.message}}</div>
98100
{% endfor %}
99101
</div>

0 commit comments

Comments
 (0)