Skip to content
Snippets Groups Projects
Commit fe3cf522 authored by Brian Moe's avatar Brian Moe
Browse files

Test events now have graceid's starting with "T"

parent 97fed535
No related branches found
No related tags found
No related merge requests found
......@@ -83,6 +83,8 @@ class Event(models.Model):
def graceid(self):
if self.uid:
return self.uid
elif self.group.name == "Test":
return "T%04d" % self.id
elif self.analysisType == "HWINJ":
return "H%04d" % self.id
return "G%04d" % self.id
......@@ -121,13 +123,15 @@ class Event(models.Model):
@classmethod
def getByGraceid(cls, id):
if id[0] not in "GH":
if id[0] not in "GHT":
# Very old, probably useless data.
return cls.objects.get(uid=id)
e = cls.objects.get(id=int(id[1:]))
if (id[0] == "G" and e.analysisType != "HWINJ") or (id[0]=="H" and e.analysisType =="HWINJ"):
return e
raise cls.DoesNotExist()
if (id[0] == "T") and (e.group.name != "Test"):
raise cls.DoesNotExist()
if (id[0] == "H") and (e.analysisType == "HWINJ"):
raise cls.DoesNotExist()
return e
class EventLog(models.Model):
class Meta:
......
......@@ -86,6 +86,12 @@ hidRange = hid + Suppress("..") + hid
hidQ = Optional(Suppress(Keyword("hid:"))) + (hid^hidRange)
hidQ = hidQ.setParseAction(maybeRange("hid", dbname="id"))
# test event id
tid = Suppress("T")+Word("0123456789")
tidRange = tid + Suppress("..") + tid
tidQ = Optional(Suppress(Keyword("tid:"))) + (tid^tidRange)
tidQ = tidQ.setParseAction(maybeRange("tid", dbname="id"))
# Created times
nltimeRange = nltime + Suppress("..") + nltime
......@@ -126,18 +132,20 @@ labelQ = (Optional(Suppress(Keyword("label:"))) + labelQ_.copy())
labelQ.setParseAction(lambda toks: ("label", toks[0]))
q = (gidQ | hidQ | atypeQ | groupQ | labelQ | createdQ | gpsQ).setName("query term")
q = (gidQ | hidQ | tidQ | atypeQ | groupQ | labelQ | createdQ | gpsQ).setName("query term")
def parseQuery(s):
d={}
for (tag, qval) in (stringStart + OneOrMore(q) + stringEnd).parseString(s).asList():
d[tag] = d.get(tag,Q()) | qval
if s.find("Test") < 0:
# Test group is not mentioned in the query, so we exclude it.
if s.find("Test") < 0 and "tid" not in d:
# If Test group is not mentioned in the query, we exclude it.
if "group" in d:
d["group"] &= ~Q(group__name="Test")
else:
d["group"] = ~Q(group__name="Test")
if "tid" in d:
d["tid"] = d["tid"] & Q(group__name="Test")
if "hid" in d:
d["hid"] = d["hid"] & Q(analysisType="HWINJ")
if "id" in d:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment