Version 36 (modified by 12 years ago) ( diff ) | ,
---|
Table of Contents
Allow person entities (people, groups, organisations) to save a search and be notified when the results change.
Overview
In an event of disaster, this functionality would help a lot in terms of providing information (take the example of dissemination of information related to availability of food, shelter, hospitals etc.). The project's essential capability is to disseminate information about various aspects through various means such as email/twitter/sms. Integrating this service into a Sahana Eden system will add to the platforms' capability of tackling various issues faced in emergency/disaster management.
Models
A single model for holding information about the search query and the parameters that are saved by the user. This will be in /modules/eden/pr.py
as a component of pr_entity
.
- name
- Name of the saved search as specified by the user.
- pe_id
- The person entity to be notified when the search results change. Defaults to the pe_id record associated with the current user account.
- query
- The query string for the search.
- notification_format
- Format for the notification, either a list (default), map, report, graph (this is a report).
- notification_method
- Subscription mode, e.g., email (default), Twitter, SMS.
- notification_frequency
- How often the search is checked for changes, e.g., never (default), every 15 minutes (not hourly?), daily, weekly and monthly.
- last_executed
-
The date and time the search was last executed by the subscription method. Set to match
modified_on
when record is first created. - public
-
Is this saved search viewable to everyone? This should trigger an authorisation process. Boolean, default is
False
. - comments
- Reusable comments field for the user to write in.
Views
A standard REST controller will be used to manage the saved searches, rather than custom controllers and methods. One custom method, "load", will be used to execute the search (redirect the user to the query URL).
Search
Each search page will have a widget the user can activate to save the current search. They will be directed to a new page where they can type a name for the search.
Saved Search List
Each person entity has a component for saved searches. This page will list all searches saved for this person entity, displaying the name of the search (as defined by the user when it was saved) and the query parameters.
Given the following search query string
organisation.country__belongs=NZ&organisation.organisation_type_id__belongs=2&organisation.sector_id__anyof=1%2C2&parent.acronym%7Cparent.name%7Cacronym%7Cname__like=%2Ared%2A
The user should see
Search=red AND Type=Red Cross / Red Crescent AND Sector=DRR,Food Security AND Home Country=New Zealand
Any field that has no matching representation should be omitted.
The user will have three options for each search record:
- run executes the search
- edit allows the user to edit the saved search record
- delete deletes the saved search record
Saved Search Edit
A page to edit a saved search. The name
, pe_id
, notification_format
, notification_method
and notification_frequency
can be changed here.
Process
Saving a search
- User searches a resource
- If the search has no errors, a "Save this search" button is shown next to the submit ("Search") button in the search form.
- The filters, added to the current resource using add_filter(), are extracted from the resource and stored as a pickled string.
- This button POSTs an s3json request to a save_search REST controller.
- The s3json contains the prefix, resource_name, and the filters applied to the resource.
Notifications
- Subscription notifications are sent by a cron task sending a request to
/msg/search_subscription_notifications/
- The first query string argument specifies what period this applies to, e.g., daily, monthly, etc.
- The controller fetches the saved searches with that frequency.
- The resource is created, and the filters are applied.
- The resource, with filters, and saved search record is passed to a notification function for the specific notification_method of each saved search.
- Records with a
modified_on
value greater thanlast_executed
are added to the message. - Format the response for special media, e.g., Twitter, SMS.
- The message is sent via the method specified.
last_executed
field updated to when the request was made.
Tasks
Phase I
- Implement model
- Implement representation functions for query string
- Implement or update controllers
/msg/search_notifications/
to be called via cron, first argument is the frequency.- Records with a
modified_on
value greater thanlast_executed
are returned.
Phase II
- Expand
/msg/search_notifications/
to notify all people within a pr_group by fetching the relevant contact details from all members. - Add formatters/codecs to format the response for Twitter, SMS, etc.
- Extend OAuth implementation for Twitter and Facebook to allow posting to users account.
Tests
- Save a search without any filters.
- Save a search after performing a search with filters.
- Attempt to save a search with empty name; must fail.
- Delete a saved search.
- Edit and save a saved search.
- Executing a search from the saved search list page.
- Send notification email.
Attachments (4)
-
myImage.png
(68.5 KB
) - added by 14 years ago.
save_search widget
-
myImage (1).png
(74.1 KB
) - added by 14 years ago.
Saved Searches Page
- myImage (2).png (88.3 KB ) - added by 14 years ago.
- myImage (3).png (80.3 KB ) - added by 14 years ago.
Download all attachments as: .zip