Skip to content

Instantly share code, notes, and snippets.

@skslater
Last active December 10, 2023 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skslater/1108978713dd30d6a1b867d2b298390d to your computer and use it in GitHub Desktop.
Save skslater/1108978713dd30d6a1b867d2b298390d to your computer and use it in GitHub Desktop.
Plugin Filters

Plugins

Plugins are plain JSON files that specify one or more filters to pass data through. To be a valid plugin the file must also include a non-JSON header containing additional information.

Example of a minimal plugin to generate completely random passenger commodity groups.

// Id: basic_plugin
// Name: Basic Plugin
// Weight: 100
{
    "commodityType": "passenger"
}

The filter commodityType is required in all plugins.

There are currently two types of filter, generation filters and completion filters.

Generation filters

These specify how new demand is generated. At the start of each generation cycle a plugin is chosen at random via the weighting values in the plugins and a blank commodity group is created and passed through all registered generation filters specified in the plugin, the resulting commodity group is validated and then saved to the database.

The current list of generation filters available for plugins can be found here.

Completion filters

These specify further processing to be performed on completed commodity groups after completion. This type of filter can be used for generation of follow-on demand.

The current list of completion filters available for plugins can be found here.

Available completion filters


Return trip filters

returnTrip

The plugin will immediately generate a return trip for the completed commodity group

// Immediately fly the same group back again
{
    "returnTrip": true
}
returnAfterDays

The return flight will be scheduled after the specified number of days. This filter is silently ignored if returnTrip is not active.

// Create a return flight 14 days from the completion of the original flight
{
    "returnAfterDays": 14
}
returnAfterHours

The return flight will be scheduled after the specified number of hours. This filter is silently ignored if returnTrip is not active.

// Create a return flight 6 hours from the completion of the original flight
{
    "returnAfterHours": 6
}
returnAfterMinutes

The return flight will be scheduled after the specified number of minutes. This filter is silently ignored if returnTrip is not active.

// Create a return flight 25 minutes from the completion of the original flight
{
    "returnAfterMinutes": 25
}
returnOn

The return flight will be scheduled for the specified date and time. This filter is silently ignored if returnTrip is not active. For information on possible values see here.

// Return on the 24th August 2025
{
    "returnOn": "2025-08-24"
}

Available generation filters


Date filters

validFrom

The plugin will be skipped if the current date and time are earlier than the specified time.
For information on possible values see here.

// Valid only after July 1st 2024
{
    "validFrom": "2024-07-01"
}

// Valid only after 7PM
{
    "validFrom": "7PM"
}
validTo

The plugin will be skipped if the current date and time are later than the specified time.
For information on possible values see here.

// Valid only until December 1st 2024
{
    "validTo": "2024-12-01"
}

// Valid only before 11PM
{
    "validTo": "11PM"
}

Plugin limit filters

pluginCommodityLimit

The plugin will not generate further demand if the specified number of commodity groups are already available. This only applies to commodity groups created by this plugin.

// Only ever have a maximum of ten commodities from this plugin
{
    "pluginCommodityLimit": 10
}

Commodity type filters

commodityType **required**

Set the type of commodity generated by this plugin. The value here must match a slug from the platform commodities tables.

// Create a passenger commodity group
{
    "commodityType": "passenger"
}

Commodity expiry filters

expireAfterDays

This commodity will expire after the specified number of days.

// Expire in 7 days
{
    "expireAfterDays": 7
}
expireAfterHours

This commodity will expire after the specified number of hours.

// Expire in 12 hours
{
    "expireAfterHours": 12
}
expireAfterMinutes

This commodity will expire after the specified number of minutes.

// Expire in 30 minutes
{
    "expireAfterMinutes": 30
}
expireOn

This commodity will expire at the specified date and time. For information on possible values see here.

// Expire before the end of 2023
{
    "expireOn": "2023-12-31 23:59:00"
}

Airport filters

All of the below filters use an "origin" prefix to apply the filter to the departure airport, replace "origin" with "destination" to apply the restriction to the arrival airport.

originIcao

This plugin will generate commodity groups departing from the specified ICAO(s).

// Groups will always want to fly out of Boston
{
    "originIcao": "KBOS"
}

// Groups will be generated out of any of the listed airports
{
    "originIcao": ["KBOS", "KLAX", "KJFK"]
}
originAirportType

This plugin will generate commodity groups departing from the specified airport types. If not specified all airport types will be considered.

// Groups will only be generated departing heliports
{
    "originAirportType": "heliport"
}

// Groups will only be generated out of any of the listed airport types
{
    "originAirportType": ["small", "medium", "large", "heliport"]
}
originCountry

This plugin will generate commodity groups departing from airport in the specified country. If not specified no restriction will be placed on country. Countries should be listed as two-letter ISO codes.

// Groups will only be generated departing US airports
{
    "originCountry": "US"
}

// Groups will be generated out of any of the listed countries
{
    "originCountry": ["US", "UK", "FR", "DE"]
}
sameCountry

Restricts the choice of arrival airports. When this value is true the arrival airport will always be in the same country as the departure airports. When this value is false the arrival airport will never be in the same country as the departure airport.

// Groups will always depart and arrive from airports in the same country
{
    "sameCountry": true
}

// Groups will depart and arrive in different countries
{
    "sameCountry": false
}
originMinimumHardRunways

This plugin will only generate commodities departing airports with at least this many hard runways

// Groups will only be generated departing airports with at least two hard runways
{
    "originMinimumHardRunways": 2
}
originMinimumSoftRunways

This plugin will only generate commodities departing airports with at least this many soft runways

// Groups will only be generated departing airports with at least two soft runways
{
    "originMinimumSoftRunways": 2
}
originMinimumWaterRunways

This plugin will only generate commodities departing airports with at least this many water runways

// Groups will only be generated departing airports with at least two water runways
{
    "originMinimumWaterRunways": 2
}
originMinimumHelipads

This plugin will only generate commodities departing airports with at least this many helipads

// Groups will only be generated departing airports with at least one helipad
{
    "originMinimumHelipads": 1
}

Airport distance restriction filters

minimumDistance

This plugin will only choose arrival airports where the distance from the departure airport is at least this distance (in nmi)

// Groups will only be generated to airports at least 100nm from the departure airport
{
    "minimumDistance": 100
}
maximumDistance

This plugin will only choose arrival airports where the distance from the departure airport is at most this distance (in nmi)

// Groups will only be generated to airports 300nm or closer to the departure airport
{
    "maximumDistance": 300
}

Airport capacity restriction filters

ignoreCapacityLimits

This plugin is allowed to ignore the hard coded capacity limits for an airport. These limits are derived from the airport geo score but specialised plugins may want to override this, especially when using pluginCommodityLimit. The actual value is unimportant, the presence of this filter in the plugin is enough to bypass the capacity restrictions.

// Airport limitations are ignored for this plugin
{
    "ignoreCapacityLimits": true
}

Passenger group size filters

passengerCount

Generated commodities will always have this number of passenger in the group. This filter is silently ignored if the commodity type is not set to "passenger".

// Always put four passengers in each group
{
    "passengerCount": 4
}

passengerCountMinimum / passengerCountMaximum

Generated commodities will always have a number of passengers between the given minimum and maximum numbers. Both minimum and maximum must be specified. This filter is silently ignored if the commodity type is not set to "passenger".

// Always put between two and six passengers in each group
{
    "passengerCountMinimum": 2,
    "passengerCountMaximum": 6
}

Passenger class filters

passengerClass

This plugin will generate commodity groups with passengers in the specified seating classes. This filter is silently ignored if the commodity type is not set to "passenger". If no passengerClass filter is included in the plugin all passengers will default to economy class.

// Passenger groups will always want to fly first class
{
    "passengerClass": "first"
}

// Passenger groups will be generated in any of the listed classes
{
    "originIcao": ["economy", "business", "first"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment