ynorth-projects / openy_pef_gxp_sync
Synchronizes Groupex schedules to PEF.
Installs: 58 240
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 2
Open Issues: 0
Type:drupal-module
Requires
- drupal/core: >=10.0.0
- ycloudyusa/yusaopeny: *
This package is auto-updated.
Last update: 2024-11-30 01:52:32 UTC
README
Synchronizes GroupEx schedules to PEF.
Quick start
Enable the modules
- Log in as an Admin
- Go to Extend (
/admin/modules
) - Install
OpenY PEF GXP Sync
andOpen Y Mappings Feature
then enable all dependencies as requested on the next step.
Configure the OpenY GXP module
-
Go to: Open Y -> Integrations -> GroupEx Pro -> GroupEx Pro settings (
/admin/openy/integrations/groupex-pro/gxp
). -
Set up your GroupExPro Client Id (which you can obtain from GroupEx PRO support).
-
Provide the parent activity ID. It should be listed in Group Exercises, under Fitness.
-
Enter Activity
Group Exercise Classes
(choose node of type Activity from autocomplete). Most likely the ID will be 94 if this is a default demo content). -
Enter Locations Mapping in the following format:
202,West YMCA 204,Downtown YMCA 203,East YMCA 3718,South YMCA
-
Save the configuration.
-
Go to: Configuration -> System -> YMCA Sync settings (
/admin/config/system/ymca-sync
) -
Enable the checkbox labeled
openy_pef_gxp_sync
and Save. Theopeny_pef_gxp_sync
module should be enabled in your system. -
Go to: Open Y -> Settings -> Mappings -> Mapping list (
/admin/openy/settings/mappings/mapping
) -
Add mappings for every branch you would like to synchronize:
- Enter the name of the mapping to easily identify it in the future. For instance,
West YMCA GXP sync mapping
. - Authored by - Keep as is
- Locations - Choose Branch
- GroupEx ID - Enter the GroupEx ID of the Branch
- Save
- Enter the name of the mapping to easily identify it in the future. For instance,
-
Go to:
admin/openy/settings/groupex-enabled-locations
and enable Locations that you want to sync. -
Run the Drush command to sync from your project docroot:
drush openy-pef-gxp-sync
(Drupal 8, Drush 8)drush yn-sync openy_pef_gxp_sync.syncer
(Drupal 9, Drush 10)
How to sync my GroupEx data to my project?
See the final step above for the proper Drush commands.
How the syncer works
The syncer consists of the next steps:
- Fetcher - fetches data from GroupEx API.
- Wrapper - processes the data for saving (maps location ids, fixes title encoding problems, etc).
- Wrapper - groups all items by Class ID and Location ID, calculates hashes.
- Wrapper - prepares data to be removed (extra items in DB or changed hashes)
- Wrapper - prepares data to be created (new items + changed hashes)
- Cleaner - removes data to be removed.
- Saver - creates data to be created.
How the syncer works (for developers)
Adding & Removing locations
- If a location is removed in API it should be removed in DB.
- If a location is added in API it should be added (with classes) in DB.
- If a class is removed in API it should be removed in DB (with all class items);
- If a class is added in API it should be added in DB (with all class items);
Updating classes
- Each GroupEx class can have several class items (with the same class ID).
- We compare hashes for Location ID + Class ID + all class items inside (on unprocessed data!).
- If the hash is changed we should remove all items belonging to this hash and create them again.
How to debug
- To emulate API data please use
FetcherDebuggerClass
. Just replace@openy_pef_gxp_sync.fetcher
with@openy_pef_gxp_sync.fetcher_debugger
to emulate API response. - Use
DEBUG_MODE
constants inside classes to debug specific services.
Known issues in sync.
- There is an issue if a class in a GroupEx has its category set to "General" - it will not be synced and displayed at PEF. This is a limitation of GroupEX PRO API.
Default Syncer behavior
By default, the Syncer creates unpublished Session nodes. In order for them to become visible in the Schedules application, you'd need to set config variables to allow unpublished entities to be displayed
- config
openy_repeat.settings
- variableallow_unpublished_references: 1
- this is for unpublished Session, Program, Program Subcategory session nodes. - config
openy_session_instance.settings
- variableallow_unpublished_references: 1
- this works only for unpublished Session nodes.
Run next commands if you want to switch to published mode
:
drush cset openy_repeat.settings allow_unpublished_references 1 -y
drush cset openy_session_instance.settings allow_unpublished_references 1 -y
Run next commands if you want to switch to unpublished mode
:
drush cset openy_repeat.settings allow_unpublished_references 0 -y
drush cset openy_session_instance.settings allow_unpublished_references 0 -y
You need to clear cache in order to get this setting working.
At this moment we have no UI for setting these variables, so using drush cset
or importing configs via Config Manager is recommended.
Enabled Groupex Locations
Use config openy_pef_gxp_sync.enabled_locations
to allow locations from GroupEx PRO to be synced.
This config contains an array of location IDs from GroupEx.