<commit_before>package main

import (
	"code.google.com/p/gosqlite/sqlite"
	"log"
	"strconv"
	"time"
)

var gConn *sqlite.Conn

func openDb() {
	conn, err := sqlite.Open("db.sqlite")
	if err != nil {
		log.Fatalf("Unable to open the database: %s", err)
	}

	conn.Exec("CREATE TABLE devices(id INTEGER PRIMARY KEY AUTOINCREMENT, date TEXT, email TEXT, deviceName TEXT, pushURL TEXT, lon FLOAT, lat FLOAT, UNIQUE (pushURL));")
	gConn = conn
}

func closeDb() {
	gConn.Close()
	gConn = nil
}

func updateDeviceLocation(pushURL string, lat float64, lon float64) bool {

	err := gConn.Exec("UPDATE devices SET date=" +
		strconv.FormatInt(time.Now().Unix(), 10) +
		", lat=" + strconv.FormatFloat(lon, 'f', 4, 64) +
		", lon=" + strconv.FormatFloat(lat, 'f', 4, 64) +
		" WHERE pushURL='" + pushURL + "'")

	if err != nil {
		log.Println("Error while update location: "+pushURL+" err: ", err)
		return false
	}
	return true
}

func addDevice(email, deviceName, pushURL, latitude, longitude string) bool {

	if email == "" || deviceName == "" || pushURL == "" {
		return false<commit_msg>Fixed latitude and longitude being reversed in the db<commit_after>package main

import (
	"code.google.com/p/gosqlite/sqlite"
	"log"
	"strconv"
	"time"
)

var gConn *sqlite.Conn

func openDb() {
	conn, err := sqlite.Open("db.sqlite")
	if err != nil {
		log.Fatalf("Unable to open the database: %s", err)
	}

	conn.Exec("CREATE TABLE devices(id INTEGER PRIMARY KEY AUTOINCREMENT, date TEXT, email TEXT, deviceName TEXT, pushURL TEXT, lon FLOAT, lat FLOAT, UNIQUE (pushURL));")
	gConn = conn
}

func closeDb() {
	gConn.Close()
	gConn = nil
}

func updateDeviceLocation(pushURL string, lat float64, lon float64) bool {

	err := gConn.Exec("UPDATE devices SET date=" +
		strconv.FormatInt(time.Now().Unix(), 10) +
		", lat=" + strconv.FormatFloat(lat, 'f', 4, 64) +
		", lon=" + strconv.FormatFloat(lon, 'f', 4, 64) +
		" WHERE pushURL='" + pushURL + "'")

	if err != nil {
		log.Println("Error while update location: "+pushURL+" err: ", err)
		return false
	}
	return true
}

func addDevice(email, deviceName, pushURL, latitude, longitude string) bool {

	if email == "" || deviceName == "" || pushURL == "" {
		return false
{'fraction_non_alphanumeric': 0.15789473684210525, 'fraction_numerical': 0.010889292196007259, 'mean_word_length': 4.163934426229508, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7377828', 'n_tokens_mistral': 842, 'n_tokens_neox': 784, 'n_words': 225}