Commit 03c194bff3befc691b5c908c2ff1d0a39d07ea74
1 parent
d61e225e
Exists in
master
Actually implement the queue of estimations.
Showing
2 changed files
with
14 additions
and
1 deletions
Show diff stats
flaskr/controllers/main_controller.py
... | ... | @@ -70,6 +70,13 @@ def compute(): # process the queue of estimation requests |
70 | 70 | |
71 | 71 | response = "" |
72 | 72 | |
73 | + count_working = Estimation.query \ | |
74 | + .filter_by(status=StatusEnum.working) \ | |
75 | + .count() | |
76 | + | |
77 | + if 0 < count_working: | |
78 | + return _respond("Already working on estimation.") | |
79 | + | |
73 | 80 | try: |
74 | 81 | estimation = Estimation.query \ |
75 | 82 | .filter_by(status=StatusEnum.pending) \ |
... | ... | @@ -83,7 +90,12 @@ def compute(): # process the queue of estimation requests |
83 | 90 | if not estimation: |
84 | 91 | return _respond("No estimation in the queue.") |
85 | 92 | |
86 | - response += u"Processing estimation `%s` of `%s`...\n" % (estimation.id, estimation.email) | |
93 | + estimation.status = StatusEnum.working | |
94 | + db.session.commit() | |
95 | + | |
96 | + response += u"Processing estimation `%s`...\n" % ( | |
97 | + estimation.public_id | |
98 | + ) | |
87 | 99 | |
88 | 100 | geocoder = CachedGeocoder() |
89 | 101 | ... | ... |