The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::Dochazka::REST::Model::Interval - activity intervals data model

SYNOPSIS

    use App::Dochazka::REST::Model::Interval;

    ...

DESCRIPTION

A description of the activity interval data model follows.

Intervals in the database

Activity intervals are stored in the intervals database table, which has the following structure:

    CREATE TABLE intervals (
       iid         serial PRIMARY KEY,
       eid         integer REFERENCES employees (eid) NOT NULL,
       aid         integer REFERENCES activities (aid) NOT NULL,
       intvl       tsrange NOT NULL,
       long_desc   text,
       remark      text,
       EXCLUDE USING gist (eid WITH =, intvl WITH &&)
    );

Note the use of the tsrange operator introduced in PostgreSQL 9.2.

In addition to the Interval ID (iid), which is assigned by PostgreSQL, the Employee ID (eid), and the Activity ID (aid), which are provided by the client, an interval can optionally have a long description (long_desc), which is the employee's description of what she did during the interval, and an admin remark (remark).

Intervals in the Perl API

In the data model, individual activity intervals (records in the intervals table) are represented by "interval objects". All methods and functions for manipulating these objects are contained in this module. The most important methods are:

For basic activity interval workflow, see t/010-interval.t.

EXPORTS

This module provides the following exports:

METHODS

load_by_iid

Boilerplate.

insert

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

update

Instance method. Attempts to UPDATE a record. Field values are taken from the object. Returns a status object.

delete

Instance method. Attempts to DELETE a record. Field values are taken from the object. Returns a status object.

FUNCTIONS

iid_exists

Boolean function

fetch_by_eid_and_tsrange

Given an EID and a tsrange, return all that employee's intervals that fall within that tsrange.

Before any records are returned, the tsrange is checked to see if it overlaps with any privlevel or schedule changes - in which case an error is returned. This is so interval report-generators do not have to handle changes in employee status.

AUTHOR

Nathan Cutler, <presnypreklad@gmail.com>