Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/gtt-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Config = require('./include/file-config');
const Cli = require('./include/cli');
const Time = require('./models/time');
const Tasks = require('./include/tasks');
const mergeRequest = require('./models/mergeRequest');

program
.option('--verbose', 'show verbose output')
Expand All @@ -24,6 +25,14 @@ function toHumanReadable(input) {
return Time.toHumanReadable(Math.ceil(input), config.get('hoursPerDay'), timeFormat);
}

function column(str, n){
if(str.length > n) {
str = str.substr(0, n-1) + "…"
}
return str.padEnd(n);
};


tasks.log()
.then(({frames, times}) => {
Object.keys(frames).sort().forEach(date => {
Expand All @@ -47,9 +56,12 @@ tasks.log()
.sort((a, b) => a.start.isBefore(b.start) ? -1 : 1)
.forEach(frame => {
let toSync = (Math.ceil(frame.duration) - parseInt(_.reduce(frame.notes, (n, m) => (n + m.time), 0))) != 0;
let durationText = toSync ? toHumanReadable(frame.duration).yellow : toHumanReadable(frame.duration);
let issue = frame.resource.new ? `new ${frame.resource.type + ' "' + frame.resource.id.blue}"` : `${(frame.resource.type + ' #' + frame.resource.id).blue}`;
console.log(` ${frame.id} ${frame.start.clone().format('HH:mm').green} to ${frame.stop.clone().format('HH:mm').green}\t${durationText}\t\t${frame.project.magenta}\t\t${issue}\t\t${frame.note!=null?frame.note:''}`)
let durationText = toSync ? toHumanReadable(frame.duration).padEnd(14).yellow : toHumanReadable(frame.duration).padEnd(14);
let issue = frame.resource.new ?
column(`(new ${frame.resource.type + ' "' + frame.resource.id}")`, 70).bgBlue:
`${(frame.resource.type + ' #' + frame.resource.id).padEnd(20).blue}${column(frame.title!=null?frame.title:'', 50)}`;
console.log(` ${frame.id} ${frame.start.clone().format('HH:mm').green} to ${frame.stop.clone().format('HH:mm').green}\t${durationText}`+
`${column(frame.project, 50).magenta}${issue}${frame.note!=null?frame.note:''}`);
});
});
}
Expand Down
1 change: 1 addition & 0 deletions src/include/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class tasks {
this.sync.resources[type][id]
.make(project, id, frame.resource.new)
.then(() => {
frame.title = this.sync.resources[type][id].data.title;
if (callback) callback();
done();
})
Expand Down
11 changes: 11 additions & 0 deletions src/models/baseFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class baseFrame {
this.timezone = config.get('timezone');
this.notes = [];
this._note = note;
this._title = null;
}

static fromJson(config, json) {
Expand All @@ -37,6 +38,7 @@ class baseFrame {
frame.notes = json.notes;
frame.timezone = json.timezone;
frame.modified = json.modified;
frame._title = json.title? json.title: null;
frame.validate();

return frame;
Expand Down Expand Up @@ -71,6 +73,7 @@ class baseFrame {
stop: frame._stop,
timezone: frame.timezone,
modified: frame.modified,
title: frame._title,
note: frame._note,
});
}
Expand All @@ -91,6 +94,14 @@ class baseFrame {
return this.timezone ? this._stop ? moment(this._stop).tz(this.timezone) : false : (this._stop ? moment(this._stop) : false );
}

set title(title) {
this._title = title;
}

get title() {
return this._title;
}

get note() {
return this._note;
}
Expand Down
1 change: 1 addition & 0 deletions src/models/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class frame extends BaseFrame {
stop: this._stop,
timezone: this.timezone,
modified: skipModified ? this.modified : moment(),
title: this._title,
note: this._note
}, null, "\t"));
}
Expand Down
4 changes: 2 additions & 2 deletions src/models/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ class report extends Base {
"project": this.project.data.path_with_namespace,
"after": (cursor===undefined)?'':cursor,
"entryPerPage": 30,
"startTime": this.config.get('from'),
"endTime": this.config.get('to')
"startTime": this.config.get('from').format("Y-M-D"),
"endTime": this.config.get('to').format("Y-M-D")
}
};

Expand Down