Skip to content

Commit

Permalink
Remove tx
Browse files Browse the repository at this point in the history
  • Loading branch information
bgpat committed Sep 15, 2018
1 parent ae3bae3 commit caa71aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions home/isucon/torb/webapp/go/src/torb/event.go
Expand Up @@ -20,13 +20,7 @@ type Event struct {
}

func getEventsRoot(all bool) ([]*Event, error) {
tx, err := db.Begin()
if err != nil {
return nil, err
}
defer tx.Commit()

rows1, err := tx.Query("SELECT id, title, price FROM events WHERE public_fg = 1 ORDER BY id ASC")
rows1, err := db.Query("SELECT id, title, price FROM events WHERE public_fg = 1 ORDER BY id ASC")
if err != nil {
return nil, err
}
Expand All @@ -41,7 +35,7 @@ func getEventsRoot(all bool) ([]*Event, error) {
[]int{500, 1000},
} {

rows, err := tx.Query("SELECT event_id, count(1) FROM reservations WHERE ? < sheet_id AND sheet_id <= ? AND canceled_at IS NULL GROUP BY event_id", v[0], v[1])
rows, err := db.Query("SELECT event_id, count(1) FROM reservations WHERE ? < sheet_id AND sheet_id <= ? AND canceled_at IS NULL GROUP BY event_id", v[0], v[1])
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion home/isucon/torb/webapp/go/src/torb/route.go
Expand Up @@ -21,7 +21,7 @@ func registerRoutes(e *echo.Echo) {
}

func getRoot(c echo.Context) error {
events, err := getEvents(false)
events, err := getEventsRoot(false)
if err != nil {
return err
}
Expand Down

0 comments on commit caa71aa

Please sign in to comment.