forio Toggle navigation

Saved Runs Manager

The Saved Runs Manager is a specific type of Run Manager which provides access to a list of runs (rather than just one run). It also provides utility functions for dealing with multiple runs (e.g. saving, deleting, listing).

An instance of a Saved Runs Manager is included automatically in every instance of a Scenario Manager, and is accessible from the Scenario Manager at .savedRuns. See more information on using .savedRuns within the Scenario Manager.

Constructor options

Required? Name Type Description
  scopeByGroup boolean If set, will only pull runs from current group. Defaults to true.
  scopeByUser boolean If set, will only pull runs from current user. Defaults to true. For multiplayer run comparison projects, set this to false so that all end users in a group can view the shared set of saved runs.
  run object Run Service options

Methods

save(run[, otherFields])

Marks a run as saved.

Note that while any run can be saved, only runs which also match the configuration options scopeByGroup and scopeByUser are returned by the getRuns() method.

Parameters

Required? Name Type Description
Yes run String / RunService Run to save. Pass in either the run id, as a string, or the Run Service.
  otherFields object Any other meta-data to save with the run.

Example

const sm = new F.manager.ScenarioManager();
sm.savedRuns.save('0000015a4cd1700209cd0a7d207f44bac289');

remove(run[, otherFields])

Marks a run as removed; the inverse of marking as saved.

Parameters

Required? Name Type Description
Yes run String / RunService / object Run to remove. Pass in either the run id, as a string, or the Run Service.
  otherFields object any other meta-data to save with the run.

Example

const sm = new F.manager.ScenarioManager();
sm.savedRuns.remove('0000015a4cd1700209cd0a7d207f44bac289');

mark(run, toMark)

Sets additional fields on a run. This is a convenience method for RunService#save.

Parameters

Required? Name Type Description
Yes run String / Array.<string> / RunService Run to operate on. Pass in either the run id, as a string, or the Run Service.
Yes toMark Object Fields to set, as name : value pairs.

Example

const sm = new F.manager.ScenarioManager();
sm.savedRuns.mark('0000015a4cd1700209cd0a7d207f44bac289', 
    { 'myRunName': 'sample policy decisions' });

getRuns([variables, filter, modifiers, options])

Returns a list of saved runs. Note: This recursively fetches all runs by default; if you need access to data as it's being fetched use options.onData, else the promise is resolved with the final list of runs.

Parameters

Required? Name Type Description
  variables Array.<string> If provided, in the returned list of runs, each run will have a .variables property with these set.
  filter object Any filters to apply while fetching the run. See RunService#filter for details.
  modifiers object Use for paging/sorting etc. See RunService#filter for details.
  options object
  options.onData function(Array.<object>): undefined Use to get progressive data notifications as they're being fetched. Called with <options.recordsPerFetch> runs until all runs are loaded.
  options.recordsPerFetch Number Control the number of runs loaded with each request. Defaults to 100, set to lower to get results faster.

Example

const sm = new F.manager.ScenarioManager();
sm.savedRuns.getRuns().then(function (runs) {
    for (const i=0; i<runs.length; i++) {
        console.log('run id of saved run: ', runs[i].id);
    }
});