🔥 remove unused backup function
Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
c45a65b618
commit
e29d68e1ba
6 changed files with 3 additions and 81 deletions
|
@ -2,10 +2,8 @@ package db
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
@ -29,28 +27,6 @@ func InsertBugReport(bugText string) (error) {
|
|||
log.Fatalf("Error connecting to the database: %v\n", err)
|
||||
}
|
||||
|
||||
// Write bugText to backup-file
|
||||
file, err := os.OpenFile("cmd/db/backups/bugreport_backup.csv", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
|
||||
if err != nil {
|
||||
log.Fatalln("error opening file", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// Prepare the row to be written
|
||||
rowSlice := []string{bugText}
|
||||
|
||||
// Create a CSV writer and write the row
|
||||
csvwriter := csv.NewWriter(file)
|
||||
if err := csvwriter.Write(rowSlice); err != nil {
|
||||
log.Fatalln("error writing record to file", err)
|
||||
}
|
||||
|
||||
// Flush the writer and check for errors
|
||||
csvwriter.Flush()
|
||||
if err := csvwriter.Error(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
insertStatement := `
|
||||
INSERT INTO FeilRapport (feiltekst)
|
||||
VALUES ($1)
|
||||
|
|
|
@ -2,10 +2,8 @@ package db
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
@ -29,28 +27,6 @@ func InsertEvaluation(evaluationText string) (error) {
|
|||
log.Fatalf("Error connecting to the database: %v\n", err)
|
||||
}
|
||||
|
||||
// Write evaluationText to backup-file
|
||||
file, err := os.OpenFile("cmd/db/backups/evaluation_backup.csv", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
|
||||
if err != nil {
|
||||
log.Fatalln("error opening file", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// Prepare the row to be written
|
||||
rowSlice := []string{evaluationText}
|
||||
|
||||
// Create a CSV writer and write the row
|
||||
csvwriter := csv.NewWriter(file)
|
||||
if err := csvwriter.Write(rowSlice); err != nil {
|
||||
log.Fatalln("error writing record to file", err)
|
||||
}
|
||||
|
||||
// Flush the writer and check for errors
|
||||
csvwriter.Flush()
|
||||
if err := csvwriter.Error(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
insertStatement := `
|
||||
INSERT INTO Evaluering (evalueringtekst)
|
||||
VALUES ($1)
|
||||
|
|
|
@ -2,11 +2,9 @@ package db
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
|
@ -19,11 +17,6 @@ type FormAnswer struct {
|
|||
|
||||
type AllFormAnswers []FormAnswer
|
||||
|
||||
type CSVRow struct {
|
||||
RespondentID string
|
||||
AllAnswers string
|
||||
}
|
||||
|
||||
func InsertUserAnswers(respondentId int, allAnswers string) (error) {
|
||||
|
||||
// Connection string
|
||||
|
@ -44,29 +37,6 @@ func InsertUserAnswers(respondentId int, allAnswers string) (error) {
|
|||
log.Fatalf("Error connecting to the database: %v\n", err)
|
||||
}
|
||||
|
||||
// Write answers to backup-file
|
||||
file, err := os.OpenFile("cmd/db/backups/answer_backup.csv", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
var row = CSVRow{strconv.Itoa(respondentId), allAnswers}
|
||||
|
||||
rowSlice := []string{row.RespondentID, row.AllAnswers}
|
||||
|
||||
csvwriter := csv.NewWriter(file)
|
||||
|
||||
if err := csvwriter.Write(rowSlice); err != nil {
|
||||
log.Fatalln("error writing record to file", err)
|
||||
}
|
||||
|
||||
csvwriter.Flush()
|
||||
|
||||
// Check for errors from flushing
|
||||
if err := csvwriter.Error(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Convert answer format
|
||||
var convertedFormAnswers = convertAnswerFormat(allAnswers)
|
||||
|
||||
|
|
Reference in a new issue