Commits

Ada Young  committed 7c05aec

Removed stray debug note, now using bulk insert instead of iterating through the logs for better performance

  • Participants
  • Parent commits 08fba34

Comments (0)

Files changed (1)

         return results[0][0]
 
 def ProcessLogs(orgname, lognotes, orgid):
+    import_map = []
     for i in lognotes:
         splitlog = i.split('-')
         timestamp = "-".join(splitlog[:3])
         cursor.execute("SELECT * FROM org_logs l join orgs o on l.orgid=o.id WHERE o.orgname=? AND l.timestamp=datetime(?) AND l.message=?", (orgname, timestamp, message))
         results = cursor.fetchall()
         if not len(results) > 0:
-            cursor.execute("INSERT INTO org_logs (orgid, timestamp, message) VALUES (?, datetime(?), ?)", (orgid, timestamp, message))
+            import_map.append((orgid, timestamp, message))
+    cursor.executemany("INSERT INTO org_logs (orgid, timestamp, message) VALUES (?, datetime(?), ?)", import_map)
     db.commit()
 
 def ValidateOrgname(orgname):
     datefrom = datefrom.strftime("%Y-%m-%d %H:%M:%S")
     dateto = dateto.strftime("%Y-%m-%d %H:%M:%S")
 
-    Note("%s - %s" % (datefrom, dateto))
     cursor.execute("SELECT timestamp, message FROM org_logs l join orgs o on l.orgid=o.id WHERE o.orgname=? AND l.timestamp>=datetime(?) AND l.timestamp<datetime(?) ORDER BY l.timestamp ASC", (orgname, datefrom, dateto))
     results = cursor.fetchall()
     Note("General log for %s:" % orgname)