Skip to content

Commit ada20c7

Browse files
authored
Merge pull request #3375 from apinf/develop
Release 0.54.0
2 parents e094292 + cc0085b commit ada20c7

File tree

86 files changed

+2522
-1485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2522
-1485
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"meteor/no-session": [
3636
0
3737
],
38+
"no-else-return": "error",
3839
"no-param-reassign": [
3940
"error",
4041
{

.meteor/versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ apinf:[email protected]
2222
2323
2424
25-
25+
2626
2727
2828

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
sudo: false
1+
sudo: required
2+
dist: trusty
3+
group: deprecated-2017Q4
4+
25
language: node_js
36
node_js:
47
- '4'
@@ -7,11 +10,8 @@ addons:
710
apt:
811
sources:
912
- ubuntu-toolchain-r-test
10-
- sourceline: 'deb https://dl.yarnpkg.com/debian/ stable main'
11-
key_url: 'https://dl.yarnpkg.com/debian/pubkey.gpg'
1213
packages:
1314
- g++-4.8
14-
- yarn
1515
chrome: stable
1616

1717
branches:

apinf_packages/about/client/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h3>
3333
Apinf
3434
</dt>
3535
<dd>
36-
0.53.0
36+
0.54.0
3737
</dd>
3838
<dt>
3939
API Umbrella

apinf_packages/analytics/server/methods.js

Lines changed: 58 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import { check } from 'meteor/check';
99

1010
// Collections imports
1111
import AnalyticsData from '/apinf_packages/analytics/collection';
12+
import ProxyBackends from '/apinf_packages/proxy_backends/collection';
1213

1314
// Npm packages imports
1415
import _ from 'lodash';
16+
import moment from 'moment/moment';
1517

1618
// APInf imports
1719
import { calculateTrend } from '/apinf_packages/dashboard/lib/trend_helpers';
@@ -107,22 +109,16 @@ Meteor.methods({
107109

108110
return errors;
109111
},
110-
summaryStatisticNumber (filter) {
112+
summaryStatisticNumber (filter, proxyBackendIds) {
111113
check(filter, Object);
114+
check(proxyBackendIds, Array);
112115

113116
// Create query to $match
114117
const matchQuery = {
115118
date: { $gte: filter.fromDate, $lt: filter.toDate },
119+
proxyBackendId: { $in: proxyBackendIds },
116120
};
117121

118-
if (filter.proxyId) {
119-
// Fetch data for particular Proxy (and several Proxy Backends)
120-
matchQuery.proxyId = filter.proxyId;
121-
} else {
122-
// Fetch data for particular Proxy Backend
123-
matchQuery.proxyBackendId = filter.proxyBackendId;
124-
}
125-
126122
const requestPathsData = {};
127123

128124
AnalyticsData.aggregate(
@@ -142,27 +138,21 @@ Meteor.methods({
142138
sumMedianTime: { $sum: '$medianResponseTime' },
143139
sumUniqueUsers: { $sum: '$uniqueUsers' },
144140
successCallsCount: { $sum: '$successCallsCount' },
145-
redirectCallsCount: { $sum: '$redirectCallsCount' },
146-
failCallsCount: { $sum: '$failCallsCount' },
147141
errorCallsCount: { $sum: '$errorCallsCount' },
148142
},
149143
},
150144
]
151145
).forEach(dataset => {
152-
// Create query
153-
const query = { prefix: dataset._id, date: matchQuery.date, requestNumber: { $ne: 0 } };
146+
// Expend query
147+
matchQuery.prefix = dataset._id;
148+
matchQuery.requestNumber = { $ne: 0 };
154149

155-
if (filter.proxyId) {
156-
query.proxyId = filter.proxyId;
157-
} else {
158-
query.proxyBackendId = filter.proxyBackendId;
159-
}
160-
161-
// Get the number of date when requests were
162-
const existedValuesCount = AnalyticsData.find(query).count();
150+
// Get the number of date when requests were no 0
151+
const existedValuesCount = AnalyticsData.find(matchQuery).count();
163152

164153
// Calculate average (mean) value of Response time and Uniques users during period
165154
requestPathsData[dataset._id] = {
155+
prefix: dataset._id, // Just rename it
166156
medianResponseTime: parseInt(dataset.sumMedianTime / existedValuesCount, 10) || 0,
167157
avgUniqueUsers: parseInt(dataset.sumUniqueUsers / existedValuesCount, 10) || 0,
168158
};
@@ -172,29 +162,6 @@ Meteor.methods({
172162

173163
return requestPathsData;
174164
},
175-
summaryStatisticTrend (filter, currentPeriodResponse) {
176-
check(filter, Object);
177-
check(currentPeriodResponse, Object);
178-
179-
// Get summary statistic data about previous period
180-
const previousPeriodResponse = Meteor.call('summaryStatisticNumber', filter);
181-
182-
const comparisonData = {};
183-
184-
// Compare the current and previous periods data
185-
_.mapKeys(currentPeriodResponse, (dataset, path) => {
186-
const previousPeriodData = previousPeriodResponse[path] || {};
187-
188-
comparisonData[path] = {
189-
compareRequests: calculateTrend(previousPeriodData.requestNumber, dataset.requestNumber),
190-
compareResponse:
191-
calculateTrend(previousPeriodData.medianResponseTime, dataset.medianResponseTime),
192-
compareUsers: calculateTrend(previousPeriodData.avgUniqueUsers, dataset.avgUniqueUsers),
193-
};
194-
});
195-
196-
return comparisonData;
197-
},
198165
statusCodesData (filter) {
199166
check(filter, Object);
200167

@@ -282,4 +249,51 @@ Meteor.methods({
282249

283250
return requestPathsData;
284251
},
252+
totalNumberRequestsAndTrend (filter, proxyBackendIds) {
253+
check(filter, Object);
254+
check(proxyBackendIds, Array);
255+
256+
// Get data for Current period
257+
const currentPeriodResponse =
258+
Meteor.call('summaryStatisticNumber', filter, proxyBackendIds);
259+
260+
// Create date range filter for Previous period
261+
const previousPeriodFilter = {
262+
fromDate: moment(filter.fromDate).subtract(filter.timeframe, 'd').valueOf(),
263+
toDate: filter.fromDate,
264+
};
265+
266+
// Get data for Previous period
267+
const previousPeriodResponse =
268+
Meteor.call('summaryStatisticNumber', previousPeriodFilter, proxyBackendIds);
269+
270+
const response = [];
271+
272+
// Compare the current and previous periods data
273+
_.mapKeys(currentPeriodResponse, (dataset, path) => {
274+
const proxyBackend = ProxyBackends.findOne({
275+
'apiUmbrella.url_matches.frontend_prefix': dataset.prefix,
276+
});
277+
278+
if (proxyBackend) {
279+
dataset.proxyBackendId = proxyBackend._id;
280+
dataset.apiName = proxyBackend.apiName();
281+
dataset.apiSlug = proxyBackend.apiSlug();
282+
dataset.apiId = proxyBackend.apiId;
283+
}
284+
285+
// Create a comparison data
286+
const previousPeriodData = previousPeriodResponse[path] || {};
287+
dataset.compareRequests =
288+
calculateTrend(previousPeriodData.requestNumber, dataset.requestNumber);
289+
dataset.compareResponse =
290+
calculateTrend(previousPeriodData.medianResponseTime, dataset.medianResponseTime);
291+
dataset.compareUsers =
292+
calculateTrend(previousPeriodData.avgUniqueUsers, dataset.avgUniqueUsers);
293+
294+
response.push(dataset);
295+
});
296+
297+
return response;
298+
},
285299
});

apinf_packages/api_docs/client/code_generator/autoform.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ AutoForm.addHooks('downloadSDK', {
4949
const message = TAPi18n.__('sdkCodeGeneratorModal_errorTextInvalidHost');
5050

5151
// Alert user of error
52-
sAlert.error(message);
52+
sAlert.error(message, { timeout: 'none' });
5353

5454
form.done(new Error(message));
5555
} else if (error) {
5656
// Alert user of error
57-
sAlert.error(error.message);
57+
sAlert.error(error.message, { timeout: 'none' });
5858

5959
form.done(new Error(error.message));
6060
} else if (result.statusCode === 200) {
@@ -73,7 +73,7 @@ AutoForm.addHooks('downloadSDK', {
7373
const message = TAPi18n.__('sdkCodeGeneratorModal_errorText');
7474

7575
// Alert user of error
76-
sAlert.error(message);
76+
sAlert.error(message, { timeout: 'none' });
7777

7878
form.done(new Error(message));
7979
}

apinf_packages/api_docs/client/manage/manage.html

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ <h1 class="modal-title">
5858
type="select-checkbox-inline"
5959
noselect=false
6060
}}
61-
{{# if apiDocumentationEditorIsEnabled }}
62-
<legend>
63-
{{> showHelp 'documentation_editor_create_file' }}
64-
{{_ "manageApiDocumentationModal_CreateDocumentation_Title" }}
65-
</legend>
66-
<a id="open-api-editor" class="btn btn-primary" href="/documentation/editor">
67-
{{_ "manageApiDocumentationModal_openDocumentationEditor" }}
68-
</a>
69-
{{/ if }}
7061
<legend>
7162
{{> showHelp 'documentation_link' }}
7263
{{_ "manageApiDocumentationModal_DocumentationLinks_Title" }}
@@ -92,20 +83,20 @@ <h1 class="modal-title">
9283
</small>
9384
</fieldset>
9485
</div>
95-
{{# each url in otherUrls }}
9686
<div id="otherUrl-link" class="otherUrl-link">
9787
<ul class="list-group">
98-
<li class="list-group-item">
99-
<a href="{{ url }}" id="other-url-@index" target="_blank">
100-
{{ url }}
101-
</a>
102-
<span class="pull-right bg-red">
103-
<i class="fa fa-times cursor delete-link" id="{{ @index }}"></i>
104-
</span>
105-
</li>
88+
{{# each url in otherUrls }}
89+
<li class="list-group-item">
90+
<a href="{{ url }}" id="other-url-@index" target="_blank">
91+
{{ url }}
92+
</a>
93+
<span class="pull-right btn-danger btn-xs">
94+
<i class="fa fa-trash-o fa-lg cursor delete-link" id="{{ @index }}"></i>
95+
</span>
96+
</li>
97+
{{/ each }}
10698
</ul>
10799
</div>
108-
{{/ each }}
109100
<button type="submit" class="btn btn-success" id="save-documentation-link">
110101
{{_ "manageApiDocumentationModal_CreateDocumentation_SaveButton" }}
111102
</button>

apinf_packages/api_docs/client/manage/manage.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@ import _ from 'lodash';
2020
// Collection imports
2121
import ApiDocs from '/apinf_packages/api_docs/collection';
2222
import DocumentationFiles from '/apinf_packages/api_docs/files/collection';
23-
import Settings from '/apinf_packages/settings/collection';
2423

2524
Template.manageApiDocumentationModal.onCreated(function () {
2625
const instance = this;
2726

2827
// Turn off spinner if it was on
2928
Session.set('fileUploading', false);
3029

31-
// Subscribe to documentation editor settings
32-
instance.subscribe('singleSetting', 'apiDocumentationEditor');
33-
3430
instance.removeDocumentationFile = (fileId) => {
3531
// Convert to Mongo ObjectID
3632
const objectId = new Mongo.Collection.ObjectID(fileId);
@@ -87,22 +83,6 @@ Template.manageApiDocumentationModal.helpers({
8783
// Otherwise return false
8884
return false;
8985
},
90-
apiDocumentationEditorIsEnabled () {
91-
// Get settings
92-
const settings = Settings.findOne();
93-
94-
// Check settings exists, editor is enabled and host setting exists
95-
if (
96-
settings &&
97-
settings.apiDocumentationEditor &&
98-
settings.apiDocumentationEditor.enabled &&
99-
settings.apiDocumentationEditor.host) {
100-
// Editor is enabled and has host setting, return true
101-
return true;
102-
}
103-
// Otherwise return false
104-
return false;
105-
},
10686
apiDocsCollection () {
10787
// Return a reference to ApiDocs collection, for AutoForm
10888
return ApiDocs;

apinf_packages/api_docs/client/swagger_ui/swagger_ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Template.swaggerUi.onCreated(() => {
2525
// Parsed swagger file
2626
Meteor.call('parsedSwaggerDocument', documentationURL, (error, result) => {
2727
if (error) {
28-
sAlert.error(error);
28+
sAlert.error(error, { timeout: 'none' });
2929
// Document is invalid
3030
instance.documentationValid = false;
3131
} else {

apinf_packages/api_docs/client/view/resumable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Meteor.startup(() => {
5555
const message = TAPi18n.__('manageApiDocumentationModal_FileType_Message');
5656

5757
// Alert user of error
58-
sAlert.error(message);
58+
sAlert.error(message, { timeout: 'none' });
5959
}
6060
} else {
6161
// Finish uploading

0 commit comments

Comments
 (0)