|
31 | 31 | from notifications.models import Subscription, SurgeAlert |
32 | 32 | from notifications.notification import send_notification |
33 | 33 | from registrations.models import Recovery, Pending |
34 | | -from deployments.models import Project, ERU |
| 34 | +from deployments.models import Project, ERU, Personnel |
35 | 35 | from flash_update.models import FlashUpdate |
36 | 36 | from dref.models import Dref, DrefOperationalUpdate |
37 | 37 |
|
@@ -201,7 +201,11 @@ def get(self, request): |
201 | 201 | dref_operational_update_response = SearchQuerySet().models(DrefOperationalUpdate).filter( |
202 | 202 | SQ(name__contains=phrase) | SQ(code__contains=phrase) | SQ(iso3__contains=phrase) |
203 | 203 | ).order_by('-_score') |
204 | | - |
| 204 | + rapid_response_deployments = SearchQuerySet().models(Personnel).filter( |
| 205 | + SQ(deploying_country_name__contains=phrase) | |
| 206 | + SQ(deployed_to_country_name__contains=phrase) | |
| 207 | + SQ(event_name__content=phrase) |
| 208 | + ).order_by('-_score') |
205 | 209 | appeals_list = [] |
206 | 210 | dref = [ |
207 | 211 | { |
@@ -355,7 +359,24 @@ def get(self, request): |
355 | 359 | } for data in surge_deployments[:50] |
356 | 360 | ], |
357 | 361 | "reports": sorted(field_report, key=lambda d: d["score"], reverse=True)[:50], |
358 | | - "emergency_planning": sorted(appeals_list, key=lambda d: d["score"], reverse=True)[:50] |
| 362 | + "emergency_planning": sorted(appeals_list, key=lambda d: d["score"], reverse=True)[:50], |
| 363 | + "rapid_response_deployments": [ |
| 364 | + { |
| 365 | + "id": int(data.id.split(".")[-1]), |
| 366 | + "name": data.name, |
| 367 | + "start_date": data.start_date, |
| 368 | + "end_date": data.end_date, |
| 369 | + "postion": data.postion, |
| 370 | + "type": data.type, |
| 371 | + "deploying_country_name": data.deploying_country_name, |
| 372 | + "deploying_country_id": data.deploying_country_id, |
| 373 | + "deployed_to_country_name": data.deployed_to_country_name, |
| 374 | + "deployed_to_country_id": data.deployed_to_country_id, |
| 375 | + "event_name": data.event_name, |
| 376 | + "event_id": data.event_id, |
| 377 | + "score": data.score, |
| 378 | + } for data in rapid_response_deployments[:50] |
| 379 | + ], |
359 | 380 | } |
360 | 381 | return Response(result) |
361 | 382 |
|
|
0 commit comments