From e4cee9f3fe1491bfc15659384bdb4375514ff668 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 20 Sep 2015 12:36:45 +0900 Subject: [PATCH] Address instead of URLs --- static/index.html | 2 +- static/scripts/search.js | 4 ++++ types.go | 2 +- util.go | 8 ++++---- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/static/index.html b/static/index.html index d936f41..7c90389 100644 --- a/static/index.html +++ b/static/index.html @@ -128,7 +128,7 @@ {{#each records}} - {{name}} + {{name}} {{#prettyFloat 2}}{{distanceToUser}}{{/prettyFloat}} km {{closestStn}} {{#prettyFloat 2}}{{distanceToStn}}{{/prettyFloat}} km diff --git a/static/scripts/search.js b/static/scripts/search.js index 0a1dd4c..4cabb22 100644 --- a/static/scripts/search.js +++ b/static/scripts/search.js @@ -47,6 +47,10 @@ return parseFloat(options.fn(this)).toFixed(precision); }); + Handlebars.registerHelper('urlEncode', function(options) { + return encodeURIComponent(options.fn(this)); + }); + $('#minScore,#resolution,#walkingDist,#maxResults').change(onSearch); $('#profileDlg').on('hidden.bs.modal', onSearch); $('#resetStorage').click(function() { diff --git a/types.go b/types.go index 8da9b90..12ef761 100644 --- a/types.go +++ b/types.go @@ -62,7 +62,7 @@ type record struct { Id int `json:"id"` Name string `json:"name"` Score float64 `json:"score"` - Urls string `json:"urls"` + Address string `json:"address"` features map[string]float64 geo geoData } diff --git a/util.go b/util.go index 9d78281..fb59c38 100644 --- a/util.go +++ b/util.go @@ -256,7 +256,7 @@ func computeRecordCompat(db *sql.DB, entries []record, context queryContext) err } func fetchRecords(db *sql.DB, context queryContext) ([]record, error) { - rows, err := db.Query("SELECT name, urls, delicious, accommodating, affordable, atmospheric, latitude, longitude, closestStnDist, closestStnName, accessCount, id FROM reviews") + rows, err := db.Query("SELECT name, address, delicious, accommodating, affordable, atmospheric, latitude, longitude, closestStnDist, closestStnName, accessCount, id FROM reviews") if err != nil { return nil, err } @@ -265,7 +265,7 @@ func fetchRecords(db *sql.DB, context queryContext) ([]record, error) { var entries []record for rows.Next() { var ( - name, urls, closestStn string + name, address, closestStn string delicious, accommodating, affordable, atmospheric float64 latitude, longitude, distanceToStn float64 accessCount, id int @@ -273,7 +273,7 @@ func fetchRecords(db *sql.DB, context queryContext) ([]record, error) { rows.Scan( &name, - &urls, + &address, &delicious, &accommodating, &affordable, @@ -287,7 +287,7 @@ func fetchRecords(db *sql.DB, context queryContext) ([]record, error) { entry := record{ Name: name, - Urls: urls, + Address: address, DistanceToStn: distanceToStn, ClosestStn: closestStn, AccessCount: accessCount,