Currently are just two adapters available.
Feel free to create new ones based on the instructions in section 'Add a Custom Adapter'.
In best case choose a database which is also available as a free DBaaS tier: ripienaar/free-for-dev.
The storage is default and initialized when passing no DB
environment variable. Since it is a in-memory state which is not synced with a database ensure that the service is deployed exactly once.
This storage adapts MongoDB and is initialized when passing a mongodb://
connection url to DB
environment variable. There are free DBaaS solutions like MongoDB Atlas.
To create a new custom adapter extend the adapter
and add the custom adapter to the index. You need to implement an interface with the asynchronous methods listed below.
The basic error handling for this functions is implemented in composeWrapper
.
-
Run basic initialization tasks like setting up the database connection.
Cleanup all scheduled events which were scheduled before the current datetime string.Input:
n/aOutput:
n/a -
Check if a user already has ever signed up.
Input:
user <string>
– The userId of the slack userOutput:
<boolean>
– Whether the user withuserId
has ever signed up. -
Check if a user already has signed up for the next matching and in which location.
Check all available locations.Input:
user <string>
– The userId of the slack userOutput:
<string|undefined>
– The name of the location orundefined
. -
Add a user to the defined location and to a list of signed up users.
Just add the user if theuserId
is not mapped to any location.
Additionally add theuserId
to another collection of unique users to identify recurring users.
Optionally increment the count in this list to get statistics.Input:
location <string>
– The name of the location
user <string>
– The userId of the slack userOutput:
<boolean>
– Whether the the user was added to a location -
Remove a user of all the locations if available.
Input:
user <string>
– The userId of the slack userOutput:
n/a -
Get list of matches of the defined size for all passed locations.
Usethis.chunk
andthis.sort
to get chunks of random matches.
Usethis.flatten
to flatten the list to get the desired format.Input:
locations <Array.<string>>
– A list of names of locations to be used to find matchesOutput:
<Array.<Array.<string>>>
– A list of matches where each match is a list of userIds. -
Delete documents related to the passed location names.
Delete the whole object and do not only clear the array of signed up users.Input:
locations <Array.<string>>
– A list of names of locations to be deleted.Output:
n/a -
If there is already an event scheduled at the same time & location, return the event.
Otherwise add a scheduled event to the defined location.
Additionally add all arguments as new document to another collection.Input:
user <string>
– The userId of the slack user.
location <string>
– The name of the location.
datetime <string>
– The datetime (UTC) as ISO string.Output:
<object|undefined>
– The existing event with the same data orundefined
. -
Get list of locations with have an event scheduled at the passed datetime.
Remove the datetime in the list of events per location if there was a match.Input:
datetime <string>
– The datetime (UTC) as ISO string.Output:
<Array.<string>>
– A list of names of matched locations. -
Find the first scheduled event for the specific location.
Return an object the keystime
andtitle
(optional).
If there is no event scheduled, return{}
.Input:
location <string>
– The name of the location.Output:
<object>
– The next scheduled event for the passed location -
Get mapping of all scheduled events per location.
Key is the location name and value the list of datetimes.Input:
n/aOutput:
Object
– List of scheduled events. -
If there is already a skip set at the same date, return the event. Otherwise set a skip.
Additionally add all arguments as new document to another collection.Input:
user <string>
– The userId of the slack user.
datetime <string>
– The datetime (UTC) as ISO string.Output:
<object|undefined>
– The existing event with the same data orundefined
. -
Get list of all set skips.
Input:
n/aOutput:
Object
– List of set skips inYYYY-MM-DD HH:mm
.