Skip to content

Commit

Permalink
Merge pull request #3375 from apinf/develop
Browse files Browse the repository at this point in the history
Release 0.54.0
  • Loading branch information
marla-singer committed Feb 1, 2018
2 parents e094292 + cc0085b commit ada20c7
Show file tree
Hide file tree
Showing 86 changed files with 2,522 additions and 1,485 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"meteor/no-session": [
0
],
"no-else-return": "error",
"no-param-reassign": [
"error",
{
Expand Down
2 changes: 1 addition & 1 deletion .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ apinf:api-umbrella@1.4.1
apinf:autoform-bs-datepicker@1.1.2
apinf:create-role-if-undefined@0.1.1
apinf:first-admin@0.1.2
apinf:fiware@0.1.1
apinf:fiware@0.1.3
apinf:restivus-swagger@0.4.0
aramk:quill@0.1.1
arillo:flow-router-helpers@0.5.2
Expand Down
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sudo: false
sudo: required
dist: trusty
group: deprecated-2017Q4

language: node_js
node_js:
- '4'
Expand All @@ -7,11 +10,8 @@ addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://dl.yarnpkg.com/debian/ stable main'
key_url: 'https://dl.yarnpkg.com/debian/pubkey.gpg'
packages:
- g++-4.8
- yarn
chrome: stable

branches:
Expand Down
2 changes: 1 addition & 1 deletion apinf_packages/about/client/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h3>
Apinf
</dt>
<dd>
0.53.0
0.54.0
</dd>
<dt>
API Umbrella
Expand Down
102 changes: 58 additions & 44 deletions apinf_packages/analytics/server/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { check } from 'meteor/check';

// Collections imports
import AnalyticsData from '/apinf_packages/analytics/collection';
import ProxyBackends from '/apinf_packages/proxy_backends/collection';

// Npm packages imports
import _ from 'lodash';
import moment from 'moment/moment';

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

return errors;
},
summaryStatisticNumber (filter) {
summaryStatisticNumber (filter, proxyBackendIds) {
check(filter, Object);
check(proxyBackendIds, Array);

// Create query to $match
const matchQuery = {
date: { $gte: filter.fromDate, $lt: filter.toDate },
proxyBackendId: { $in: proxyBackendIds },
};

if (filter.proxyId) {
// Fetch data for particular Proxy (and several Proxy Backends)
matchQuery.proxyId = filter.proxyId;
} else {
// Fetch data for particular Proxy Backend
matchQuery.proxyBackendId = filter.proxyBackendId;
}

const requestPathsData = {};

AnalyticsData.aggregate(
Expand All @@ -142,27 +138,21 @@ Meteor.methods({
sumMedianTime: { $sum: '$medianResponseTime' },
sumUniqueUsers: { $sum: '$uniqueUsers' },
successCallsCount: { $sum: '$successCallsCount' },
redirectCallsCount: { $sum: '$redirectCallsCount' },
failCallsCount: { $sum: '$failCallsCount' },
errorCallsCount: { $sum: '$errorCallsCount' },
},
},
]
).forEach(dataset => {
// Create query
const query = { prefix: dataset._id, date: matchQuery.date, requestNumber: { $ne: 0 } };
// Expend query
matchQuery.prefix = dataset._id;
matchQuery.requestNumber = { $ne: 0 };

if (filter.proxyId) {
query.proxyId = filter.proxyId;
} else {
query.proxyBackendId = filter.proxyBackendId;
}

// Get the number of date when requests were
const existedValuesCount = AnalyticsData.find(query).count();
// Get the number of date when requests were no 0
const existedValuesCount = AnalyticsData.find(matchQuery).count();

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

return requestPathsData;
},
summaryStatisticTrend (filter, currentPeriodResponse) {
check(filter, Object);
check(currentPeriodResponse, Object);

// Get summary statistic data about previous period
const previousPeriodResponse = Meteor.call('summaryStatisticNumber', filter);

const comparisonData = {};

// Compare the current and previous periods data
_.mapKeys(currentPeriodResponse, (dataset, path) => {
const previousPeriodData = previousPeriodResponse[path] || {};

comparisonData[path] = {
compareRequests: calculateTrend(previousPeriodData.requestNumber, dataset.requestNumber),
compareResponse:
calculateTrend(previousPeriodData.medianResponseTime, dataset.medianResponseTime),
compareUsers: calculateTrend(previousPeriodData.avgUniqueUsers, dataset.avgUniqueUsers),
};
});

return comparisonData;
},
statusCodesData (filter) {
check(filter, Object);

Expand Down Expand Up @@ -282,4 +249,51 @@ Meteor.methods({

return requestPathsData;
},
totalNumberRequestsAndTrend (filter, proxyBackendIds) {
check(filter, Object);
check(proxyBackendIds, Array);

// Get data for Current period
const currentPeriodResponse =
Meteor.call('summaryStatisticNumber', filter, proxyBackendIds);

// Create date range filter for Previous period
const previousPeriodFilter = {
fromDate: moment(filter.fromDate).subtract(filter.timeframe, 'd').valueOf(),
toDate: filter.fromDate,
};

// Get data for Previous period
const previousPeriodResponse =
Meteor.call('summaryStatisticNumber', previousPeriodFilter, proxyBackendIds);

const response = [];

// Compare the current and previous periods data
_.mapKeys(currentPeriodResponse, (dataset, path) => {
const proxyBackend = ProxyBackends.findOne({
'apiUmbrella.url_matches.frontend_prefix': dataset.prefix,
});

if (proxyBackend) {
dataset.proxyBackendId = proxyBackend._id;
dataset.apiName = proxyBackend.apiName();
dataset.apiSlug = proxyBackend.apiSlug();
dataset.apiId = proxyBackend.apiId;
}

// Create a comparison data
const previousPeriodData = previousPeriodResponse[path] || {};
dataset.compareRequests =
calculateTrend(previousPeriodData.requestNumber, dataset.requestNumber);
dataset.compareResponse =
calculateTrend(previousPeriodData.medianResponseTime, dataset.medianResponseTime);
dataset.compareUsers =
calculateTrend(previousPeriodData.avgUniqueUsers, dataset.avgUniqueUsers);

response.push(dataset);
});

return response;
},
});
6 changes: 3 additions & 3 deletions apinf_packages/api_docs/client/code_generator/autoform.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ AutoForm.addHooks('downloadSDK', {
const message = TAPi18n.__('sdkCodeGeneratorModal_errorTextInvalidHost');

// Alert user of error
sAlert.error(message);
sAlert.error(message, { timeout: 'none' });

form.done(new Error(message));
} else if (error) {
// Alert user of error
sAlert.error(error.message);
sAlert.error(error.message, { timeout: 'none' });

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

// Alert user of error
sAlert.error(message);
sAlert.error(message, { timeout: 'none' });

form.done(new Error(message));
}
Expand Down
29 changes: 10 additions & 19 deletions apinf_packages/api_docs/client/manage/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ <h1 class="modal-title">
type="select-checkbox-inline"
noselect=false
}}
{{# if apiDocumentationEditorIsEnabled }}
<legend>
{{> showHelp 'documentation_editor_create_file' }}
{{_ "manageApiDocumentationModal_CreateDocumentation_Title" }}
</legend>
<a id="open-api-editor" class="btn btn-primary" href="/documentation/editor">
{{_ "manageApiDocumentationModal_openDocumentationEditor" }}
</a>
{{/ if }}
<legend>
{{> showHelp 'documentation_link' }}
{{_ "manageApiDocumentationModal_DocumentationLinks_Title" }}
Expand All @@ -92,20 +83,20 @@ <h1 class="modal-title">
</small>
</fieldset>
</div>
{{# each url in otherUrls }}
<div id="otherUrl-link" class="otherUrl-link">
<ul class="list-group">
<li class="list-group-item">
<a href="{{ url }}" id="other-url-@index" target="_blank">
{{ url }}
</a>
<span class="pull-right bg-red">
<i class="fa fa-times cursor delete-link" id="{{ @index }}"></i>
</span>
</li>
{{# each url in otherUrls }}
<li class="list-group-item">
<a href="{{ url }}" id="other-url-@index" target="_blank">
{{ url }}
</a>
<span class="pull-right btn-danger btn-xs">
<i class="fa fa-trash-o fa-lg cursor delete-link" id="{{ @index }}"></i>
</span>
</li>
{{/ each }}
</ul>
</div>
{{/ each }}
<button type="submit" class="btn btn-success" id="save-documentation-link">
{{_ "manageApiDocumentationModal_CreateDocumentation_SaveButton" }}
</button>
Expand Down
20 changes: 0 additions & 20 deletions apinf_packages/api_docs/client/manage/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@ import _ from 'lodash';
// Collection imports
import ApiDocs from '/apinf_packages/api_docs/collection';
import DocumentationFiles from '/apinf_packages/api_docs/files/collection';
import Settings from '/apinf_packages/settings/collection';

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

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

// Subscribe to documentation editor settings
instance.subscribe('singleSetting', 'apiDocumentationEditor');

instance.removeDocumentationFile = (fileId) => {
// Convert to Mongo ObjectID
const objectId = new Mongo.Collection.ObjectID(fileId);
Expand Down Expand Up @@ -87,22 +83,6 @@ Template.manageApiDocumentationModal.helpers({
// Otherwise return false
return false;
},
apiDocumentationEditorIsEnabled () {
// Get settings
const settings = Settings.findOne();

// Check settings exists, editor is enabled and host setting exists
if (
settings &&
settings.apiDocumentationEditor &&
settings.apiDocumentationEditor.enabled &&
settings.apiDocumentationEditor.host) {
// Editor is enabled and has host setting, return true
return true;
}
// Otherwise return false
return false;
},
apiDocsCollection () {
// Return a reference to ApiDocs collection, for AutoForm
return ApiDocs;
Expand Down
2 changes: 1 addition & 1 deletion apinf_packages/api_docs/client/swagger_ui/swagger_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Template.swaggerUi.onCreated(() => {
// Parsed swagger file
Meteor.call('parsedSwaggerDocument', documentationURL, (error, result) => {
if (error) {
sAlert.error(error);
sAlert.error(error, { timeout: 'none' });
// Document is invalid
instance.documentationValid = false;
} else {
Expand Down
2 changes: 1 addition & 1 deletion apinf_packages/api_docs/client/view/resumable.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Meteor.startup(() => {
const message = TAPi18n.__('manageApiDocumentationModal_FileType_Message');

// Alert user of error
sAlert.error(message);
sAlert.error(message, { timeout: 'none' });
}
} else {
// Finish uploading
Expand Down

0 comments on commit ada20c7

Please sign in to comment.