@@ -70,15 +70,21 @@ def process_cdx(cls, cdxfile, csvfile):
70
70
cls .db .set_index_complete ()
71
71
else :
72
72
vb .write (verbose = True , content = "\n Already indexed snapshots" )
73
- if cls .MODE_LAST or cls .MODE_FIRST :
74
- if not cls .db .get_filter_complete ():
75
- vb .write (content = "\n Filtering snapshots (last or first version)..." )
76
- cls .filter_snapshots () # filter: keep newest or oldest based on MODE
77
- cls .db .set_filter_complete ()
78
- else :
79
- vb .write (verbose = True , content = "\n Already filtered snapshots (last or first version)" )
73
+ if not cls .db .get_filter_complete ():
74
+ vb .write (content = "\n Filtering snapshots (last or first version)..." )
75
+ cls .filter_snapshots () # filter: keep newest or oldest based on MODE
76
+ cls .db .set_filter_complete ()
77
+ else :
78
+ vb .write (verbose = True , content = "\n Already filtered snapshots (last or first version)" )
80
79
81
80
cls .skip_set (csvfile ) # set response to NULL or read csv file and write values into db
81
+
82
+
83
+
84
+
85
+
86
+ @classmethod
87
+ def calculate (cls ):
82
88
cls .SNAPSHOT_UNHANDLED = cls .count_totals (unhandled = True ) # count all unhandled in db
83
89
cls .SNAPSHOT_HANDLED = cls .count_totals (handled = True ) # count all handled in db
84
90
cls .SNAPSHOT_TOTAL = cls .count_totals (total = True ) # count all in db
@@ -96,7 +102,8 @@ def process_cdx(cls, cdxfile, csvfile):
96
102
if cls .FILTER_RESPONSE > 0 :
97
103
vb .write (content = f"-----> { 'skip statuscode' .ljust (18 )} : { cls .FILTER_RESPONSE } " )
98
104
99
- vb .write (content = f"\n -----> { 'to utilize' .ljust (18 )} : { cls .SNAPSHOT_UNHANDLED :,} " )
105
+ if cls .SNAPSHOT_UNHANDLED > 0 :
106
+ vb .write (content = f"\n -----> { 'to utilize' .ljust (18 )} : { cls .SNAPSHOT_UNHANDLED :,} " )
100
107
101
108
102
109
@@ -179,9 +186,6 @@ def csv_create(cls, csvfile):
179
186
cls .db .cursor .execute ("UPDATE snapshot_tbl SET response = NULL WHERE response = 'LOCK'" ) # reset locked to unprocessed
180
187
cls .db .cursor .execute ("SELECT * FROM csv_view WHERE response IS NOT NULL" ) # only write processed snapshots
181
188
headers = [description [0 ] for description in cls .db .cursor .description ]
182
- if "snapshot_id" in headers :
183
- snapshot_id_index = headers .index ("snapshot_id" )
184
- headers .pop (snapshot_id_index )
185
189
with open (csvfile , "w" , encoding = "utf-8" ) as f :
186
190
writer = csv .writer (f )
187
191
writer .writerow (headers )
@@ -341,9 +345,9 @@ def count_totals(cls, total=False, handled=False, unhandled=False, success=False
341
345
if unhandled :
342
346
return cls .db .cursor .execute ("SELECT COUNT(rowid) FROM snapshot_tbl WHERE response IS NULL" ).fetchone ()[0 ]
343
347
if success :
344
- return cls .db .cursor .execute ("SELECT COUNT(rowid) FROM snapshot_tbl WHERE file IS NOT NULL" ).fetchone ()[0 ]
348
+ return cls .db .cursor .execute ("SELECT COUNT(rowid) FROM snapshot_tbl WHERE file IS NOT NULL AND file != '' " ).fetchone ()[0 ]
345
349
if fail :
346
- return cls .db .cursor .execute ("SELECT COUNT(rowid) FROM snapshot_tbl WHERE file IS NULL" ).fetchone ()[0 ]
350
+ return cls .db .cursor .execute ("SELECT COUNT(rowid) FROM snapshot_tbl WHERE file IS NULL OR file = '' " ).fetchone ()[0 ]
347
351
348
352
@staticmethod
349
353
def modify_snapshot (connection , snapshot_id , column , value ):
0 commit comments