Toggle menu

Maintenance Mode

Unlike other areas of the platform, placing the History worker into maintenance mode does not disable it - histories can still be read and written as normal. Instead it enables the timestamp parameter in the log() function, which lets you manually set the timestamps for events and other dates in the history, rather than them defaulting to "now".

Enabling Maintenance Mode

Placing the service into maintenance mode is described in System Online/Offline. While in maintenance mode all functions continue to operate as normal, there's no impact on any other service using the History worker.

Log() in Maintenance Mode

In maintenance mode you can include the timestamp parameter when logging histories. Note that this is always an integer, representing milliseconds since 00:00:00 Thursday, 1 January 1970 (Unix time). This may be useful if for some reason you need to recreate a history that has been deleted, or perhaps import histories into the system.

New Histories

Once in maintenance mode, a new history could be created like this:

function(params, credentials) {
    let result = this.callWorkerMethod("history", "log", {
        "labela": "maintenance example",
        "labelb": "3",
        "timestamp": 1234567890123, //13 Feb 2009
        "subject": {
            "name": {
                "first": "Tim"
            }
        },
        "event": {
            "type": "birthday",
            "age": 36
        }
    });
    return result;
}

The supplied timestamp is used for the created and lastupdated times, and the time of the first event:

{
    "jsonrpc": "2.0",
    "id": 1129,
    "result": {
        "labela": "maintenance example",
        "labelb": "3",
        "labelc": null,
        "labeld": null,
        "labele": null,
        "created": 1234567890123, //13 Feb 2009
        "lastupdated": 1234567890123, //13 Feb 2009
        "id": "cd69093a-dc7e-4182-82a6-4481474340dc",
        "sealed": false,
        "subject": {
            "name": {
                "first": "Tim"
            }
        },
        "events": [{
            "pos": [1, 1],
            "event": {
                "type": "birthday",
                "age": 36
            },
            "fpos": [1, 1],
            "timestamp": 1234567890123 //13 Feb 2009
        }]
    }
}

New Events

When adding a new event to an existing history, the timestamp you provide is used for the new event and for the the lastupdated time of the history. Adding a new event with a different timestamp to the history above:

this.callWorkerMethod("history", "log", {
    "labela": "maintenance example",
    "labelb": "3",
    "timestamp": 1548948303033, //31 Jan 2019
    "event": {
        "type": "additional info"
    }
});

Would result in:

{
    "jsonrpc": "2.0",
    "id": 1132,
    "result": {
        "labela": "maintenance example",
        "labelb": "3",
        "labelc": null,
        "labeld": null,
        "labele": null,
        "created": 1234567890123, //13 Feb 2009
        "lastupdated": 1548948303033, //31 Jan 2019
        "id": "cd69093a-dc7e-4182-82a6-4481474340dc",
        "sealed": false,
        "subject": {
            "name": {
                "first": "Tim"
            }
        },
        "events": [{
            "pos": [1, 2],
            "event": {
                "type": "birthday",
                "age": 36
            },
            "fpos": [1, 2],
            "timestamp": 1234567890123 //13 Feb 2009
        }, {
            "pos": [2, 2],
            "event": {
                "type": "additional info"
            },
            "fpos": [2, 2],
            "timestamp": 1548948303033 //31 Jan 2019
        }]
    }
}

Sealed Histories

Maintenance mode also allows you to add events to sealed histories, ie existing histories that could not normally be written to.

Last modified on April 02, 2024

Share this page

Facebook icon Twitter icon email icon

Print

print icon