From fe3cf522984432984e838986759000065dde9ff1 Mon Sep 17 00:00:00 2001 From: Brian Moe <lars@moe.phys.uwm.edu> Date: Fri, 18 Dec 2009 16:15:43 -0600 Subject: [PATCH] Test events now have graceid's starting with "T" --- gracedb/models.py | 12 ++++++++---- gracedb/query.py | 14 +++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/gracedb/models.py b/gracedb/models.py index 0fb74fc60..ad17460d5 100644 --- a/gracedb/models.py +++ b/gracedb/models.py @@ -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: diff --git a/gracedb/query.py b/gracedb/query.py index 2ce6fba52..3d042a842 100644 --- a/gracedb/query.py +++ b/gracedb/query.py @@ -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: -- GitLab