Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

feat(#64) added multiple aggregate levels #66

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
npm-debug.log
coverage
.vscode
9 changes: 9 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit here -- at least as a broad Formidable convention (and same for most of our clients), npm scripts have "won".

Gulp, while a great tool, has persistent problems of plugins being behind the "real" upstream projects and adding complexity / abstraction where it's not needed. Here, we just want to execute mocha. I vote we stick with mocha + package.json:scripts until we hit a use case we truly can't support.

Side note -- if we need concurrent execution of things, we've got great tools for that that work with package.json:scripts.

@jasonwilson -- Thoughts on ^^^ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can npm run scripts allow you to debug your spec files? If so, that is great. Otherwise, the only purpose for the gulp is for debugging unit tests and I can keep it out of the main repo.

Although, excluding it would make portability an issue across dev machines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, you can always use mocha directly. Second npm scripts allow extra commands to punch to the command via --. So, for example,

$ npm run test-only -- --grep=foo --ANY_OTHER_MOCHA_CLI_FLAG

works just fine.

Also, we write our npm package scripts to be the portable subset of shell commands that is universally (mac, win, linux) compatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By dev machine, I really meant for those folks that might use VS code as their debugger, these tagalong files are helpful to include

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with VS code's debugging, but I'd be surprised if generic gulp was supported and raw mocha wasn't. In any case, let's keep the main repo gulp-free to save on dependencies we don't strictly need 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Also sounds like I might have another interested party in learning debugging and using VS code?

I think you'll find it to be a really amazing editor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is an Electron app, it is built on Node too, so this editor is perfectly adapted to Node development.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, since you're not using VS code, what editor are you using?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I have the solution I was looking for to remove the gulp and still get the debug ability.

https://gist.github.com/paambaati/54d33e409b4f7cf059cc

Up to date even!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use many, currently vs code. What I meant is that I don't use the integrated debugger -- typically when I need a debugger I just do the normal node flags and open up chrome.

Nice to see you found what you need and your preferred debugging solution is still available to you!


var gulp = require("gulp");
var mocha = require("gulp-mocha");

gulp.task("test-debug", function () {
gulp.src(["test/**/*.spec.js"])
.pipe(mocha());
});
52 changes: 52 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use strict";

// these define the time levels that data will be aggregated into
// each number is in milliseconds

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Do the empty newline // too, so that it reads as a contiguous "comment"

// since these are used as object keys, they are strings

// For example, 5000 = 5s and means that one of the aggregate levels
// will be at 5s increments of time

// 300000 = 30s and the corresponding zoom will show 30s aggregates
var AGGREGATE_TIME_LEVELS = [
"5000",
"10000",
"15000",
"30000",
"60000",
"300000",
"600000",
"900000",
"1800000",
"3600000"
];

// this array object is used to reduce ms to its highest human-readable form
// see lib/providers/metrics-provider.js::getTimeIndexLabel
var TIME_SCALES = [
{
units: "ms",
divisor: 1
}, {
units: "s",
divisor: 1000
}, {
units: "m",
divisor: 60
}, {
units: "h",
divisor: 60
}, {
units: "d",
divisor: 24
}, {
units: "y",
divisor: 365.24
}
];

module.exports = {
AGGREGATE_TIME_LEVELS: AGGREGATE_TIME_LEVELS,
TIME_SCALES: TIME_SCALES
};
10 changes: 8 additions & 2 deletions lib/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ Dashboard.prototype._configureKeys = function () {
this.screen.key(["q", "C-c"], function () {
process.exit(0); // eslint-disable-line no-process-exit
});

this.screen.key(["up", "down"], _.throttle(function (ch, key) {
var zoom = key.name === "down" ? -1 : 1;
this.screen.emit("zoomGraphs", zoom);
this._showLayout(this.currentLayout, true);
}.bind(this), THROTTLE_TIMEOUT));
};

Dashboard.prototype.onEvent = function (event) {
Expand All @@ -94,8 +100,8 @@ var VIEW_MAP = {
eventLoop: EventLoopView
};

Dashboard.prototype._showLayout = function (id) {
if (this.currentLayout === id) {
Dashboard.prototype._showLayout = function (id, forced) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there another way to update the aggregate view without having to force a layout refresh?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure there is. I will work on it!

if (this.currentLayout === id && !forced) {
return;
}
_.each(this.views, function (view) {
Expand Down
Loading