Exemple #1
0
 def impl(self, options):
     basicparse.sqlite_insureColumns(self.conn, 'event', [('combat_id', 'int'),
             ('absorbType', 'str'), ('absorbName', 'str'),
         ])
     
     conn_execute(self.conn, '''drop index if exists ndx_event_combat_time''')
     conn_execute(self.conn, '''drop index if exists ndx_event_combat_source_time''')
     conn_execute(self.conn, '''update event set combat_id = ?''', (0,))
     conn_execute(self.conn, '''create index ndx_event_combat_time on event (combat_id, time)''')
     conn_execute(self.conn, '''create index ndx_event_combat_source_time on event (combat_id, sourceType, sourceName, time)''')
     conn_execute(self.conn, '''create index ndx_event_combat_suffix_spell on event (combat_id, suffix, sourceName)''')
     
     conn_execute(self.conn, '''create table combat (id integer primary key, start_event_id, close_event_id, end_event_id, size int, instance, encounter, dps_list json, healer_list json, tank_list json)''')
     self.conn.commit()
     
     
     print datetime.datetime.now(), "Building combats..."
     require_set = set()
     for name_str in armoryutils.getAllMobs():
         require_set.add('NPC/' + name_str)
         require_set.add('Mount/' + name_str)
         
     combat_list = []
     combat = None
     
     cur = self.conn.cursor()
     cur.execute('''select * from event order by id''')
     event_list = cur.fetchmany()
     
     # This loop is structured oddly so that we don't have to pull in all
     # of the event list into memory at once.  Otherwise, four hours of
     # tens raiding would consume about 400MB of RAM, and that won't work
     # for hosted solutions.
     # Note that combat.finalizeClose has to mess with the DB, so we can't
     # have statements in progress while we fiddle with it.
     while event_list:
         event = event_list.pop(0)
     
         if not combat:
             combat = LogCombat(event)
         elif combat.isOpen():
             combat.addEvent(event)
         else:
             del cur
             
             if combat.prune(require_set):
                 combat.finalizeClose(self.conn, require_set)
                 self.conn.commit()
                 
             del combat
             combat = None
                 
             cur = self.conn.cursor()
             cur.execute('''select * from event where id >= ? order by id''', (event['id'],))
             event_list = []
             
         if not event_list:
             event_list = cur.fetchmany()
             
     del cur
Exemple #2
0
 def impl(self, options):
     print datetime.datetime.now(), "Iterating over combat images (finding stasis parses)..."
     basicparse.sqlite_insureColumns(self.conn, 'combat', [('stasis_path', 'str')])
     for combat in conn_execute(self.conn, '''select * from combat order by start_event_id''').fetchall():
         start_dt = conn_execute(self.conn, '''select time from event where id = ?''', (combat['start_event_id'],)).fetchone()[0]
         
         start_seconds = time.mktime(start_dt.timetuple())
         #print start_seconds
         
         stasis_str = armoryutils.getStasisName(combat['instance'], combat['encounter'])
         
         min_float = 1000.0
         for stasis_path in glob.glob(os.path.join(options.stasis_path, 'sws-%s-*' % stasis_str)):
             try:
                 stasis_seconds = int(stasis_path.rsplit('-', 1)[-1])
                 diff_float = stasis_seconds - start_seconds
                 
                 if diff_float < 60 and diff_float > -10:
                     # Match found!
                     conn_execute(self.conn, '''update combat set stasis_path = ? where id = ?''', (stasis_path, combat['id']))
                     break
                 
                 if abs(diff_float) < abs(min_float):
                     min_float = diff_float
             except:
                 pass
         else:
             print datetime.datetime.now(), "No min diff found:", min_float, stasis_str, start_seconds, glob.glob(os.path.join(options.stasis_path, 'sws-%s-*' % stasis_str))
 
     self.conn.commit()