Advanced

Re: Labcaches

Labcaches
January 15, 2020 12:12PM
I will release two updates to the Sandbox API in a few minutes.

Both implementations are 100% untested. Feel free to test them, if they don't work, please inform me here.
None of them are documented yet. I will generate a new Doxygen documentation when I know that they work.


New method PGC.GetLabCacheFinds(profileId)
Doxygen basis
	/// @brief Returns an associative array with the labcache finds from given profileId.
	///
	/// Returned fields: guid, name, date_found
	/// @param[in] int $profileId An integer with the users profile id.


New in-parameter to PGC.GetFinds()
	/// - includeLabCaches (bool): If set to true, will include labcache finds. Note that most fields returned will be null.
If used, the data with Geocache finds will be merged with Labcache finds. It's a hack though. All fields except those mentioned here will be set to NULL. The LUA script must be able to handle that.
  • cache_id - Will be set to crc32 of a GUID string.
  • gccode - Will be set to the GUID of the Labcache. Example: 0008be86-1cf0-49b3-8b21-a9aa17bac1a2
  • cache_name - The name of the labcache.
  • visitdate - Date logged.

The implementation first fetches all geocache finds as before. When that process is done it fetches the labcache finds and append those.

After that it sorts the data again. We do not have data to sort labcaches and geocaches within the same day correctly. Geocaches will still be sorted correctly, but all the Labcache finds will be at the end of that day.

If a limit has been provided, we will slice the data array down to the limit again.



Edited 1 time(s). Last edit at 01/15/2020 12:13PM by magma1447. (view changes)
Re: Labcaches
January 15, 2020 06:18PM
I assume it's not deployed yet?

Caught exception: attempt to call field 'GetLabCacheFinds' (a nil value)
Re: Labcaches
January 15, 2020 06:27PM
pieterix Wrote:
-------------------------------------------------------
> I assume it's not deployed yet?
>
> Caught exception: attempt to call field
> 'GetLabCacheFinds' (a nil value)

It is, but I forgot to add the method into the Sandbox, I just wrote the code... I should have tested it myself. I will attack it tomorrow, and at least test that it gives decent data.
Re: Labcaches
January 15, 2020 07:13PM
It's fixed now, and I made a new release.

I have tested method GetLabCacheFinds(). It seems to return relevant data.

I tested GetFinds() so that it actually runs. I did not verify that I got the data I expected. So if you do not find any labcaches here, it probably doesn't work.

Regarding GetFinds() I added these two comments:
* The field cache_id is NOT guaranteed to be unique between geocaches and labcaches.
* Filters are ignored, even for dates.

If parameter includeLabCaches = true is set, it will return ALL LabCaches finds for that user, regardless of filters. Also note that the script can not rely on the cache_id being unique. The GC-code will be however, since it's either a GC-Code or a long GUID. As the data is today, there are 34 collisions between cache_id (int) and crc32(labcache-guid).
Re: Labcaches
January 15, 2020 07:15PM
GetLabCacheFinds() works for me now.
Re: Labcaches
March 03, 2020 01:21PM
I'm having trouble with GetFinds. Doing

local finds = PGC.GetFinds(profileId, { includeLabCaches = true, fields = {'gccode', 'cache_name', 'visitdate','type', 'country'}, order = 'OLDESTFIRST', filter = filter })

seems to set finds to true, instead of a table for some reason. I thought the fields/filters might mess it up somehow, and indeed with

local finds = PGC.GetFinds(profileId, { includeLabCaches = true })

the result is a table at least, however it still does not include Labs.



Edited 1 time(s). Last edit at 03/03/2020 01:22PM by PattuX. (view changes)
Re: Labcaches
March 04, 2020 09:29AM
I will look into this. Maybe it doesn't work as it should. If you haven't heard anything on Monday, please remind me. Right now I am trying to not lose focus on the 360-tool for the The All Around Cacher. Got so many notes about it here that I want to implement most of it.
Re: Labcaches
March 04, 2020 01:07PM
Found a sloppy error. After adding the Labcaches I need to re-sort the data. The code did a $data = uasort(...); But PHP's uasort() doesn't return the result, the parameter for the data is a reference, so it's sorted in-place. $data was set to TRUE because the sort was successful. I of course know that uasort() doesn't return the result, so it was surprising to find the error.

I will make a new release with the fix in a few minutes. I still haven't tested the code. If it still doesn't work, could you provide me with a link to a fairly simple LUA script which shows the issue?
Re: Labcaches
March 04, 2020 10:32PM
https://project-gc.com/Challenges//46972

local finds = PGC.GetFinds(profileId, { includeLabCaches = true })
works correctly.

PGC.GetFinds(profileId, { includeLabCaches = true, fields = {'gccode', 'cache_name', 'visitdate','type', 'country'}, order = 'OLDESTFIRST', filter = filter })
however results in some backend error (see checker). Specifically, the order parameter. Without it, it works fine.



Edited 1 time(s). Last edit at 03/04/2020 10:33PM by PattuX. (view changes)
Re: Labcaches
March 05, 2020 12:15AM
Hi Pattux, it looks interesting:)-D, but I could not get it working yet. Would you make a calender matrix checker for lab caches? It should look like this one https://project-gc.com/Challenges/GC7GQTV/31113
Re: Labcaches
March 05, 2020 12:12PM
Such a challenge would surely not be published, see rule 10 of the guidelines.

Quote

Not allowed: Trackable, Benchmarking, Waymarking logs, or specifying Lab Cache finds.

I find "specifying" a bit vague, but I think it's fine to allow Lab Caches to count towards a challenge (i.e. as one type in "Find 100 caches for each of 7 types", or one date in "find a cache on each calendar date") but not to make them mandatory.

Also please use the Checker requests forum for checker requests.
Re: Labcaches
March 05, 2020 01:37PM
I was just curious wether it is really possible with your script or not. Would be fun to see, since U was not able to get your https://project-gc.com/Challenges//46972 working yet
Re: Labcaches
March 05, 2020 02:50PM
Just from a technical side it would be no problem, even now. PGC.GetLabCacheFinds(profileId) works correctly and contains log dates, so you could just modify some existing calendar checker to call that insead of PGC.GetFinds().
Re: Labcaches
March 06, 2020 11:20AM
PattuX Wrote:
-------------------------------------------------------
> https://project-gc.com/Challenges//46972
>
>
> local finds = PGC.GetFinds(profileId, {
> includeLabCaches = true })
>
> works correctly.
>
>
> PGC.GetFinds(profileId, { includeLabCaches = true,
> fields = {'gccode', 'cache_name',
> 'visitdate','type', 'country'}, order =
> 'OLDESTFIRST', filter = filter })
>
> however results in some backend error (see
> e checker). Specifically, the order parameter.
> Without it, it works fine.

Thank you for the script, most helpful.

I have found three issues, and corrected them in the development environment. I am aiming for a new release before 3 pm CET today. Could also be within an hour. Just have some other things to cleanup first.

Issue 1) When specifying fields, some fields are always added even though you don't request them. Those are fields used by the code. The log_id is required for the re-sort after adding Labcaches, but it was missing in the list of always-add-fields. Therefore you got the errors you got.
Issue 2) Type wasn't set to anything. It will from now on be set to *Labcache* (no stars).
Issue 3) Fields that doesn't exist for labcaches, should be filled with NULL. The callback has a mapping between field names and database column names, with table prefixes. Instead of setting for example log_id to NULL, I was setting l.log_id to NULL. I was using the value in the table instead of the key.

Conclusion: I need to trust myself less when changing the LUA callbacks. Seems like I more often get it wrong than right. At least I did say it was untested this time. :)

Typical example of a row from a labcache when fiels isn't specified:
    'gccode' => 'e71611de-13a8-42c3-8b66-879021f7bae4',
    'cache_id' => 1157519609,
    'cache_name' => 'Adventure 10 - Find the image',
    'type' => 'Labcache',
    'difficulty' => NULL,
    'terrain' => NULL,
    'size' => NULL,
    'owner_id' => NULL,
    'placed_by' => NULL,
    'latitude' => NULL,
    'longitude' => NULL,
    'elevation' => NULL,
    'hidden' => NULL,
    'last_publish_date' => NULL,
    'country' => NULL,
    'region' => NULL,
    'county' => NULL,
    'archived' => NULL,
    'disabled' => NULL,
    'premium' => NULL,
    'last_find_date' => NULL,
    'last_archive_date' => NULL,
    'num_finds' => NULL,
    'latest_logs' => NULL,
    'favorite_points' => NULL,
    'favorite_points_pct' => NULL,
    'favorite_points_wilson' => NULL,
    'last_cache_harvest' => NULL,
    'last_log_harvest' => NULL,
    'log_id' => NULL,
    'visitdate' => '2020-01-27',
    'length' => NULL,
    'words' => NULL,
    'attributes_set_1' => NULL,
    'attributes_set_2' => NULL,
    'attributes_unset_1' => NULL,
    'attributes_unset_2' => NULL,

I hope it works better for you now. I couldn't see anything else that's weird.
Re: Labcaches
March 06, 2020 12:40PM
Thanks, I'll have a look later when it's live.

> Issue 2) Type wasn't set to anything. It will from now on be set to *Labcache* (no stars).

On gc.com it's 'Lab Cache' btw. I guess it doesn't break anything but consistency is always nice.
Re: Labcaches
March 06, 2020 12:44PM
PattuX Wrote:
-------------------------------------------------------
> On gc.com it's 'Lab Cache' btw. I guess it doesn't
> break anything but consistency is always nice.

I'll update to 'Lab Cache' before the release. If I forget, please remind me.
Re: Labcaches
March 06, 2020 01:27PM
I had used the name 'Lab Cache' in Profile stats as well. I have changed the LUA callback to that now, and am preparing a release. Expect it to be live in ~5 minutes.
Re: Labcaches
March 06, 2020 02:27PM
Seems to be working :)

I also tried filters any everything seems fine so far. I'll let you know should I find some error.
Re: Labcaches
March 08, 2020 09:53AM
Ok, thank you for your effort Pattux and Magma1447, I could use your challenge checker now too, however I am still having problems with this issue:

This multi cache calender checker https://project-gc.com/Challenges/GC7GQTV/31113 uses this source: Generic calendar checker, by pinkunicorn

It displays every calendar day with a multi cache find in a nice looking table.

The decision, that multi caches are to be checked is made not by the source but with the tag config. I was able to change it from multi cache calender checker to traditional cache calender checker by changing the word multi cache into traditional cache in the tag config. However, changing it into Lab Cache does not show any finds, even though I definitely have found la caches on several days. In the source of Generic calendar checker there are lab caches mentioned with all the other caches, there is a lab cache icon with all the other icons, so I can not find the mistake.
Re: Labcaches
March 08, 2020 09:57AM
That script doesn't support Lab Caches, like most aren't. It just happens to have a copy/paste-block with the name and an icon. It's not fetching Lab caches from the API for example.

There probably aren't many active scripts handling Lab caches, probably even fewer that hasn't been created this year, if any.
Re: Labcaches
March 08, 2020 10:13AM
I guess it is not possible to change the script so it supports it?
Re: Labcaches
March 08, 2020 10:17AM
I don't think this thread is the right place for that discussions. But since it's possible to write such script, it's possible to change the script into handling it.

I can't answer for how hard it is since I don't know the script. It can possibly have unintended side-effects on other features in the script. It could very well be smarter to create a new script, that does what you want, therefore requesting a check could be more wise. I am personally for many small script that fills few purposes rather than gigantic unreadable scripts that does everything.
Re: Labcaches
March 08, 2020 04:24PM
Ok, I will simply request one. ;-)
Re: Labcaches
March 12, 2020 06:05AM
I've just updated the Multiple Test Checker (enhanced) script to allow includeLabCaches parameter for the functions which make sense to allow it (calendar, date, number, streak and in_a_year). Default is off, so that it doesn't change existing checkers.
Sorry, you do not have permission to post/reply in this forum.