Don't store duration in db
This commit is contained in:
		
							parent
							
								
									20218372d5
								
							
						
					
					
						commit
						7a8b027716
					
				| 
						 | 
				
			
			@ -20,7 +20,6 @@ class Database(object):
 | 
			
		|||
                    fingerprint text NOT NULL,
 | 
			
		||||
                    start text NOT NULL,
 | 
			
		||||
                    end text NOT NULL,
 | 
			
		||||
                    duration long NOT NULL,
 | 
			
		||||
                    filecount long NOT NULL);"""
 | 
			
		||||
        self.conn.execute(query)
 | 
			
		||||
        self.commit()
 | 
			
		||||
| 
						 | 
				
			
			@ -28,5 +27,5 @@ class Database(object):
 | 
			
		|||
    def insert(self, log_entry: LogEntry):
 | 
			
		||||
        query = f"INSERT INTO {self.table_name} (name, fingerprint, start, end, duration, filecount) VALUES(?,?,?,?,?)"
 | 
			
		||||
        self.conn.execute(query, (log_entry.name, log_entry.fingerprint, log_entry.start_time, log_entry.end_time,
 | 
			
		||||
                                  log_entry.duration, log_entry.file_count))
 | 
			
		||||
                                  log_entry.file_count))
 | 
			
		||||
        self.commit()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
from datetime import *
 | 
			
		||||
from datetime import datetime
 | 
			
		||||
from math import floor
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -23,12 +24,12 @@ class LogEntry(object):
 | 
			
		|||
                             f"file_count: {self.file_count}"])
 | 
			
		||||
 | 
			
		||||
    def get_duration(self, duration_string):
 | 
			
		||||
        total_seconds = 0.0
 | 
			
		||||
        total_seconds = 0
 | 
			
		||||
        time_strings = [('second', 1), ('minute', 60), ('hour', 3600), ('day', 86400)]
 | 
			
		||||
        for ts, mult in time_strings:
 | 
			
		||||
            total_seconds += self.get_time_unit_string(duration_string, ts, mult)
 | 
			
		||||
 | 
			
		||||
        return total_seconds
 | 
			
		||||
        return floor(total_seconds)
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def get_time_unit_string(text: str, time_text: str, multiplier: int = 1):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user