hippysurfer / OSM-Connect

Google Script App for connecting to Online Scout Manager
GNU General Public License v3.0
5 stars 3 forks source link

Adaptation for Waiting List reports #1

Closed gcor71 closed 1 year ago

gcor71 commented 1 year ago

@hippysurfer Loving this project, perfect timing as I'm trying to combine a Google App Sheet mobile deployment with automated data collection from OSM to create a new way of managing district WLs.

My plan is to adapt your approach to pull member details from waiting list sections only. Baring in mind I don't need to preserve the functionality to the other functions (subs etc), I've been able to modify the [OSM.gs and member.gs code to include "waiting" in the list of sections presented in the dialogue and adjusted the spreadsheet output to include the fields I want.

But I'm stuck. I can't figure out how to return ONLY waiting list section types to the dialogue - and not all the other, beavers, cubs etc.

Even better - if I could do away with the dialogue all together and trigger the fetch of data, for any 'waiting' section, programmatically (and later, to a schedule) - thereby allowing automation of the report.

Suggestions to approach this welcome.

hippysurfer commented 1 year ago

Hi, should not be too tricky to support waiting lists. I will have a look. (It might take me a few days to find the time).

gcor71 commented 1 year ago

I don't want you spending time unnecessarily, so to let you know that I solved my particular use case. I've got it running 'silently' (no user input) and so scheduled to run daily to update my source Sheet. Key changes are:

in code.gs added:

menu.addItem("Fetch Waiting ...", "fetch_waiting");

in member.gs added new function to hard code section numbers:

function fetch_waiting(){ // Clear sheet var ss = SpreadsheetApp.getActiveSpreadsheet(); var osm_data = ss.getSheetByName("OSM_DATA"); osm_data.clear(); // Hardcode WL sections - far easier than trying to work out how to extract them autonomously action_fetch_members(["59265","57934","60066","6559","48692","58796","63232","4218","29131","31187","53876","56318","60067","17567","25519","54887"]); }

Also in member.gs , tweaked the fetch_members function to a) hard code the term as -1; b) retrieve the groupname so aiding identifying where the data came from:

fetch_members(section) { Logger.log(section); var result = this.fetch( "ext/members/contact/grid/?action=getMembers" + "&term_id=-1", section.sectionid); var values = []; for (var key in result.data) { values.push(result.data[key]); } result = values.map( function (elem) { elem['section_name'] = section.groupname; elem['section_type'] = section.section; return elem; } ); return result; }

If you had time, the part I'd want to improve is removing the hardcoded section numbers. I'm not bright enough to figure out how to adapt your rather elegant solution to do this automatically.

Regardless, I am VERY grateful you shared this project. I tried automating exactly this data extraction from OSM in Sheets last year and got almost nowhere - my ambition outweighed my capability :-). Thank you.

hippysurfer commented 1 year ago

Thank you for the issue. I have added initial support for waiting lists. Could still do with some work but it does show how to avoid hardcoding the section ids.

gcor71 commented 10 months ago

Thank you! I hadn't realised until looking for the next thing that you had added this support! I botched my way through using your prompts and got something good enough working to automatically pull waiting list details from across our district, drop them into Sheets and from there integrate them into a Google AppSheet app for waiting list management. Nice work!