From bd37f1707228644dd7a08827d44af0de444cb936 Mon Sep 17 00:00:00 2001 From: ditatompel Date: Sun, 12 May 2024 01:35:41 +0700 Subject: [PATCH] Include `date_entered` when inporting from old API When importing from old API endpoint, also get the `date_entered` field and insert to database. --- cmd/import.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/import.go b/cmd/import.go index 88040a6..5e03660 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -18,10 +18,11 @@ func newImport(db *database.DB) *importClient { } type importData struct { - Hostname string `json:"hostname"` - Port int `json:"port"` - Protocol string `json:"protocol"` - IsTor bool `json:"is_tor"` + Hostname string `json:"hostname"` + Port int `json:"port"` + Protocol string `json:"protocol"` + IsTor bool `json:"is_tor"` + DateEntered int `json:"date_entered"` } var importCmd = &cobra.Command{ @@ -84,8 +85,8 @@ func (i *importClient) processData(node importData) error { } // insert - query = `INSERT INTO tbl_node (hostname, port, protocol, is_tor, nettype, ip_addr, last_check_status) VALUES (?, ?, ?, ?, ?, ?, ?)` - _, err = i.db.Exec(query, node.Hostname, node.Port, node.Protocol, node.IsTor, "", "", "[2,2,2,2,2]") + query = `INSERT INTO tbl_node (hostname, port, protocol, is_tor, nettype, ip_addr, date_entered, last_check_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?)` + _, err = i.db.Exec(query, node.Hostname, node.Port, node.Protocol, node.IsTor, "", "", node.DateEntered, "[2,2,2,2,2]") if err != nil { return err }