Include date_entered when inporting from old API

When importing from old API endpoint, also get the `date_entered` field
and insert to database.
This commit is contained in:
Cristian Ditaputratama 2024-05-12 01:35:41 +07:00
parent df8b933374
commit bd37f17072
Signed by: ditatompel
GPG key ID: 31D3D06D77950979

View file

@ -22,6 +22,7 @@ type importData struct {
Port int `json:"port"` Port int `json:"port"`
Protocol string `json:"protocol"` Protocol string `json:"protocol"`
IsTor bool `json:"is_tor"` IsTor bool `json:"is_tor"`
DateEntered int `json:"date_entered"`
} }
var importCmd = &cobra.Command{ var importCmd = &cobra.Command{
@ -84,8 +85,8 @@ func (i *importClient) processData(node importData) error {
} }
// insert // insert
query = `INSERT INTO tbl_node (hostname, port, protocol, is_tor, nettype, ip_addr, last_check_status) VALUES (?, ?, ?, ?, ?, ?, ?)` 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, "", "", "[2,2,2,2,2]") _, err = i.db.Exec(query, node.Hostname, node.Port, node.Protocol, node.IsTor, "", "", node.DateEntered, "[2,2,2,2,2]")
if err != nil { if err != nil {
return err return err
} }