summaryrefslogtreecommitdiff
path: root/sqlQueries.go
diff options
context:
space:
mode:
Diffstat (limited to 'sqlQueries.go')
-rw-r--r--sqlQueries.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/sqlQueries.go b/sqlQueries.go
index 65b0a7a..b814d2e 100644
--- a/sqlQueries.go
+++ b/sqlQueries.go
@@ -179,11 +179,7 @@ func removeASNIP(db *sql.DB, asn int, ipBlock string) error {
// Adds differential privacy to all entries in the
// database that is older than t and haven't had
// differential privacy added to them yet.
-// If epsilon == 0 in conf. Then nothing is done.
func privatizeCleaned(db *sql.DB, t time.Time, conf Config) (err error) {
- if conf.Epsilon == 0 {
- return
- }
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")
if err != nil {
log.Println("Failed to prepare query")
@@ -220,3 +216,18 @@ func privatizeCleaned(db *sql.DB, t time.Time, conf Config) (err error) {
}
return
}
+
+func availableRows(tx *sql.Tx, limit time.Time) (numRows int, err error) {
+ stmt, err := tx.Prepare("SELECT COUNT(*) FROM acct WHERE stamp_inserted < ? ")
+ if err != nil {
+ log.Println("Could not prepare statement")
+ return
+ }
+ row := stmt.QueryRow(limit)
+
+ err = row.Scan(&numRows)
+ if err != nil {
+ log.Println("Failed to scan result")
+ }
+ return
+}