App::Dochazka::REST::Model::Interval - activity intervals data model
use App::Dochazka::REST::Model::Interval; ...
A description of the activity interval data model follows.
Activity intervals are stored in the intervals database table, which has the following structure:
intervals
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.
tsrange
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).
iid
eid
aid
long_desc
remark
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:
constructor (spawn)
basic accessors (iid, eid, aid, intvl, long_desc, remark)
reset (recycles an existing object by setting it to desired state)
insert (inserts object into database)
delete (deletes object from database)
For basic activity interval workflow, see t/010-interval.t.
t/010-interval.t
This module provides the following exports:
iid_exists (boolean function)
Boilerplate.
Instance method. Attempts to INSERT a record. Field values are taken from the object. Returns a status object.
Instance method. Attempts to UPDATE a record. Field values are taken from the object. Returns a status object.
Instance method. Attempts to DELETE a record. Field values are taken from the object. Returns a status object.
Boolean function
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.
Nathan Cutler, <presnypreklad@gmail.com>
<presnypreklad@gmail.com>
To install App::Dochazka::REST, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Dochazka::REST
CPAN shell
perl -MCPAN -e shell install App::Dochazka::REST
For more information on module installation, please visit the detailed CPAN module installation guide.