get-google-fit-bike-rides
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -92,3 +92,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var _numberArrayFuzzyFindIndex = __webpack_require__(6); | ||
var _numberArrayFuzzyFindIndex = __webpack_require__(8); | ||
@@ -101,3 +101,3 @@ var _numberArrayFuzzyFindIndex2 = _interopRequireDefault(_numberArrayFuzzyFindIndex); | ||
var _queryGoogleFitDataSource = __webpack_require__(4); | ||
var _queryGoogleFitDataSource = __webpack_require__(6); | ||
@@ -222,18 +222,48 @@ var _queryGoogleFitDataSource2 = _interopRequireDefault(_queryGoogleFitDataSource); | ||
}); | ||
exports.default = function (path) { | ||
return gapi.client.request({ path: path }).then(function (_ref) { | ||
var point = _ref.result.point; | ||
return point; | ||
}); | ||
}; | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = 100000; | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = queryFitnessDataSource; | ||
var _getNanos = __webpack_require__(5); | ||
var _getNanos = __webpack_require__(7); | ||
var _getNanos2 = _interopRequireDefault(_getNanos); | ||
var _makeGapiRequest = __webpack_require__(4); | ||
var _makeGapiRequest2 = _interopRequireDefault(_makeGapiRequest); | ||
var _maxGapiResults = __webpack_require__(5); | ||
var _maxGapiResults2 = _interopRequireDefault(_maxGapiResults); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function doTheActualQuery(dataSourceId, fromDate, toDate) { | ||
var path = 'fitness/v1/users/me/dataSources/' + dataSourceId + '/datasets/' + (0, _getNanos2.default)(fromDate) + '-' + (0, _getNanos2.default)(toDate); | ||
return gapi.client.request({ path: path }).then(function (_ref) { | ||
var point = _ref.result.point; | ||
return point; | ||
}); | ||
} | ||
function getDateFromNanos(nanos) { | ||
@@ -248,7 +278,5 @@ return new Date(nanos / 1000000); | ||
function queryFitnessDataSource(dataSourceId, fromDate, toDate) { | ||
return doTheActualQuery(dataSourceId, fromDate, toDate).then(function (points) { | ||
if (points.length === 0) { | ||
return []; | ||
} else if (lessThanADayApart(getDateFromNanos(points[0].startTimeNanos), fromDate)) { | ||
var path = 'fitness/v1/users/me/dataSources/' + dataSourceId + '/datasets/' + (0, _getNanos2.default)(fromDate) + '-' + (0, _getNanos2.default)(toDate); | ||
return (0, _makeGapiRequest2.default)(path).then(function (points) { | ||
if (points.length < _maxGapiResults2.default) { | ||
return points; | ||
@@ -267,3 +295,3 @@ } else { | ||
/***/ }), | ||
/* 5 */ | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -283,3 +311,3 @@ | ||
/***/ }), | ||
/* 6 */ | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -286,0 +314,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n=e.sort(),r=n[(0,a.default)(n.map(function(e){return e.startTimeNanos}),t)];return{lat:+r.value[0].fpVal,lng:+r.value[1].fpVal}}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=n(6),a=r(u),s=n(3),f=r(s),l=n(4),c=r(l);t.default=function(e,t){return Promise.all([f.default.activitySegments,f.default.locationSamples].map(function(n){return(0,c.default)(n,e,t)})).then(function(e){var t=i(e,2),n=t[0],r=t[1];if(!n)throw new Error("No activities found in the given range");return n.filter(function(e){return 1===e.value[0].intVal}).map(function(e){var t=new Date(e.startTimeNanos/1e6),n=new Date(e.endTimeNanos/1e6),i=(e.endTimeNanos-e.startTimeNanos)/1e6;return{startTime:t,endTime:n,startLatLang:o(r,e.startTimeNanos),endLatLang:o(r,e.endTimeNanos),durationMs:i}})})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=["https://www.googleapis.com/auth/fitness.activity.read","https://www.googleapis.com/auth/fitness.location.read"].join(" ")},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.googleApiScope=void 0;var o=n(0),i=r(o),u=n(1),a=r(u);window.getGoogleFitBikeRides=i.default,window.getGoogleFitBikeRides.googleApiScope=s,t.default=i.default;var s=t.googleApiScope=a.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={activitySegments:"derived:com.google.activity.segment:com.google.android.gms:merge_activity_segments",locationSamples:"derived:com.google.location.sample:com.google.android.gms:merge_location_samples"}},function(e,t,n){"use strict";function r(e,t,n){var r="fitness/v1/users/me/dataSources/"+e+"/datasets/"+(0,s.default)(t)+"-"+(0,s.default)(n);return gapi.client.request({path:r}).then(function(e){return e.result.point})}function o(e){return new Date(e/1e6)}function i(e,t){return e.getTime()-t.getTime()<864e5}function u(e,t,n){return r(e,t,n).then(function(n){if(0===n.length)return[];if(i(o(n[0].startTimeNanos),t))return n;var r=o(n[0].startTimeNanos),a=new Date(r.getTime()-1);return console.log("Loads of results. Querying again to get points before "+r.toDateString()),u(e,t,a).then(function(e){return e.concat(n)})})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=u;var a=n(5),s=function(e){return e&&e.__esModule?e:{default:e}}(a)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return 1e6*e.getTime()}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return e.reduce(function(n,r,o){return Math.abs(r-t)<Math.abs(e[n]-t)?o:n},0)}}])}); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n=e.sort(),r=n[(0,a.default)(n.map(function(e){return e.startTimeNanos}),t)];return{lat:+r.value[0].fpVal,lng:+r.value[1].fpVal}}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){var n=[],r=!0,o=!1,u=void 0;try{for(var i,a=e[Symbol.iterator]();!(r=(i=a.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,u=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw u}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=n(8),a=r(i),s=n(3),f=r(s),l=n(6),c=r(l);t.default=function(e,t){return Promise.all([f.default.activitySegments,f.default.locationSamples].map(function(n){return(0,c.default)(n,e,t)})).then(function(e){var t=u(e,2),n=t[0],r=t[1];if(!n)throw new Error("No activities found in the given range");return n.filter(function(e){return 1===e.value[0].intVal}).map(function(e){var t=new Date(e.startTimeNanos/1e6),n=new Date(e.endTimeNanos/1e6),u=(e.endTimeNanos-e.startTimeNanos)/1e6;return{startTime:t,endTime:n,startLatLang:o(r,e.startTimeNanos),endLatLang:o(r,e.endTimeNanos),durationMs:u}})})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=["https://www.googleapis.com/auth/fitness.activity.read","https://www.googleapis.com/auth/fitness.location.read"].join(" ")},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.googleApiScope=void 0;var o=n(0),u=r(o),i=n(1),a=r(i);window.getGoogleFitBikeRides=u.default,window.getGoogleFitBikeRides.googleApiScope=s,t.default=u.default;var s=t.googleApiScope=a.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={activitySegments:"derived:com.google.activity.segment:com.google.android.gms:merge_activity_segments",locationSamples:"derived:com.google.location.sample:com.google.android.gms:merge_location_samples"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return gapi.client.request({path:e}).then(function(e){return e.result.point})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=1e5},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){return new Date(e/1e6)}function u(e,t,n){var r="fitness/v1/users/me/dataSources/"+e+"/datasets/"+(0,a.default)(t)+"-"+(0,a.default)(n);return(0,f.default)(r).then(function(n){if(n.length<c.default)return n;var r=o(n[0].startTimeNanos),i=new Date(r.getTime()-1);return console.log("Loads of results. Querying again to get points before "+r.toDateString()),u(e,t,i).then(function(e){return e.concat(n)})})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=u;var i=n(7),a=r(i),s=n(4),f=r(s),l=n(5),c=r(l)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return 1e6*e.getTime()}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return e.reduce(function(n,r,o){return Math.abs(r-t)<Math.abs(e[n]-t)?o:n},0)}}])}); |
{ | ||
"name": "get-google-fit-bike-rides", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Browser JS library to fetch a list of bikerides from Google Fit", | ||
@@ -19,4 +19,5 @@ "main": "dist/get-google-fit-bike-rides.min.js", | ||
"proxyquire": "^1.7.11", | ||
"sinon": "^2.2.0", | ||
"webpack": "^2.3.3" | ||
} | ||
} |
15078
254
10