Skip to content
This repository has been archived by the owner on Oct 14, 2019. It is now read-only.

Commit

Permalink
Merge pull request #404 from thecsw/Fixing384
Browse files Browse the repository at this point in the history
Fixing #384: Uninitialized Networth API Variable
  • Loading branch information
thecsw committed May 26, 2019
2 parents 7ba6038 + c90206f commit d72a743
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions api/firm/firm.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package firm

import (
"../utils"
"database/sql"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
"log"
"net/http"
"regexp"

"../utils"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
)

type firm struct {
Expand All @@ -19,16 +18,13 @@ type firm struct {
Balance int64 `json:"balance"`
Size int `json:"size"`
Execs int `json:"execs"`
Assocs int `json:"assocs"`
Coo int `json:"coo"`
Cfo int `json:"cfo"`
Tax int `json:"tax"`
Rank int `json:"rank"`
Private bool `json:"private"`
LastPayout int `json:"last_payout"`
}

type investor struct {
type investorNet struct {
Id int `json:"id"`
Name string `json:"name"`
Balance int64 `json:"balance"`
Expand All @@ -40,6 +36,17 @@ type investor struct {
NetWorth int64 `json:"networth"`
}

type investor struct {
Id int `json:"id"`
Name string `json:"name"`
Balance int64 `json:"balance"`
Completed int `json:"completed"`
Broke int `json:"broke"`
Badges []string `json:"badges"`
Firm int `json:"firm"`
Firm_role string `json:"firm_role"`
}

// Investments on time
func Firm() func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -64,8 +71,8 @@ func Firm() func(w http.ResponseWriter, r *http.Request) {
}
defer conn.Close()
query := fmt.Sprintf(`
SELECT id, name, balance, size, execs, assocs,
coo, cfo, tax, rank, private, last_payout
SELECT id, name, balance, size, execs,
tax, rank, private, last_payout
FROM Firms
WHERE id = %s
ORDER BY balance DESC
Expand All @@ -85,9 +92,6 @@ LIMIT 1;`, firm_id)
&temp.Balance,
&temp.Size,
&temp.Execs,
&temp.Assocs,
&temp.Coo,
&temp.Cfo,
&temp.Tax,
&temp.Rank,
&temp.Private,
Expand Down Expand Up @@ -207,8 +211,8 @@ LIMIT %d OFFSET %d;`, firm_id, per_page, per_page*page)
return
}
defer rows.Close()
wrapper := make([]investor, 0, per_page)
temp := investor{}
wrapper := make([]investorNet, 0, per_page)
temp := investorNet{}
var badges_temp string
for rows.Next() {
err := rows.Scan(
Expand Down

0 comments on commit d72a743

Please sign in to comment.