Skip to content

Commit 26bbe63

Browse files
committed
refactor(methodSummary): rename responses to results and nest under value along with time.
1 parent b8aab6c commit 26bbe63

File tree

9 files changed

+181
-111
lines changed

9 files changed

+181
-111
lines changed

src/router/call.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ module.exports = function routerCall(callPath, args,
2828
callPath: callPath,
2929
args: args,
3030
refPaths: refPathsArg,
31-
thisPaths: thisPathsArg
31+
thisPaths: thisPathsArg,
32+
results: [],
33+
routes: []
3234
};
3335
}
3436

@@ -97,8 +99,10 @@ module.exports = function routerCall(callPath, args,
9799
innerSource = innerSource.
98100
do(function (response) {
99101
if (router._methodSummaryHook) {
100-
methodSummary.responses = methodSummary.responses || [];
101-
methodSummary.responses.push(response);
102+
methodSummary.results.push({
103+
time: router._now(),
104+
value: response
105+
});
102106
}
103107
}, function (err) {
104108
if (router._methodSummaryHook) {

src/router/get.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ module.exports = function routerGet(paths) {
2020
var methodSummary;
2121
if (router._methodSummaryHook) {
2222
methodSummary = {
23-
start: router._now()
23+
method: 'get',
24+
pathSets: paths,
25+
start: router._now(),
26+
results: [],
27+
routes: []
2428
};
2529
}
2630

@@ -82,8 +86,10 @@ module.exports = function routerGet(paths) {
8286
result = result.
8387
do(function (response) {
8488
if (router._methodSummaryHook) {
85-
methodSummary.responses = methodSummary.responses || [];
86-
methodSummary.responses.push(response);
89+
methodSummary.results.push({
90+
time: router._now(),
91+
value: response
92+
});
8793
}
8894
}, function (err) {
8995
if (router._methodSummaryHook) {

src/router/set.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ module.exports = function routerSet(jsonGraph) {
3333
methodSummary = {
3434
method: 'set',
3535
jsonGraphEnvelope: jsonGraph,
36-
start: router._now()
36+
start: router._now(),
37+
results: [],
38+
routes: []
3739
};
3840
}
3941

@@ -169,9 +171,10 @@ module.exports = function routerSet(jsonGraph) {
169171
do(
170172
function (response) {
171173
if (router._methodSummaryHook) {
172-
methodSummary.responses =
173-
methodSummary.responses || [];
174-
methodSummary.responses.push(response);
174+
methodSummary.results.push({
175+
time: router._now(),
176+
value: response
177+
});
175178
}
176179
}, function (err) {
177180
if (router._methodSummaryHook) {

src/run/call/runCallAction.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@ function runCallAction(matchAndPath, routerInstance, callPath, args,
4444
var route = {
4545
start: routerInstance._now(),
4646
route: matchAndPath.match.prettyRoute,
47-
pathSet: matchAndPath.path
47+
pathSet: matchAndPath.path,
48+
results: []
4849
};
49-
methodSummary.routes = methodSummary.routes || [];
5050
methodSummary.routes.push(route);
5151

5252
output = output.do(
5353
function (response) {
54-
route.responses = route.responses || [];
55-
route.responses.push(response);
54+
route.results.push({
55+
time: routerInstance._now(),
56+
value: response
57+
});
5658
},
5759
function (err) {
5860
route.error = err;
@@ -218,15 +220,17 @@ function runCallAction(matchAndPath, routerInstance, callPath, args,
218220
var route = {
219221
start: routerInstance._now(),
220222
route: matchAndPath.match.prettyRoute,
221-
pathSet: matchAndPath.path
223+
pathSet: matchAndPath.path,
224+
results: []
222225
};
223-
methodSummary.routes = methodSummary.routes || [];
224226
methodSummary.routes.push(route);
225227

226228
out = out.do(
227229
function (response) {
228-
route.responses = route.responses || [];
229-
route.responses.push(response);
230+
route.results.push({
231+
time: routerInstance._now(),
232+
value: response
233+
});
230234
},
231235
function (err) {
232236
route.error = err;

src/run/get/runGetAction.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ function getAction(routerInstance, matchAndPath, jsongCache, methodSummary) {
2222
var route = {
2323
start: routerInstance._now(),
2424
route: matchAndPath.match.prettyRoute,
25-
pathSet: matchAndPath.path
25+
pathSet: matchAndPath.path,
26+
results: []
2627
};
27-
methodSummary.routes = methodSummary.routes || [];
2828
methodSummary.routes.push(route);
2929
return _out.do(function (response) {
30-
route.responses = route.responses || [];
31-
route.responses.push(response);
30+
route.results.push({
31+
time: routerInstance._now(),
32+
value: response
33+
});
3234
}, function (err) {
3335
route.error = err;
3436
route.end = routerInstance._now();

src/run/set/runSetAction.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ function runSetAction(routerInstance, jsongMessage, matchAndPath,
8282
pathSet: matchAndPath.path,
8383
start: routerInstance._now()
8484
};
85-
methodSummary.routes = methodSummary.routes || [];
8685
methodSummary.routes.push(route);
8786

8887
return _out.do(
8988
function (result) {
9089
route.results = route.results || [];
91-
route.results.push(result);
90+
route.results.push({
91+
time: routerInstance._now(),
92+
value: result
93+
});
9294
},
9395
function (err) {
9496
route.error = err;

test/unit/core/call.spec.js

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('Call', function() {
9595
var expected = {
9696
method: 'call',
9797
start: 0,
98-
end: 7,
98+
end: 10,
9999
callPath: ['genrelist', 10, 'titles', 'push'],
100100
args: ['title100'],
101101
refPaths: [['name']],
@@ -105,35 +105,39 @@ describe('Call', function() {
105105
start: 1,
106106
route: 'genrelist[10].titles.push',
107107
pathSet: ['genrelist', 10, 'titles', 'push'],
108-
responses: [
109-
[
108+
results: [{
109+
time: 2,
110+
value: [
110111
{
111112
path: ['genrelist', 10, 'titles', 100],
112113
value: { $type: 'ref', value: ['titlesById', 54] }
113114
}
114115
]
115-
],
116-
end: 2
116+
}],
117+
end: 3
117118
},
118119
{
119-
start: 3,
120-
end: 4,
120+
start: 4,
121+
end: 5,
121122
route: 'titlesById[{integers:id}].name',
122123
pathSet: ['titlesById', 54, 'name'],
124+
results: [],
123125
error: new Error('Live or die? Too bad! <HONK>')
124126
},
125127
{
126-
start: 5,
127-
end: 6,
128+
start: 6,
129+
end: 8,
128130
route: 'genrelist[10].titles.length',
129131
pathSet: ['genrelist', 10, 'titles', 'length'],
130-
responses: [
131-
[{ path: ['genrelist', 10, 'titles', 'length'], value: 50 }]
132-
]
132+
results: [{
133+
time: 7,
134+
value: [{ path: ['genrelist', 10, 'titles', 'length'], value: 50 }]
135+
}]
133136
}
134137
],
135-
responses: [
136-
{
138+
results: [{
139+
time: 9,
140+
value: {
137141
jsonGraph: {
138142
genrelist: {
139143
'10': {
@@ -157,7 +161,7 @@ describe('Call', function() {
157161
['genrelist', 10, 'titles', 100, 'name']
158162
]
159163
}
160-
]
164+
}]
161165
};
162166

163167
expect(summary).to.deep.equal(expected);
@@ -212,7 +216,7 @@ describe('Call', function() {
212216
var expected = {
213217
method: 'call',
214218
start: 0,
215-
end: 7,
219+
end: 11,
216220
callPath: ['genrelist', 10, 'titles', 'push'],
217221
args: ['title100'],
218222
refPaths: [['name']],
@@ -222,37 +226,41 @@ describe('Call', function() {
222226
start: 1,
223227
route: 'genrelist[10].titles.push',
224228
pathSet: ['genrelist', 10, 'titles', 'push'],
225-
responses: [
226-
[
229+
results: [{
230+
time: 2,
231+
value: [
227232
{
228233
path: ['genrelist', 10, 'titles', 100],
229234
value: { $type: 'ref', value: ['titlesById', 54] }
230235
}
231236
]
232-
],
233-
end: 2
237+
}],
238+
end: 3
234239
},
235240
{
236-
start: 3,
237-
end: 4,
241+
start: 4,
242+
end: 6,
238243
route: 'titlesById[{integers:id}].name',
239244
pathSet: ['titlesById', 54, 'name'],
240-
responses: [
241-
[{ path: ['titlesById', 54, 'name'], value: 'Die Hard'}]
242-
]
245+
results: [{
246+
time: 5,
247+
value: [{ path: ['titlesById', 54, 'name'], value: 'Die Hard'}]
248+
}]
243249
},
244250
{
245-
start: 5,
246-
end: 6,
251+
start: 7,
252+
end: 9,
247253
route: 'genrelist[10].titles.length',
248254
pathSet: ['genrelist', 10, 'titles', 'length'],
249-
responses: [
250-
[{ path: ['genrelist', 10, 'titles', 'length'], value: 50 }]
251-
]
255+
results: [{
256+
time: 8,
257+
value: [{ path: ['genrelist', 10, 'titles', 'length'], value: 50 }]
258+
}]
252259
}
253260
],
254-
responses: [
255-
{
261+
results: [{
262+
time: 10,
263+
value: {
256264
jsonGraph: {
257265
genrelist: {
258266
'10': {
@@ -269,7 +277,7 @@ describe('Call', function() {
269277
['genrelist', 10, 'titles', 100, 'name']
270278
]
271279
}
272-
]
280+
}]
273281
};
274282

275283

0 commit comments

Comments
 (0)