The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

App::Dochazka::REST::Model::Schedhistory - schedule history functions

VERSION

Version 0.075

SYNOPSIS

    use App::Dochazka::REST::Model::Schedhistory;

    ...

DESCRIPTION

A description of the schedhistory data model follows.

Schedhistory in the database

Table

Once we know the SID of the schedule we would like to assign to a given employee, it is time to insert a record into the schedhistory table:

      CREATE TABLE IF NOT EXISTS schedhistory (
        int_id     serial PRIMARY KEY,
        eid        integer REFERENCES employees (eid) NOT NULL,
        sid        integer REFERENCES schedules (sid) NOT NULL,
        effective  timestamp NOT NULL,
        remark     text,
        stamp      json
      );

Stored procedures

This table also includes two stored procedures -- schedule_at_timestamp and current_schedule -- which will return an employee's schedule as of a given date/time and as of 'now', respectively. For the procedure definitions, see dbinit_Config.pm

See also "When history changes take effect".

Schedhistory in the Perl API

  • constructor (spawn)

  • reset method (recycles an existing object)

  • basic accessors (int_id, eid, sid, effective, remark)

  • load method (load schedhistory record from EID and optional timestamp)

  • insert method (straightforward)

  • delete method (straightforward) -- not tested yet # FIXME

For basic workflow, see t/007-schedule.t.

EXPORTS

This module provides the following exports:

METHODS

spawn

Constructor. See Employee.pm->spawn for general comments.

reset

Instance method. Resets object, either to its primal state (no arguments) or to the state given in PARAMHASH.

Accessor methods

Basic accessor methods for all the fields of Schedhistory table. These functions return whatever value happens to be associated with the object, with no guarantee that it matches the database.

int_id

Accessor method.

eid

Accessor method.

sid

Accessor method.

effective

Accessor method.

remark

Accessor method.

load

Instance method. Given an EID, and, optionally, a timestamp, loads a single Schedhistory record into the object, rewriting whatever was there before. Returns a status object.

insert

Instance method. Attempts to INSERT a record into the 'Schedhistory' table. Field values are taken from the object. Returns a status object.

update

There is no update method for schedhistory records. Instead, delete and re-create.

delete

Instance method. Deletes the record. Returns status object.

AUTHOR

Nathan Cutler, <presnypreklad@gmail.com>