okapi r664
This commit is contained in:
parent
ce25cd68f3
commit
2d42d6f675
@ -778,7 +778,7 @@ class Okapi
|
||||
{
|
||||
public static $data_store;
|
||||
public static $server;
|
||||
public static $revision = 660; # This gets replaced in automatically deployed packages
|
||||
public static $revision = 664; # This gets replaced in automatically deployed packages
|
||||
private static $okapi_vars = null;
|
||||
|
||||
/** Get a variable stored in okapi_vars. If variable not found, return $default. */
|
||||
|
@ -142,13 +142,15 @@
|
||||
<li><b>difficulty</b> - float (between 1 and 5), difficulty rating of the cache,</li>
|
||||
<li><b>terrain</b> - float (between 1 and 5), terrain rating of the cache,</li>
|
||||
<li>
|
||||
<b>searchtime</b> - float, the estimated time in hours to do the cache, roundtrip
|
||||
from nearest parking area or specified starting point to the cache and back,
|
||||
or <b>null</b> if unknown,
|
||||
<b>trip_time</b> - float, approximate total amount of time needed to
|
||||
find the cache, in hours; this will usually include the time to reach the
|
||||
cache location <em>and</em> go back (from/to a parking spot, etc.);
|
||||
<b>null</b> if unknown,
|
||||
</li>
|
||||
<li><b>waylength</b> - float, the estimated way to go for doing the cache in kilometers,
|
||||
roundtrip from nearest parking area or specified starting point to the cache and back,
|
||||
or <b>null</b> if unknown,
|
||||
<li><b>trip_distance</b> - float, approximate total distance needed to
|
||||
find the cache, in kilometers; this will usually include the time to reach the
|
||||
cache location <em>and</em> go back (from/to a parking spot, etc.);
|
||||
<b>null</b> if unknown,
|
||||
</li>
|
||||
<li>
|
||||
<p><b>rating</b> - float (between 1 and 5), an overall rating of the cache,
|
||||
|
@ -31,7 +31,8 @@ class WebService
|
||||
'descriptions', 'hint', 'hints', 'images', 'attrnames', 'latest_logs',
|
||||
'my_notes', 'trackables_count', 'trackables', 'alt_wpts', 'last_found',
|
||||
'last_modified', 'date_created', 'date_hidden', 'internal_id', 'is_watched',
|
||||
'is_ignored', 'willattends', 'country', 'state', 'preview_image', 'searchtime', 'waylength');
|
||||
'is_ignored', 'willattends', 'country', 'state', 'preview_image',
|
||||
'trip_time', 'trip_distance');
|
||||
|
||||
public static function call(OkapiRequest $request)
|
||||
{
|
||||
@ -131,15 +132,16 @@ class WebService
|
||||
# DE branch:
|
||||
# - Caches do not have ratings.
|
||||
# - Total numbers of founds and notfounds are kept in the "stat_caches" table.
|
||||
# - search_time and way_length cannot be null, 0 = not specified
|
||||
# - search_time and way_length are both round trip values and cannot be null;
|
||||
# 0 = not specified
|
||||
|
||||
$rs = Db::query("
|
||||
select
|
||||
c.cache_id, c.name, c.longitude, c.latitude, c.listing_last_modified as last_modified,
|
||||
c.date_created, c.type, c.status, c.date_hidden, c.size, c.difficulty,
|
||||
c.terrain, c.wp_oc, c.logpw, c.user_id,
|
||||
if(c.search_time=0, null, c.search_time) as searchtime,
|
||||
if(c.way_length=0, null, c.way_length) as waylength,
|
||||
if(c.search_time=0, null, c.search_time) as trip_time,
|
||||
if(c.way_length=0, null, c.way_length) as trip_distance,
|
||||
|
||||
ifnull(sc.toprating, 0) as topratings,
|
||||
ifnull(sc.found, 0) as founds,
|
||||
@ -160,15 +162,16 @@ class WebService
|
||||
# PL branch:
|
||||
# - Caches have ratings.
|
||||
# - Total numbers of found and notfounds are kept in the "caches" table.
|
||||
# - search_time and way_length can be null, 0 or null = not specified
|
||||
# - search_time is round trip and way_length one way; both can be null;
|
||||
# 0 or null = not specified
|
||||
|
||||
$rs = Db::query("
|
||||
select
|
||||
c.cache_id, c.name, c.longitude, c.latitude, c.last_modified,
|
||||
c.date_created, c.type, c.status, c.date_hidden, c.size, c.difficulty,
|
||||
c.terrain, c.wp_oc, c.logpw, c.user_id,
|
||||
if(c.search_time=0, null, c.search_time) as searchtime,
|
||||
if(c.way_length=0, null, c.way_length) as waylength,
|
||||
if(c.search_time=0, null, c.search_time) as trip_time,
|
||||
if(c.way_length=0, null, 2*c.way_length) as trip_distance,
|
||||
|
||||
c.topratings,
|
||||
c.founds,
|
||||
@ -262,15 +265,15 @@ class WebService
|
||||
case 'oxsize': $entry['oxsize'] = Okapi::cache_size2_to_oxsize(Okapi::cache_sizeid_to_size2($row['size'])); break;
|
||||
case 'difficulty': $entry['difficulty'] = round($row['difficulty'] / 2.0, 1); break;
|
||||
case 'terrain': $entry['terrain'] = round($row['terrain'] / 2.0, 1); break;
|
||||
case 'searchtime':
|
||||
case 'trip_time':
|
||||
# search time is entered in hours:minutes and converted to decimal hours,
|
||||
# which can produce lots of unneeded decimal places; 2 of them are sufficient here
|
||||
$entry['searchtime'] = $row['searchtime'] === null ? null : round($row['searchtime'],2); break;
|
||||
$entry['trip_time'] = $row['trip_time'] === null ? null : round($row['trip_time'],2); break;
|
||||
break;
|
||||
case 'waylength':
|
||||
case 'trip_distance':
|
||||
# way length is entered in km as decimal fraction, but number conversions can
|
||||
# create fake digits which should be stripped; meter precision is sufficient here
|
||||
$entry['waylength'] = $row['waylength'] === null ? null : round($row['waylength'],3); break;
|
||||
$entry['trip_distance'] = $row['trip_distance'] === null ? null : round($row['trip_distance'],3); break;
|
||||
break;
|
||||
case 'rating':
|
||||
if ($row['votes'] < 3) $entry['rating'] = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user