Browse Source

Make Browse item count configurable

tags/v1.0
Matt Baer 8 years ago
parent
commit
3392e8e2ba
2 changed files with 2 additions and 1 deletions
  1. +1
    -0
      config.go
  2. +1
    -1
      construction.go

+ 1
- 0
config.go View File

@@ -20,6 +20,7 @@ type config struct {

AutoApprove bool `env:"key=AUTO_APPROVE default=false"`
AdminPass string `env:"key=ADMIN_PASS default=uhoh"`
BrowseItems int `env:"key=BROWSE_ITEMS default=10"`
}

func newConfig() (*config, error) {


+ 1
- 1
construction.go View File

@@ -304,7 +304,7 @@ func viewHouses(app *app, w http.ResponseWriter, r *http.Request) error {

func getPublicHouses(app *app) (*[]PublicHouse, error) {
houses := []PublicHouse{}
rows, err := app.db.Query("SELECT house_id, title, thumb_url FROM publichouses WHERE approved = 1 ORDER BY updated DESC LIMIT 10")
rows, err := app.db.Query(fmt.Sprintf("SELECT house_id, title, thumb_url FROM publichouses WHERE approved = 1 ORDER BY updated DESC LIMIT %d", app.cfg.BrowseItems))
switch {
case err == sql.ErrNoRows:
return nil, impart.HTTPError{http.StatusNotFound, "Return to sender. Address unknown."}


Loading…
Cancel
Save