# Managing activities in Narval

This document specifies how to delegate the reporting of activities to Narval

## Overview

### Three commands are available...

activity-notify
  notify daily activity
activity-flush
  reset the current report of activity
activity-report
  print the current report of activity

### A few words about testing

This document includes acceptance tests written under pyact format, ie HTML tables. They will test the right behaviour of a narval object created by the following table

exec:narval.tools.accrun.run
args | var:
string | string
Activity.notify.xml | notify_memory
Activity.flush.xml | flush_memory
Activity.report.xml | report_memory

`narval.tools.accrun.run` calls `narval.tools.tcrun.run` to run a narval on the argument. Then it gets the memory back from the result. The memory is wrapped into an object by which we will be able to define simple assertions.

## Notify daily activity

This command is used to enter a daily ratio for an activity. An email is sent when the sum of ratios of all activities reaches 1. Notification can use positive or negative ratio, the agent will increment or decrement the existing value (if existing). If the total ratio goes under 0, the activity is deleted.

### Syntax

        ([+-]?\d/\d)\s+(.+)$
        ([+-]?\d([.,]\d\d?)?|[+-]?[.,]\d\d?)\s+(.+)$

### Example

`1/2 narval`
  assigns half of the working load of the day on the narval project
`+0.2 redaction`
  assign 20% of the working load to an activity called `redaction`
`-0.1 narval`
  decrement load on narval by 10%
`.4 meeting`
  Fill daily load with 40% of the time spent in a reunion

### Watch out

An email is sent as soon as the sum of all activities comes up to 1. All the same, activities may still be notified and will generate other notification mails as long as the sum remains over 1

### Restriction

Restrictions weight on the ratio exclusively, meaning the user is free to use any name for his activity.

- ratio must be parseable into a float (or an integer)
- -1 <= ratio <= 1

### Test

act_upon:var:notify_memory
exec:in | check:out
string | string
1/2 narval | you have only specified 0.50 of your daily activity, please complete (now or latter today)
+0.2 redaction | you have only specified 0.70 of your daily activity, please complete (now or latter today)
-0.1 narval | you have only specified 0.60 of your daily activity, please complete (now or latter today)
.4 meeting | your daily activity report has been sent to emb
-.2 redaction | activity deleted (ratio 0.00)
.2 narval | your daily activity report has been sent to emb
2.3 narval | ratio 2.30 out of range (-1 <= ratio <= 1)
-2 narval | ratio -2.00 out of range (-1 <= ratio <= 1)

## Reset activity report

Reset the current report of activity

### Syntax

        RESET CURRENT ACTIVITY( REPORT)?
        (DELETE)|(FLUSH)( ALL)? ACTIVITIES
        FLUSH

### Example

`flush`
  delete all daily activities entered so far
`reset current activity report`
`delete all activities`
  same behavior. They are aliases

### Watch out

The effect is this command is not reversible. All activities entered for this day will be removed

### Test

match:var:flush_memory.get_elmts
type | select:content | check:response
string | string | string
message | .5 narval | you have only specified 0.50 of your daily activity, please complete (now or latter today)
| flush | Activity report reset
| .2 redaction | you have only specified 0.20 of your daily activity, please complete (now or latter today)
| .4 meeting | you have only specified 0.60 of your daily activity, please complete (now or latter today)
| delete all activities | Activity report reset
| reset current activity report | Activity report reset
| .1 narval | you have only specified 0.10 of your daily activity, please complete (now or latter today)

## Print activity report

print the current report of activity

### Syntax

        WHAT ARE MY ACTIVITIES( SO FAR)?\?
        PRINT MY ACTIVITY REPORT
        ACTIVITIES

### Example

`activities`
  print the current report of activity for the current day
`print my activity report`
`what are my activities`
  same behavior. They are aliases

### Test

in | out