Skip to content

Commit

Permalink
Fix connection string
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanRenteM committed Apr 29, 2022
1 parent ed86feb commit cf3c208
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/prepare/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"github.com/spf13/cobra"
)

var proxy = services.NewProxy()

func NewCmdPrepare() *cobra.Command {
cmd := &cobra.Command{
Use: "prepare",
Expand All @@ -21,6 +19,8 @@ func NewCmdPrepare() *cobra.Command {

// Prepare appointments
func prepareAppointments(cmd *cobra.Command, args []string) {
proxy := services.NewProxy()

msg, err := proxy.AppointmentService.PrepareAppointments()
if err != nil {
log.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/spf13/viper"
)

var proxy = services.NewProxy()

func NewCmdUpload() *cobra.Command {
cmd := &cobra.Command{
Use: "upload",
Expand All @@ -24,6 +22,8 @@ func NewCmdUpload() *cobra.Command {
}

func uploadAppointments(cmd *cobra.Command, args []string) {
proxy := services.NewProxy()

// Fetch appointments
appointments, err := proxy.AppointmentService.FetchAppointments()
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions internal/data/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ type Database struct {
DB *sql.DB
}

func (d *Database) getConnection() sql.DB {
return *d.DB
}

// Close resources used by database
func Close() error {
if database == nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/data/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package data

import (
"database/sql"
"os"

_ "github.com/denisenkom/go-mssqldb"
"github.com/spf13/viper"
)

func getConnection() (*sql.DB, error) {
conn := os.Getenv("CONN_STRING")
conn := viper.GetString("connection_string")
return sql.Open("mssql", conn)
}
2 changes: 1 addition & 1 deletion internal/repositories/appointment.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (r *AppointmentRepository) PrepareAppointments() (string, error) {
return "", err
}

message := fmt.Sprintf("Rows affected: %v", rowsAffected - 2)
message := fmt.Sprintf("Rows affected: %v", rowsAffected-2)
return message, nil
}

Expand Down

0 comments on commit cf3c208

Please sign in to comment.