diff --git a/gracedb/query.py b/gracedb/query.py index 359702db580e80ba38fd519dc6e002fcf1cce21a..d326b3f6f5feb952173328369bab31cfea2f0abd 100644 --- a/gracedb/query.py +++ b/gracedb/query.py @@ -15,6 +15,7 @@ from nltime import nlTimeExpression as nltime_ nltime = nltime_.setParseAction(lambda toks: toks["calculatedTime"]) +import time, datetime import models from django.db.models import Q @@ -58,7 +59,8 @@ gpsQ = gpsQ.setParseAction(maybeRange("gpstime")) # Analysis Groups groupNames = [group.name for group in models.Group.objects.all()] group = Or(map(CaselessLiteral, groupNames)).setName("analysis group name") -groupList = delimitedList(group, delim='|').setName("analysis group list") +#groupList = delimitedList(group, delim='|').setName("analysis group list") +groupList = OneOrMore(group).setName("analysis group list") groupQ = (Optional(Suppress(Keyword("group:"))) + groupList) groupQ = groupQ.setParseAction(lambda toks: ("group", Q(group__name__in=toks.asList()))) @@ -85,8 +87,23 @@ hidQ = Optional(Suppress(Keyword("hid:"))) + (hid^hidRange) hidQ = hidQ.setParseAction(maybeRange("hid", dbname="id")) # Created times + nltimeRange = nltime + Suppress("..") + nltime -createdQ = Optional(Suppress(Keyword("created:"))) + (nltime^nltimeRange) + +def doTime(tok): + x = datetime.datetime(*(map(int, tok))) + return x + +dash = Suppress('-') +colon = Suppress(':') +date_ = Regex(r'\d{4}') + dash + Regex(r'\d{2}') + dash + Regex(r'\d{2}') +dt = date_ + Optional(Regex(r'\d{2}')+colon+Regex(r'\d{2}')+ + Optional(colon+Regex(r'\d{2}'))) +dt.setParseAction(doTime) + +dtrange = dt + Suppress("..") + dt + +createdQ = Optional(Suppress(Keyword("created:"))) + (nltime^nltimeRange^dt^dtrange) createdQ = createdQ.setParseAction(maybeRange("created")) @@ -107,14 +124,8 @@ labelQ_ = operatorPrecedence(label, labelQ = labelQ_.copy().setParseAction(lambda toks: ("label", toks[0])) -# Date/Time -# XXX Not yet included... requires conversion to gps. -dateTime = Regex(r'\d{4}/\d{2}/\d{2}(-\d{2}:\d{2}(:\d{2})?( ?[A-Z]{3,4})?)?') -dateQ = (Optional(Suppress(Keyword("date:"))) + dateTime).\ - setParseAction(doDate) - -q = (gidQ | hidQ | atypeQ | groupQ | gpsQ | labelQ | createdQ).setName("query term") +q = (gidQ | hidQ | atypeQ | groupQ | labelQ | createdQ | gpsQ).setName("query term") def parseQuery(s): d={} diff --git a/templates/gracedb/event_list.html b/templates/gracedb/event_list.html index 927124b991ca3918fdcdc15afbc438a4ffe1a654..169706f0d4381623f3688424e38473c54258942f 100644 --- a/templates/gracedb/event_list.html +++ b/templates/gracedb/event_list.html @@ -5,6 +5,21 @@ {% block heading %}{{ title }}{% endblock %} {% block pageid %}search{% endblock %} +{% block jscript %} + <script type="text/javascript"> + <!-- + function toggle_visibility(id) { + var e = document.getElementById(id); + if(e.style.display == 'block') + e.style.display = 'none'; + else + e.style.display = 'block'; + } + //--> + </script> +{% endblock %} + + {% block content %} <p>{{ message }}</p> @@ -12,6 +27,7 @@ <form action="{{ formAction }}"method="POST"> {{ form.as_table }} <a href="{{queryLink}}">Link</a> </form> + {% include "gracedb/query_help_frag.html" %} {% endif %} {% if object_list.count %} diff --git a/templates/gracedb/query.html b/templates/gracedb/query.html index e6cd88a3a8426823554dbdacfe2344c729d03f99..0c2d5733532b78439e4825ad0f93167596560d99 100644 --- a/templates/gracedb/query.html +++ b/templates/gracedb/query.html @@ -4,26 +4,34 @@ {% block heading %}Search{% endblock %} {% block pageid %}search{% endblock %} +{% block jscript %} + <script type="text/javascript"> + <!-- + function toggle_visibility(id) { + var e = document.getElementById(id); + if(e.style.display == 'block') + e.style.display = 'none'; + else + e.style.display = 'block'; + } + //--> + </script> +{% endblock %} + {% block content %} -<dl> -<dt>Hints on querying:</dt> -<dd> - <ul> - <li>Limit results to a set of groups or analysis types by typing group or analysis type names.</li> - <li>Limit results to GPS times or time ranges by typing a GPS time or range, eg <code>941367090..941418534</code> or <code>941418534</code>.</li> - <li>Limit results to a range of graceids, <code>G0770..G0900</code>.</li> - <li>Limit results to events with certain labels, eg <code>LUMIN_GO</code> or <code>DQV</code>.</li> - </ul> -</dd> -</dl> <form method="POST"> - <table> - {{ form.as_table }} - <tr><td></td><td><input type="Submit"/></td></tr> - </table> + <table> + {{ form.as_table }} + <tr><td></td><td><input type="Submit"/></td></tr> + <tr><td></td> + <td>{% include "gracedb/query_help_frag.html" %}</td> + </tr> + </table> </form> +<!-- Old style Query --> + {% if form2 %} <hr/> <h4>Simple Query</h4> diff --git a/templates/gracedb/query_help_frag.html b/templates/gracedb/query_help_frag.html new file mode 100644 index 0000000000000000000000000000000000000000..10e9e8952f448271d2f0a9952ca6cc777abfde17 --- /dev/null +++ b/templates/gracedb/query_help_frag.html @@ -0,0 +1,54 @@ + +<a onClick="toggle_visibility('hints');">Hints on querying:</a> +<div id="hints" style="display: none;"> + <h5>By GPS Time</h5> + Specifiy an exact GPS time, or a range. + Integers will be assumed to be GPS times, making the <code>gpstime:</code> + keyword optional. + <ul style="blank"> + <li><code>999999000..999999999</code></li> + <li><code>gpstime: 999999999</code></li> + <li><code>gpstime: 999999000..999999999</code></li> + </ul> + + <h5>By Creation Time</h5> + Creation time may be indicated by an exact time or a range. Date/times are + in the format <code>2009-10-20 13:00:00</code>. If the time is omitted, it + is assumed to be <code>00:00:00</code>. Dates may also consist of certain + variants of English-like phrases. + The <code>created:</code> keyword is (generally) optional. + <ul> + <li><code>created: 2009-10-08 .. 2009-12-04 16:00:00</code></li> + <li><code>yesterday..now</code></li> + <li><code></code></li> + <li><code>created: 1 week ago .. now</code></li> + </ul> + + <h5>By Graceid</h5> + GraceIds can be specified either individually, or as a range. + The <code>gid:</code> keyword is optional. + <ul> + <li>gid: G2011</li> + <li>G2011..G3000</li> + <li>G2011 G2032 G2033</li> + </ul> + + <h5>By Group and Analysis Type</h5> + The <code>group:</code> and <code>type:</code> keywords are optional. Group and analysis type names are case-insensitive. Note that events in the Test group will not be shown unless explicitly requested. + <ul> + <li>CBC Burst</li> + <li>Inspiral CWB</li> + <li>group: Test type: cwb</li> + <li>Burst Omega</li> + </ul> + + <h5>By Label</h5> + You may request only events that have a certain label. The <code>label:</code> keyword + is optional. Note that specifying multiple labels is an "OR" operation. More complex + expressiveness is on the 'todo' list. + <ul> + <li>label: INJ</li> + <li>DQV LUMIN_GO</li> + </ul> + +</div>