Closed tttp closed 8 years ago
Good Morning Xavier,
stn is just the parser and needs to stay that way so I would prefer that we don't added IO to it. I use it with other JavaScript platforms where Node's modular system isn't available. You're welcome to fork (and forks are good thing) and it would be trivial to add the IO assuming your flat file.
That said I wouldn't recommend a plain text flat file. I think you have a couple easy options that will fit nicely in Knockout's time constraints. I've used Felixge's dirty (https://github.com/felixge/node-dirty). It's fast and can handle just under million records. An alternative I've been meaning to try out is Monglo (https://github.com/Monglo/MongloDB) that gives you a database with a MongoDB like filter engine. Both are pure JavaScript without compiled parts so should be friendly on Nodejitsu.
I will try to add some examples to stn using both before the weekend. My understanding is if the module is public and open source and available to Knockout I can build its functionality early without violating the Knockout rules. I'll also make sure I have some decent docs to keep in that spirit.
Below is a sketch of what I imagine you'll want to track in your system -
{
_id: "SOME SORT OF UNIQUE KEY LIKE email": {
email: "john.doe@example.com",
map: {
"prep": {
client_name: "ACME Motor Corp",
project_name: "Invisible Car Project",
task: "planning"
},
"meeting": {
client_name: "ACME Motor Corp",
project_name: "Invisible Car Project",
task: "meeting"
},
"coding": {
client_name: "ACME Motor Corp",
project_name: "Invisible Car Project",
task: "coding"
},
"review": {
client_name: "ACME Motor Corp",
project_name: "Invisible Car Project",
task: "Quality assurance"
}
},
timesheet: { ... }
}
}
stn supports the concept of a map from tags to client/project data. If you configure stn with {map: true, tags: true}. I do this when I import my time log into harvest each week (see example in stn repos harvest-csv.js).
To integrate with services like Harvest you'll need to support OAuth2. I'm not certain you want to keep a DB to manage that. I generally avoid storing secrets so if you can get by without this integrate for Knockout I think you'll save allot of time.
Is xmpp a requirement? Do you already have a working implementation in NodeJS that doesn't require compilation? You'll want to avoid having to compile stuff on Nodejitsu. It's SmartOS based which is cool from a reliable service point of view but often proves to be a pain getting things to compile that were originally at other systems (e.g. Linux). Just a thought.
If you're just going for an IRC like interface then I think you can spin up one of the many NodeJS IRC examples and just feed the times sheets into stn based on the user handles (e.g. #rsdoiel). Then you store the current state of the parse tree.
I see some easy paths for Knockout in terms of creating a timesheet service. They wouldn't require authentication but would let you have a platform for exploring visualization. You could also use them to generate files for import to services like Harvest thus making it useful.
Keeping the architecture simple will let you create a more private authentication based solution later.
Have an IRC service running. Each handle (e.g. #rsdoiel) gets mapped to a timesheet and Map. Create a comment for defining maps of tags, projects clients. Here's an example of someone sending data via an IRC -
.map {"code": {"client_name":"Mr. Lizard", "project_name":"Raspberry Pi robot", "task": "coding"}}
2012-11-05
8:00 - 14:34; code; Prototype robot
If that came from #rsdoiel then you can now run it through an stn object for #rsdoiel and persist the results.
http input is just a matter of handling form posts. You don't really need stn since you could post the individual fields. You could provide a simple timesheet upload though and that would merge the results into the datastore. It would be easier defining the map via a web form then having to hand type out a JSON blob.
You can of course create a hybrid. You could have a single page app that runs browser side. You could persist the data store locally (e.g. use Monglo and AmplifyJS) and then send up snapshots when you have a network connection.
This would give you the best of both worlds - IRC for realtime integration and an http service for defining things like the tag map to clients, projects and tasks.
This is where you're visualization goes. Here's where I think Monglo starts to have an advantage over dirty db. You can setup a reports page (also could be a simple page app) that scans the database and filters by project, timesheet owners, clients, etc. I would recommend a simple RESTful JSON API for getting data out based on the queries requested. Leave all presentation client side in the browser.
You could of course also expose the output via IRC. Using a dot command you could render in simple timesheet notation or JSON.
.report-json # outputs JSON blog of timesheet using toJSON()
...
.report # outputs text version using stn's toString()
...
Anyway, just ideas. I can prototype some of this and include it in the stn repo. It'll give you something to start with since my time will be very limited this weekend.
All the best,
Robert
Hey, very interesting points.
1) not including a file dependency. if you run outside of node, make sense indeed. Looking at the code that started with require("util") I assumed it was node specific
2) IMO the "real backend" is going to be another CRM/invoicing like Harvest or civicrm via REST or uploading csv or whatever. Therefore, we only need to keep a handful of timesheet in the bot, hence the flat file as a minimal solution. https://github.com/felixge/node-dirty dirty querying offer is rather minimal too;)
3) on your map, not sure I get what's the diff between the key and the task. Pretty sure we'll have some kind of id as well for the client/task, not sure how yet.
4) xmpp is not a hard requirement and your idea of having other interfaces (eg IRC) completely make sense. This being said, might be a personal bias but I tend to start my xmpp and be on it longer than on irc, so more opportunities to collect data and interact with the bot
We'll try to separate the communication layer from the command/business logic. Might be worthwhile having a simple socket.io alternate interface for the judges on the knockout too. Might have misread, but amplifyjs doesn't seem to easily allow the server to push things, eg notifications that it's time to clockin a task. This being said, I like very much the hybrid approach of being able to clock time offline and push when you get a connection, best of both world indeed.
X+
Quickly, then I'll write some code. A good valid point about XMPP. If you're already using it, it make perfect sense. I tend to be in text editors and never really got confortable with having a chat client running full-time (probably just my generation of computer user, Unix talk is what people used when I started and it wasn't very convenient on a VT-100 terminal). But I think you make a good point and it fits really nicely in with your general architecture - source(s) of input -> middleware merging <=> CRM/invoicing systems. I really wish we had this at work :-).
I think you're right on the money for Knockout about the flat file. Write a quick and dirty stn extended and put it in the extra's folder (extras/stn-fs.js). Then you could use that instead of raw stn.
all the best,
Robert
On Thu, Nov 8, 2012 at 12:29 AM, xavier dutoit notifications@github.comwrote:
Hey, very interesting points.
1) not including a file dependency. if you run outside of node, make sense indeed. Looking at the code that started with require("util") I assumed it was node specific
2) IMO the "real backend" is going to be another CRM/invoicing like Harvest or civicrm via REST or uploading csv or whatever. Therefore, we only need to keep a handful of timesheet in the bot, hence the flat file as a minimal solution. https://github.com/felixge/node-dirty dirty querying offer is rather minimal too;)
3) on your map, not sure I get what's the diff between the key and the task. Pretty sure we'll have some kind of id as well for the client/task, not sure how yet.
4) xmpp is not a hard requirement and your idea of having other interfaces (eg IRC) completely make sense. This being said, might be a personal bias but I tend to start my xmpp and be on it longer than on irc, so more opportunities to collect data and interact with the bot
We'll try to separate the communication layer from the command/business logic. Might be worthwhile having a simple socket.io alternate interface for the judges on the knockout too. Might have misread, but amplifyjs doesn't seem to easily allow the server to push things, eg notifications that it's time to clockin a task. This being said, I like very much the hybrid approach of being able to clock time offline and push when you get a connection, best of both world indeed.
X+
— Reply to this email directly or view it on GitHubhttps://github.com/rsdoiel/stn/issues/7#issuecomment-10179912.
Hello Again,
I've updated master to include extras/stnfs.js which adds readFile(), readFileSync(), writeFile(), writeFileSync() to basic stn object. I haven't had time today to add the streaming versions. I'll be updating npm registry shortly as version 0.0.8.
Thanks,
Robert
Hi,
Presumably, stn is used from a flat file (will be true in our case), so instead of this
Having a (async reading)
Same for updating the file, instead of
having timesheet.writeFile(fileName); //filename optional if opened with parseFile
Can avoid some boilerplate and enforce good practice (eg. async instead of sync)
What do you think?