1

Updating UI to display new entries from database

This commit is contained in:
Alex Yatskov 2015-01-05 15:54:40 +09:00
parent c351080c70
commit 12eb1427ca
2 changed files with 19 additions and 14 deletions

View File

@ -83,7 +83,9 @@
<tr>
<th>Id</th>
<th>Name</th>
<th>Distance</th>
<th>Distance to User</th>
<th>Closest Station</th>
<th>Distance to Station</th>
<th>Score</th>
</tr>
</thead>
@ -91,7 +93,9 @@
<tr>
<td>{{id}}</td>
<td><a href="{{url}}">{{name}}</a></td>
<th>{{distance}} km</th>
<th>{{distanceToUser}} km</th>
<th>{{closestStn}}</th>
<th>{{distanceToStn}} km</th>
<td>{{score}}</td>
</tr>
{{/each}}

View File

@ -64,11 +64,13 @@ function findRecords(data, features, minScore) {
var results = [];
walkMatches(data, features, minScore, function(record, score) {
results.push({
name: record.name,
url: 'http://www.tripadvisor.com' + record.relativeUrl,
score: score,
distance: record.distanceToUser / 1000.0,
id: record.id
name: record.name,
url: 'http://www.tripadvisor.com' + record.relativeUrl,
score: score,
distanceToUser: record.distanceToUser / 1000.0,
distanceToStn: record.distanceToStn / 1000.0,
closestStn: record.closestStn,
id: record.id
});
});
@ -200,16 +202,15 @@ function getRecords(geo, callback) {
var records = _.map(rows, function(row) {
return {
name: row.name,
id: row.id,
relativeUrl: row.url,
distanceToStation: row.distanceToStation,
name: row.name,
id: row.id,
relativeUrl: row.url,
closestStn: row.closestStn,
distanceToStn: row.distanceToStn,
geo: {
latitude: row.latitude,
longitude: row.longitude
},
features: {
delicious: row.delicious,
accomodating: row.accomodating,
@ -243,7 +244,7 @@ function computeRecordGeo(records, geo, accessDist) {
_.each(records, function(record) {
record.features.nearby = -((record.distanceToUser - distUserMin) / distUserRange - 0.5) * 2.0;
record.features.accessible = 1.0 - (record.distanceToStation / accessDist);
record.features.accessible = 1.0 - (record.distanceToStn / accessDist);
record.features.accessible = Math.min(record.features.accessible, 1.0);
record.features.accessible = Math.max(record.features.accessible, -1.0);
});