+
+ maxes={};
+ mins={};
+
+ c=self.db.cursor();
+ c.execute("select time,vcc,glitchcount,count from glitches;"); #Limit 10000 for testing.
+ progress=0;
+ for r in c:
+ progress=progress+1;
+ if progress % 1000000==0: print "%09i rows crunched." % progress;
+ t=r[0];
+ v=r[1];
+ glitchcount=r[2];
+ count=r[3];
+ # FIXME: Threse thresholds suck.
+ if count<2:
+ try: oldmax=maxes[t];
+ except: oldmax=-1;
+ if v>oldmax: maxes[t]=v;
+ elif glitchcount<2:
+ try: oldmin=mins[t];
+ except: oldmin=0x10000;
+ if v<oldmin: mins[t]=v;
+ print "List complete. Inserting.";
+ for t in maxes:
+ max=maxes[t];
+ try: min=mins[t];
+ except: min=0;
+ self.db.execute("insert into glitchrange(time,max,min) values (?,?,?)",(t,max,min));