Skip to content

Commit

Permalink
Updated the readme to be more descriptive. Updated the get-report.js …
Browse files Browse the repository at this point in the history
…to be UTC based. Removed get-task-time. Will rebuild later
  • Loading branch information
Soben committed Jun 21, 2019
1 parent fffab1b commit 2293d03
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 87 deletions.
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
# Road Map
# Timeular CLI

## Requirements

You have to have a [Timeular](https://timeular.com) account, using the Timeular app. Their device is optional (but badass)

## Installation

Update your .bashrc or .zshrc to include the following environment variables:

```
export TIMEULAR_API_KEY="XXXXXXXXXX"
export TIMEULAR_API_SECRET="YYYYYYYYYY"
```

You can get the values for these fields by visiting your [Account page](https://profile.timeular.com/#/app/account) on Timeular

### via NPM

```
$ npm install -g timeular-cli
```

### via Yarn

```
$ yarn global add timeular-cli
```

## How to Use

### Time Report

Generates a report based on the current date, filtered by your Mentions (`@`)

```
$ timeular report
```

This will not show any time entries that have not been flagged by an `@` mention. For my purposes, this is useful, because I only need to clock time that I have flagged to Jira issues.

Example output:

```
┌───────────┬────────────────────┐
│ (index) │ Values │
├───────────┼────────────────────┤
│ AAA-166 │ 0.07 │
│ AAA-196 │ 0.6799999999999999 │
│ BBB-1 │ 0.11 │
│ INTERNAL │ 0.15 │
│ INTERNAL │ 1.2999999999999998 │
└───────────┴────────────────────┘
Total Hours: 2.3099999999999999
```

## Road Map

- Set up the reporting so you can specify a date range rather than only be "today"
- Get specific Activity or Mentions
- Move console.log into its own library, with colors and fancy displays depending on status
- Everything that the API currently does(?)

## Contributors

Chris Lagasse <[email protected]>, developer at Happy Cog
2 changes: 1 addition & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ program
program
.command("*")
.description("Get total time spent for Timeular mention (Jira Issue)")
.action(getTaskTotal);
.action(getReport);

program.parse(process.argv);
35 changes: 27 additions & 8 deletions src/commands/get-report.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
const moment = require("moment");
const timeular = require("../timeular"); // @TODO change this to just 'timeular'

let mentions = [];
let mentions = null;

const getDate = () => {
const timeStart = moment().format("YYYY-MM-DDT00:00:00.000");
const timeEnd = moment().format("YYYY-MM-DDT23:59:59.999");
const utcOffset = moment().utcOffset(); // Gets your system's timezone.

// Gets UTC times, adjusted by the offset.
const timeStart = moment()
.hours(0)
.minutes(0)
.seconds(0)
.milliseconds(0)
.utc()
.utcOffset(utcOffset, true);
const timeEnd = moment()
.hours(23)
.minutes(59)
.seconds(59)
.milliseconds(999)
.utc()
.utcOffset(utcOffset, true);

return { timeStart, timeEnd };
};

const getMentions = async () => {
if (mentions) {
if (!mentions) {
const tagsAndMentions = await timeular.api("tags-and-mentions");

if (tagsAndMentions) {
Expand Down Expand Up @@ -54,19 +69,23 @@ module.exports = async () => {
const reportOutput = [];
let grandTotal = 0;
const { timeStart, timeEnd } = getDate();
const entries = await timeular.api(`time-entries/${timeStart}/${timeEnd}`);
const entries = await timeular.api(
`time-entries/${timeStart.format(
"YYYY-MM-DDTHH:mm:ss.SSS"
)}/${timeEnd.format("YYYY-MM-DDTHH:mm:ss.SSS")}`
);

if (entries) {
entries.timeEntries.forEach(entry => {
const timeSpent = getDurationInHours(entry.duration);
const timeSpent = getDurationInHours(entry.duration).toFixed(2);
entry.note.mentions.forEach(mention => {
let mentionDetails = getMentionDetails(mention.key);
if (!reportOutput[mentionDetails.label]) {
reportOutput[mentionDetails.label] = 0;
}

reportOutput[mentionDetails.label] += parseFloat(timeSpent.toFixed(2));
grandTotal += parseFloat(timeSpent.toFixed(2));
reportOutput[mentionDetails.label] += parseFloat(timeSpent);
grandTotal += parseFloat(timeSpent);
});
});
}
Expand Down
77 changes: 0 additions & 77 deletions src/commands/get-task-time.js

This file was deleted.

0 comments on commit 2293d03

Please sign in to comment.