summaryrefslogtreecommitdiff
path: root/sqlQueries.go
diff options
context:
space:
mode:
authorDaniel Langesten <daniel.langest@gmail.com>2015-03-17 12:02:05 +0100
committerDaniel Langesten <daniel.langest@gmail.com>2015-03-17 12:02:05 +0100
commit330763bab77365fb69213f2489070f75797912c6 (patch)
tree60dff989b7d662eb85347660cb77d4257df49841 /sqlQueries.go
parent38eb46bad4062e04f1db1b93bf5d0d1a935c4d96 (diff)
fixed queries so that they match the content of the database
Diffstat (limited to 'sqlQueries.go')
-rw-r--r--sqlQueries.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/sqlQueries.go b/sqlQueries.go
index b814d2e..6ed02c8 100644
--- a/sqlQueries.go
+++ b/sqlQueries.go
@@ -17,9 +17,9 @@ func fetchRawData(db *sql.DB, tim time.Time, limit int) (rDat []rawData, err err
var prepSel *sql.Stmt
if limit > 0 {
- prepSel, err = db.Prepare("SELECT ip_src,ip_dst,as_src,as_dst,port_src,port_dst,packets,pkt_len_distrib,stamp_inserted FROM acct WHERE stamp_inserted < ? LIMIT ?")
+ prepSel, err = db.Prepare("SELECT ip_src,ip_dst,as_src,as_dst,port_src,port_dst,packets,pkt_len_distrib,stamp_inserted FROM acct WHERE stamp_processed IS NULL AND stamp_inserted < ? LIMIT ?")
} else {
- prepSel, err = db.Prepare("SELECT ip_src,ip_dst,as_src,as_dst,port_src,port_dst,packets,pkt_len_distrib,stamp_inserted FROM acct WHERE stamp_inserted < ?")
+ prepSel, err = db.Prepare("SELECT ip_src,ip_dst,as_src,as_dst,port_src,port_dst,packets,pkt_len_distrib,stamp_inserted FROM acct WHERE stamp_processed IS NULL AND stamp_inserted < ?")
}
if err != nil {
log.Println("Failed to prepare select")
@@ -117,7 +117,7 @@ func purgeRawData(tx *sql.Tx, rDat []rawData) (err error) {
}
func insertCleanData(tx *sql.Tx, cd *cleanedData) error {
- prepStmt, err := tx.Prepare("INSERT INTO clean_data (ipb_src, ipb_dst, as_src, as_dst, port_src, port_dst, occurences, volume, time) VALUES ( ? , ? , ? , ? , ? , ? , ? , ? , ? ) ON DUPLICATE KEY UPDATE occurences = occurences + ?")
+ prepStmt, err := tx.Prepare("INSERT INTO clean_data (ipb_src, ipb_dst, as_src, as_dst, port_src, port_dst, occurences, volume, time_added) VALUES ( ? , ? , ? , ? , ? , ? , ? , ? , ? ) ON DUPLICATE KEY UPDATE occurences = occurences + ?")
if err != nil {
log.Println("Failed to prepare statement")
return err
@@ -180,7 +180,7 @@ func removeASNIP(db *sql.DB, asn int, ipBlock string) error {
// database that is older than t and haven't had
// differential privacy added to them yet.
func privatizeCleaned(db *sql.DB, t time.Time, conf Config) (err error) {
- query, err := db.Prepare("SELECT ipb_src,ipb_dst,as_src,as_dst,port_src,port_dst,volume,time,occurences FROM clean_data WHERE time < ? FOR UPDATE")
+ query, err := db.Prepare("SELECT ipb_src,ipb_dst,as_src,as_dst,port_src,port_dst,volume,time,occurences FROM clean_data WHERE time_added < ? FOR UPDATE")
if err != nil {
log.Println("Failed to prepare query")
return
@@ -192,7 +192,7 @@ func privatizeCleaned(db *sql.DB, t time.Time, conf Config) (err error) {
return
}
- update, err := db.Prepare("UPDATE clean_data SET occurences = ? , privitazied = ? WHERE ipb_src = ? AND ipb_dst = ? AND as_src = ? AND as_dst = ? AND port_src = ? AND port_dst = ? AND volume = ? AND time = ? ")
+ update, err := db.Prepare("UPDATE clean_data SET occurences = ? , time_privatized = ? WHERE ipb_src = ? AND ipb_dst = ? AND as_src = ? AND as_dst = ? AND port_src = ? AND port_dst = ? AND volume = ? AND time_added = ? ")
if err != nil {
log.Println("Failed to prepare update")
return