App-Dochazka-REST

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  META_DOCHAZKA_RESOURCE_DOCS and store resource documentation strings
  there during path router initialization
- in the 'docu' target, get the HTML string from
  META_DOCHAZKA_RESOURCE_DOCS meta param
- Resource.pm: no longer need to push documentation HTML string onto the
  context
- Test.pm: add a 'docu_check' routine (to automate testing of each resource
  for presence of documentation in the resource definition)
- t/dispatch/top.t: run docu_check on each top-level resource

0.208  2014-10-24 08:43 CEST
- convert portion of employee dispatch tests to new structure

0.209  2014-10-24 10:49 CEST
- complete development workflow for employee resources
- dispatch_Employee_Config.pm: add missing documentation
- Dispatch/Employee.pm: fix bug "DELETE employee/nick/:nick actually
  inserts a new employee if :nick not found"
- t/: continue migrating dispatch tests to new structure; disable old
  units so ./Build test doesn't run them; add new unit
  t/dispatch/employee/nick.t

0.210  2014-10-24 15:33 CEST
- Hackweek Day 5
- implement privhistory resources using new development workflow
- merge 'privhistory/current' and 'privhistory/current/:tsrange' into a
  single resource 'privhistory/current/?:tsrange'
- dispatch/dispatch_Privhistory_Config.pm: put resources in alphabetical
  order; document resources; add more supported methods
- t/dispatch/privhistory: add privhistory tests in new structure
- Dispatch/Privhistory.pm: put targets in order according to their
  corresponding resources; rename _get_nick and _get_eid to _nick and _eid,
  respectively, and expand them to support PUT and DELETE
- Model/Privhistory.pm: add some debug messages

0.211  2014-10-24 22:40 CEST
- Hackweek Day 5, continued
- config/sql/dbinit_Config.pm: add UNIQUE (eid, effective) constraint to
  privhistory table to avoid duplicate entries in a given employee's
  privhistory listing
- dispatch_Message_en.conf: add DISPATCH_PRIVHISTORY_COULD_NOT_SPAWN
- Dispatch/Privhistory.pm: implement support for PUT and DELETE requests in
  _eid and _nick targets
- Model/Employee.pm: fix bug "get 500 Server Error when I send a request for
  bogus resource 'privhistory/eid/asdf'"
- t/dispatch/privhistory/: add quite a few tests

Changes  view on Meta::CPAN


0.239  2014-11-03 12:15 CET
- renamed all 'priv/current/...' and 'schedule/current/...' resources
  to 'priv/self/...' and 'schedule/self/...', respectively
- Dispatch/Priv.pm: renamed _get_current to _get_history_self; move
  _current_priv logic to Dispatch/Shared.pm->current because we will call it
  from Dispatch/Schedule.pm as well;
- Dispatch/Schedule.pm: ongoing adaptations
- t/: adapt to current state

0.240  2014-11-03 16:19 CET
- MANIFEST: add Dispatch/Schedule.pm, t/dispatch/schedule.t
- activity_Config.pm: add 'activity/help' resource definition
- priv_Config.pm, etc.: rename some resources and targets
  (in particular s/current/self/ in resource names)
- dispatch_Config.pm, Resource.pm: activate schedule resources
- dispatch_Message_en.pm: add new DISPATCH_EMPLOYEE_SCHEDULE and
  DISPATCH_EMPLOYEE_SCHEDULE_AS_AT messages
- config/sql/schedule_Config.pm: add new SQL_SCHEDHISTORY_SELECT_RANGE_BY_EID
  and SQL_SCHEDHISTORY_SELECT_RANGE_BY_NICK params
- Dispatch/Shared.pm: adapt 'current' routine to work for both priv and
  schedule resources
- Model/Shared.pm: fix some bugs
- Resource.pm: activate schedule resources
- t/dispatch/activity.t: add tests for 'activity/help'
- t/dispatch/schedule.t: add tests for "/schedule/eid/:eid/?:ts",
  "/schedule/help", "/schedule/nick/:nick/?:ts", and "/schedule/self/?:ts"
  resources

0.241  2014-11-03 22:32 CET
- Dispatch/Shared.pm: "numify" $eid in return value payload from dispatch
  target 'current'; check for hashref instead of scalar now that we are
  converting the schedule from JSON string into Perl hashref
- Model/Schedule.pm: rename 'get_json' to 'get_schedule_json' and add
  'decode_schedule_json' for converting the schedule JSON string into a Perl
  hashref
- Model/Shared.pm: return decoded schedule (hashref) from schedule_by_eid
- t/dispatch/schedule.t: uncomment/adapt some tests
- t/: get model units to run cleanly again

0.242  2014-11-04 08:30 CET
- config/dispatch/schedule_Config.pm: put resource definitions in alphabetical order;
  add missing POD; add missing 'schedule/intervals' resource definition

0.243  2014-11-04 09:56 CET
- schedule_Config.pm, Dispatch/Schedule.pm: make 'schedule/history/...'
  resources use "not_implemented" dispatch target so they don't vomit 500

0.244  2014-11-04 11:32 CET
- schedule_Config.pm: split 'schedule/intervals/?:shid' into two separate
  resources for parsing clarity

0.245  2014-11-04 17:50 CET
- Build.PL: require App::Dochazka 0.175 for 'ssid' (instead of 'scratch_sid')
- schedule_Config.pm: 'schedule/intervals' is POST and DELETE only; activate
  DELETE on 'schedule/intervals/:sid'; rename ':shid' parameter to ':sid'
- rename 'scratch_sid' field/property of intervals to 'ssid'
- dispatch_Message_en.conf: add DISPATCH_SCHEDINTVLS_MISSING,
  DISPATCH_SCHEDULE_INSERT_OK, DISPATCH_SCHEDULE_NO_UPDATE
- Dispatch/Schedule.pm: add _intervals_post and _intervals_delete dispatch
  targets
- move 'expurgate' logic to Model/Shared.pm and implement a wrapper method
  in each model module
- Model/Schedintvls.pm: fix 'insert' method so it returns a sensible status
  payload
- Test.pm: in docu_check, run 'payload' tests only if there is a payload;
  add as-yet untested 'create_testing_schedule' and 'delete_testing_schedule'
  routines
- t/: add new 'intervals.t' unit; adapt existing units to current state

0.246  2014-11-04 21:08 CET
- stabilization after the last commit
- t/dispatch/intervals.t: add some tests called for by development workflow

0.247  2014-11-04 22:21 CET
- add 'DISPATCH_SCHEDULE_EXISTS' message
- add 'schedule/all' and 'schedule/all/disabled' resource definitions
- add 'disabled' field to 'schedules' table
- Dispatch/Schedule.pm: when schedule already exists, return
  'DISPATCH_SCHEDULE_OK'
- t/dispatch/intervals.t: test for 'DISPATCH_SCHEDULE_OK' when inserting the
  same schedule a second time

0.248  2014-11-05 11:05 CET
- Build.PL: require App::Dochazka 0.176 to ensure Schedule objects have a
  'disabled' property
- config/dispatch/schedule_Config.pm: activate 'schedule/all' and 
  'schedule/all/disabled' resources
- config/sql/schedule_Config.pm: add 'disabled' field to SQL statements;
  add two new SQL statements to get all schedule records
- Dispatch/Schedule.pm: import 'get_all_schedules' and
  'get_all_schedules_including_disabled' routines
- Model/Schedule.pm: implement 'get_all_schedules' and
  'get_all_schedules_including_disabled' routines

0.249  2014-11-05 12:18 CET
- give 'schedule/all/...' dispatch targets more sensible names
- enable POST on 'schedule/intervals/:sid', including documentation
- t/dispatch/schedule.t: add 405 tests for 'schedule/all/...'

0.250  2014-11-05 17:54 CET
- Build.PL: require App::Dochazka 0.177 for TO_JSON method; require
  App::CELL 0.201 to get rid of Data::Structure::Util
- Resource.pm: get rid of wacky debug code; add 'convert_blessed' to our
  JSON 'encode' method call now that we have TO_JSON methods in all models;
  this obviates the need to call 'unblessed'

Changes  view on Meta::CPAN

- Util/Date.pm: drop unused dependency
- REST/Test.pm: skip tests if Mason initialization fails
- Implement Feature #39:
  - REST.pm: implement, use, test reset_mason_dir() routine
  - REST.pm->reset_mason_dir(): return comp_root in payload
  - REST.pm->reset_mason_dir(): return payload only on success
  - Model/Component.pm: add create_file method
  - Model/Component.pm: call create_file on successful insert and update
  - Model/Component.pm: add delete_file method

0.508 2016-01-02 20:24 CET
- Build.PL: add Mason dependency
- docker: add Mason dependency
- t/mason.t: skip tests if state directory inaccessible

0.509 2016-01-02 21:56 CET
- docker: add new dependencies and create state directory
- ResourceDefs.pm: add genreport resource definition
- Implement basic "POST genreport" operation

0.510 2016-01-02 23:24 CET

lib/App/Dochazka/REST/Model/Interval.pm  view on Meta::CPAN

    $status = tsrange_to_dates_and_times( $canon_tsrange );
    return $status unless $status->ok;

    # extract the beginning/ending dates/times
    my $pl = $status->payload;
    my $begin_date = $pl->{begin}->[0];
    my $begin_time = $pl->{begin}->[1];
    my $end_date = $pl->{end}->[0];
    my $end_time = $pl->{end}->[1];

    # interval must begin and end at 00:00/24:00,
    # otherwise no game
    return $CELL->status_err( 'DISPATCH_SUMMARY_ILLEGAL_TSRANGE' ) unless
        ( $begin_time eq '00:00' or $begin_time eq '24:00' ) and 
        ( $end_time eq '00:00' or $end_time eq '24:00' );

    # get list of dates in range
    my $date_hash = holidays_and_weekends( begin => $begin_date, end => $end_date );

    # get intervals for each date
    foreach my $date ( keys %$date_hash ) {

t/dispatch/interval_lock.t  view on Meta::CPAN

    is( $status->{'payload'}->{'aid'}, $aid_of_work );
    ok( $status->{'payload'}->{'iid'} );
    return $status->{'payload'}->{'iid'};
}

sub create_testing_lock {
    my ( $test ) = @_;
    
    note( 'in create_testing_lock() function' );
    $status = req( $test, 201, 'root', 'POST', 'lock/new', <<"EOH" );
{ "eid" : $eid_active, "intvl" : "[2013-06-01 00:00, 2013-06-30 24:00)" }
EOH
    if( $status->level ne 'OK' ) {
        diag( Dumper $status );
        BAIL_OUT(0);
    }
    is( $status->level, 'OK' );
    is( $status->code, 'DOCHAZKA_CUD_OK' );
    ok( $status->{'payload'} );
    ok( $status->{'payload'}->{'lid'} );
    return $status->{'payload'}->{'lid'};

t/fillup.t  view on Meta::CPAN

    isa_ok( $intervals->[$i], 'App::Dochazka::REST::Model::Interval' );
    is( $intervals->[$i]->iid, undef );
}
like( $intervals->[0]->intvl, qr/^\["1998-06-08 10:05:00...","1998-06-08 12:00:00..."\)$/ );
like( $intervals->[1]->intvl, qr/^\["1998-06-08 12:30:00...","1998-06-08 16:30:00..."\)$/ );
like( $intervals->[2]->intvl, qr/^\["1998-06-09 08:00:00...","1998-06-09 12:00:00..."\)$/ );
like( $intervals->[3]->intvl, qr/^\["1998-06-09 12:30:00...","1998-06-09 14:00:00..."\)$/ );
like( $intervals->[4]->intvl, qr/^\["1998-06-09 14:15:00...","1998-06-09 16:30:00..."\)$/ );
like( $intervals->[5]->intvl, qr/^\["1998-06-10 08:00:00...","1998-06-10 09:55:00..."\)$/ );

note( $note = "GET interval/nick/active/[ \"1998-06-08 00:00\", \"1998-06-10 24:00\" )" );
my @ARGS = (
    $faux_context->{'dbix_conn'},
    $active->eid,
    "[ \"1998-06-08 00:00\", \"1998-06-10 24:00\" )",
);
$status = fetch_intervals_by_eid_and_tsrange( @ARGS );
$intervals = $status->payload;
is(scalar @$intervals, 3 );
isa_ok( $intervals->[0], 'App::Dochazka::REST::Model::Interval' );
ok( $intervals->[0]->iid > 0 );
like( $intervals->[0]->intvl, qr/^\["1998-06-08 09:55:00...","1998-06-08 10:05:00..."\)$/ );
isa_ok( $intervals->[1], 'App::Dochazka::REST::Model::Interval' );
ok( $intervals->[1]->iid > 0 );
like( $intervals->[1]->intvl, qr/^\["1998-06-09 14:00:00...","1998-06-09 14:15:00..."\)$/ );

t/fillup.t  view on Meta::CPAN

    isa_ok( $intervals->[$i], 'App::Dochazka::REST::Model::Interval' );
    ok( $intervals->[$i]->iid > 0 );
}
like( $intervals->[0]->intvl, qr/^\["1998-06-08 10:05:00...","1998-06-08 12:00:00..."\)$/ );
like( $intervals->[1]->intvl, qr/^\["1998-06-08 12:30:00...","1998-06-08 16:30:00..."\)$/ );
like( $intervals->[2]->intvl, qr/^\["1998-06-09 08:00:00...","1998-06-09 12:00:00..."\)$/ );
like( $intervals->[3]->intvl, qr/^\["1998-06-09 12:30:00...","1998-06-09 14:00:00..."\)$/ );
like( $intervals->[4]->intvl, qr/^\["1998-06-09 14:15:00...","1998-06-09 16:30:00..."\)$/ );
like( $intervals->[5]->intvl, qr/^\["1998-06-10 08:00:00...","1998-06-10 09:55:00..."\)$/ );

note( $note = "GET interval/nick/active/[ \"1998-06-08 00:00\", \"1998-06-10 24:00\" )" );
my @ARGS = (
    $faux_context->{'dbix_conn'},
    $eids_to_delete[0],
    "[ \"1998-06-08 00:00\", \"1998-06-10 24:00\" )",
);
$status = fetch_intervals_by_eid_and_tsrange( @ARGS );
$intervals = $status->payload;
is(scalar @$intervals, 9 );
foreach my $i ( 0..8 ) {
    isa_ok( $intervals->[$i], 'App::Dochazka::REST::Model::Interval' );
    ok( $intervals->[$i]->iid > 0 );
}
like( $intervals->[0]->intvl, qr/^\["1998-06-08 09:55:00...","1998-06-08 10:05:00..."\)$/ );
like( $intervals->[1]->intvl, qr/^\["1998-06-08 10:05:00...","1998-06-08 12:00:00..."\)$/ );



( run in 0.597 second using v1.01-cache-2.11-cpan-7add2cbd662 )