Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

明らかに重そうなところを列挙した #5

Merged
merged 3 commits into from Sep 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions isuumo/webapp/go/main.go
Expand Up @@ -381,6 +381,7 @@ func postChair(c echo.Context) error {
c.Logger().Errorf("failed to read record: %v", err)
return c.NoContent(http.StatusBadRequest)
}
// TODO: bulk insetアリかも
_, err := tx.Exec("INSERT INTO chair(id, name, description, thumbnail, price, height, width, depth, color, features, kind, popularity, stock) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)", id, name, description, thumbnail, price, height, width, depth, color, features, kind, popularity, stock)
if err != nil {
c.Logger().Errorf("failed to insert chair: %v", err)
Expand Down Expand Up @@ -503,6 +504,7 @@ func searchChairs(c echo.Context) error {
}

searchQuery := "SELECT * FROM chair WHERE "
// TODO: array countしてみたら良いかも
countQuery := "SELECT COUNT(*) FROM chair WHERE "
searchCondition := strings.Join(conditions, " AND ")
limitOffset := " ORDER BY popularity DESC, id ASC LIMIT ? OFFSET ?"
Expand Down Expand Up @@ -588,6 +590,7 @@ func getChairSearchCondition(c echo.Context) error {

func getLowPricedChair(c echo.Context) error {
var chairs []Chair
// TODO: price, idの複合indexありかも
query := `SELECT * FROM chair WHERE stock > 0 ORDER BY price ASC, id ASC LIMIT ?`
err := db.Select(&chairs, query, Limit)
if err != nil {
Expand Down Expand Up @@ -678,6 +681,7 @@ func postEstate(c echo.Context) error {
c.Logger().Errorf("failed to read record: %v", err)
return c.NoContent(http.StatusBadRequest)
}
// TODO: bulk insert使えそう
_, err := tx.Exec("INSERT INTO estate(id, name, description, thumbnail, address, latitude, longitude, rent, door_height, door_width, features, popularity) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)", id, name, description, thumbnail, address, latitude, longitude, rent, doorHeight, doorWidth, features, popularity)
if err != nil {
c.Logger().Errorf("failed to insert estate: %v", err)
Expand Down Expand Up @@ -771,6 +775,7 @@ func searchEstates(c echo.Context) error {
}

searchQuery := "SELECT * FROM estate WHERE "
// TODO: arrayのカウント
countQuery := "SELECT COUNT(*) FROM estate WHERE "
searchCondition := strings.Join(conditions, " AND ")
limitOffset := " ORDER BY popularity DESC, id ASC LIMIT ? OFFSET ?"
Expand Down Expand Up @@ -875,6 +880,7 @@ func searchEstateNazotte(c echo.Context) error {
}

estatesInPolygon := []Estate{}
// TODO: N+1
for _, estate := range estatesInBoundingBox {
validatedEstate := Estate{}

Expand Down