@@ -25,29 +25,26 @@ import (
2525
2626type DatapipeStatusData interface {
2727 UpdateLastAnalysisCompleteTime (ctx context.Context ) error
28+ SetLastAnalysisStartTime (ctx context.Context ) error
2829 SetDatapipeStatus (ctx context.Context , status model.DatapipeStatus ) error
2930 GetDatapipeStatus (ctx context.Context ) (model.DatapipeStatusWrapper , error )
3031}
3132
33+ // This should be called at the end of a successful analysis run (not always every analysis)
3234func (s * BloodhoundDB ) UpdateLastAnalysisCompleteTime (ctx context.Context ) error {
3335 now := time .Now ().UTC ()
3436 return s .db .WithContext (ctx ).Exec ("UPDATE datapipe_status SET updated_at = ?, last_complete_analysis_at = ?" , now , now ).Error
3537}
3638
39+ // This should be called at the start of analysis processing (not every datapipe tick, but start of real work)
40+ func (s * BloodhoundDB ) SetLastAnalysisStartTime (ctx context.Context ) error {
41+ now := time .Now ().UTC ()
42+ return s .db .WithContext (ctx ).Exec ("UPDATE datapipe_status SET updated_at = ?, last_analysis_run_at = ?" , now , now ).Error
43+ }
44+
3745func (s * BloodhoundDB ) SetDatapipeStatus (ctx context.Context , status model.DatapipeStatus ) error {
3846 now := time .Now ().UTC ()
39- // All queries will update the status and table update time
40- updateSql := "UPDATE datapipe_status SET status = ?, updated_at = ?"
41-
42- if status == model .DatapipeStatusAnalyzing {
43- // Updates last run anytime we start analysis
44- updateSql += ", last_analysis_run_at = ?;"
45- return s .db .WithContext (ctx ).Exec (updateSql , status , now , now ).Error
46- } else {
47- // Otherwise, only update status and last update to the table
48- updateSql += ";"
49- return s .db .WithContext (ctx ).Exec (updateSql , status , now ).Error
50- }
47+ return s .db .WithContext (ctx ).Exec ("UPDATE datapipe_status SET status = ?, updated_at = ?;" , status , now ).Error
5148}
5249
5350func (s * BloodhoundDB ) GetDatapipeStatus (ctx context.Context ) (model.DatapipeStatusWrapper , error ) {
0 commit comments