issue #628 save_user_coords#629
Open
hxdimpf wants to merge 3 commits intoopencaching:masterfrom
Open
Conversation
88a83ba to
2d3306a
Compare
wrygiel
requested changes
Nov 23, 2023
091137a to
ad8b421
Compare
cccc1cd to
4a5f2f4
Compare
4a5f2f4 to
b4cb1a9
Compare
e8d3b16 to
0462c38
Compare
0462c38 to
e24323f
Compare
Contributor
|
If you want a feedback from c:geo side, please open an issue there. |
wrygiel
reviewed
Dec 9, 2023
e24323f to
5194518
Compare
Use a simple '' instead of Db::escape_string("") for the empty
description value in the INSERT statement.
b8d1c60 to
60a163a
Compare
stefopl
reviewed
May 7, 2026
Comment on lines
+109
to
+143
| else # oc.pl branch | ||
| { | ||
| $rs = Db::query(" | ||
| select max(id) as id | ||
| from cache_mod_cords | ||
| where | ||
| cache_id = '".Db::escape_string($cache_id)."' | ||
| and user_id = '".Db::escape_string($user_id)."' | ||
| "); | ||
| $id = null; | ||
| if($row = Db::fetch_assoc($rs)) { | ||
| $id = $row['id']; | ||
| } | ||
| if ($id == null) { | ||
| Db::query(" | ||
| insert into cache_mod_cords ( | ||
| cache_id, user_id, latitude, longitude | ||
| ) values ( | ||
| '".Db::escape_string($cache_id)."', | ||
| '".Db::escape_string($user_id)."', | ||
| '".Db::escape_string($latitude)."', | ||
| '".Db::escape_string($longitude)."' | ||
| ) | ||
| "); | ||
| } else { | ||
| Db::query(" | ||
| update cache_mod_cords | ||
| set latitude = '".Db::escape_string($latitude)."', | ||
| longitude = '".Db::escape_string($longitude)."' | ||
| where | ||
| id = '".Db::escape_string($id)."' | ||
| "); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
OCPL cache_mod_cords table does not contain an id column.
create table cache_mod_cords
(
cache_id int not null,
user_id int not null,
date timestamp default current_timestamp() not null,
longitude double not null,
latitude double not null,
primary key (cache_id, user_id)
)
it should look something like this:
else # oc.pl branch
{
Db::query("
INSERT INTO cache_mod_cords (
cache_id,
user_id,
latitude,
longitude,
date
) VALUES (
'".Db::escape_string($cache_id)."',
'".Db::escape_string($user_id)."',
'".Db::escape_string($latitude)."',
'".Db::escape_string($longitude)."',
NOW()
)
ON DUPLICATE KEY UPDATE
latitude = VALUES(latitude),
longitude = VALUES(longitude),
date = NOW()
");
}
Additionally, in OCPL only some cache types support user coordinates:
https://github.com/opencaching/opencaching-pl/blob/30ae3a4681c6840fe5aad454ccdb50fdb1340603/src/Controllers/ViewCacheController.php#L646-L648
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is about adding a new service endpoint. The platforms (opencaching.xx) provide the capabilities to maintain a personal cache notes field for each cache. In addition with this there is also a capability to store user provided coordinates for instance the coordinates that are the result of solving a puzzle.
The OKAPI provides a service to retrieve the personal caches notes and also the user_coords. It also provides a service to update the personal cache notes but not the user coords.
I have implemented a new service to fill this gap. First I thought about extending the already existing service
:: services/caches/save_personal_notes
however, to make sure that this doesn't create any adverse side effects for existing client applications I decided to implement a new service:
:: services/caches/save_user_coords.