Skip to content

Commit 98b3767

Browse files
author
Bogdan Abaev
committed
setting up the alexa skill
1 parent 6667fc6 commit 98b3767

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

.DS_Store

0 Bytes
Binary file not shown.

CLI/CLI.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
const yargs = require('yargs')
22
const request = require('request')
33
const fs = require('fs');
4-
host = "http://localhost:3000";
5-
//host = "http://18.233.168.151:80";
6-
path = "/Users/bogdanabaev/RandomProgramming/node/notes/CLI/"
4+
//host = "http://localhost:3000";
5+
host = "http://18.233.168.151:80";
6+
path = "/Users/bogdanabaev/RandomProgramming/node/notes/CLI/";
77

88

99
// BUG: BREAKS WITH SIGNUP CAUSE THERE IS NO 'TIME' AFTER DATA
1010
//BUG: breaks when send request with nonexisting user name
11+
12+
// lambda - entry point. There construct query, send it to server from there.
1113
const sendQuery = function (query, username, signup) {
1214
if (username) {
1315
request.post({
@@ -212,16 +214,14 @@ yargs.command({
212214
if (err) {
213215
console.log(err);
214216
} else {
215-
console.log(result.body);
216217
const dict = JSON.parse(result.body).data.time.report;
217218
for (var project in dict) {
218-
console.log(project);
219219
console.log("\nProject: " + dict[project]._id);
220220
var minSpent = dict[project].timeSpent;
221221
var hr = parseInt(minSpent / 60);
222222
var min = minSpent % 60;
223223
console.log(`Total time: ${hr}:${min}`);
224-
console.log("Work sessions:\n")
224+
console.log("Work sessions:\n");
225225
dict[project].workSessions.forEach(session => {
226226
console.log(`Start:${session.start.day}/${session.start.month} at ${session.start.time}`);
227227
console.log(session.finish ? `Finish:${session.finish.day}/${session.finish.month} at ${session.finish.time}` : "In progress");
@@ -249,7 +249,6 @@ yargs.command({
249249
if (res) {
250250
fs.writeFileSync(path + '.username.txt', argv.username);
251251
}
252-
253252
}
254253
});
255254

server/server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,6 @@ app.use('/graphql', graphqlHTTP({
142142
graphiql: true,
143143
}));
144144

145+
146+
145147
app.listen(port, () => console.log(`Time tracker listening on port ${port}!`));

server/timeTracker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const assert = require('assert');
33
const mongoUtils = require('./mongoUtils.js');
44
const fs = require('fs');
55

6+
67
const createProject = function (username, title) {
78
return mongoUtils.connectToDb(
89
() => new Promise(function (resolve, reject) {
@@ -231,7 +232,7 @@ const report = function (username, days) {
231232
{'$match': {
232233
$and:[
233234
{ $or: [
234-
{$and: [ {"start.day": { $gt: parseInt(lastWeek)} },{"start.month": { $eq: parseInt(lastMonth)} }] } ,
235+
{$and: [ {"start.day": { $gte: parseInt(lastWeek)} },{"start.month": { $eq: parseInt(lastMonth)} }] } ,
235236
{$and: [ {"start.day": { $lte:parseInt( today)} },{"start.month": { $eq: parseInt(thisMonth)} }] } ,
236237
]},
237238
{"user": { $eq: username} },
@@ -313,4 +314,3 @@ module.exports = {
313314
}
314315

315316

316-

0 commit comments

Comments
 (0)