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> <tr>
<th>Id</th> <th>Id</th>
<th>Name</th> <th>Name</th>
<th>Distance</th> <th>Distance to User</th>
<th>Closest Station</th>
<th>Distance to Station</th>
<th>Score</th> <th>Score</th>
</tr> </tr>
</thead> </thead>
@ -91,7 +93,9 @@
<tr> <tr>
<td>{{id}}</td> <td>{{id}}</td>
<td><a href="{{url}}">{{name}}</a></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> <td>{{score}}</td>
</tr> </tr>
{{/each}} {{/each}}

View File

@ -67,7 +67,9 @@ function findRecords(data, features, minScore) {
name: record.name, name: record.name,
url: 'http://www.tripadvisor.com' + record.relativeUrl, url: 'http://www.tripadvisor.com' + record.relativeUrl,
score: score, score: score,
distance: record.distanceToUser / 1000.0, distanceToUser: record.distanceToUser / 1000.0,
distanceToStn: record.distanceToStn / 1000.0,
closestStn: record.closestStn,
id: record.id id: record.id
}); });
}); });
@ -203,13 +205,12 @@ function getRecords(geo, callback) {
name: row.name, name: row.name,
id: row.id, id: row.id,
relativeUrl: row.url, relativeUrl: row.url,
distanceToStation: row.distanceToStation, closestStn: row.closestStn,
distanceToStn: row.distanceToStn,
geo: { geo: {
latitude: row.latitude, latitude: row.latitude,
longitude: row.longitude longitude: row.longitude
}, },
features: { features: {
delicious: row.delicious, delicious: row.delicious,
accomodating: row.accomodating, accomodating: row.accomodating,
@ -243,7 +244,7 @@ function computeRecordGeo(records, geo, accessDist) {
_.each(records, function(record) { _.each(records, function(record) {
record.features.nearby = -((record.distanceToUser - distUserMin) / distUserRange - 0.5) * 2.0; 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.min(record.features.accessible, 1.0);
record.features.accessible = Math.max(record.features.accessible, -1.0); record.features.accessible = Math.max(record.features.accessible, -1.0);
}); });