From aeb9531e69a55eca6661511373402b30fdbb2d1b Mon Sep 17 00:00:00 2001 From: Aleksei Simatov Date: Sun, 21 Jul 2024 18:34:34 +0700 Subject: [PATCH] Feature: Add team requests support (#43) * Feature: Add team requests support * Fix: error in toString --- README.md | 2 +- action.yml | 2 +- build/index.js | 2078 ++++++++++++++++- package-lock.json | 17 +- package.json | 4 +- src/converters/collectData.ts | 37 +- src/converters/utils/prepareDiscussions.ts | 246 +- .../utils/prepareRequestedReviews.ts | 25 +- src/converters/utils/prepareResponseTime.ts | 37 +- src/converters/utils/prepareReviews.ts | 22 +- src/view/utils/createResponseTable.ts | 2 +- 11 files changed, 2236 insertions(+), 236 deletions(-) diff --git a/README.md b/README.md index c306bcb..7416bcb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Pull request analytics action -![Version](https://img.shields.io/badge/version-3.1.0-blue) ![License](https://img.shields.io/badge/license-MIT-green) +![Version](https://img.shields.io/badge/version-3.1.1-blue) ![License](https://img.shields.io/badge/license-MIT-green) **pull-request-analytics-action**: A powerful tool for analyzing the effectiveness of both teams and individual developers. This action generates reports based on data from pull requests, code reviews, and comments, enabling you to identify your team's strengths as well as areas needing improvement. The statistics collected by this GitHub Action can be displayed in the form of tables and graphs or passed on for further operations as markdown or a data collection. diff --git a/action.yml b/action.yml index 776b539..de32464 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,6 @@ name: "Pull Request Analytics" author: "Aleksei Simatov" -description: "Generates detailed PR analytics reports within GitHub, focusing on review efficiency and team performance." +description: "Provides informative reports on team and developer metrics, based on data from pull requests and code reviews" branding: icon: "trending-up" color: "orange" diff --git a/build/index.js b/build/index.js index 7a94940..e4cdc6e 100644 --- a/build/index.js +++ b/build/index.js @@ -769,13 +769,18 @@ exports.validateSingleValue = validateSingleValue; /***/ }), /***/ 18465: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.collectData = void 0; const date_fns_1 = __nccwpck_require__(73314); +const set_1 = __importDefault(__nccwpck_require__(82900)); +const get_1 = __importDefault(__nccwpck_require__(56908)); const utils_1 = __nccwpck_require__(64266); const constants_1 = __nccwpck_require__(95354); const calculations_1 = __nccwpck_require__(16576); @@ -796,16 +801,11 @@ const collectData = (data, teams) => { ? (0, date_fns_1.format)(closedDate, (0, utils_2.getDateFormat)()) : constants_1.invalidDate; const userKey = pullRequest.user?.login || constants_1.invalidUserLogin; - [userKey, ...(teams[userKey] || [])].forEach((key) => { - if (!collection[key]) { - collection[key] = {}; - } - }); (0, utils_1.prepareRequestedReviews)(reviewRequests, collection, dateKey, teams); ["total", userKey, ...(teams[userKey] || [])].forEach((key) => { ["total", dateKey].forEach((innerKey) => { - collection[key][innerKey] = (0, utils_1.preparePullRequestInfo)(pullRequest, collection[key][innerKey]); - collection[key][innerKey] = (0, utils_1.preparePullRequestTimeline)(pullRequest, reviews, reviewRequests?.[0], statuses, collection[key][innerKey]); + (0, set_1.default)(collection, [key, innerKey], (0, utils_1.preparePullRequestInfo)(pullRequest, (0, get_1.default)(collection, [key, innerKey], {}))); + (0, set_1.default)(collection, [key, innerKey], (0, utils_1.preparePullRequestTimeline)(pullRequest, reviews, reviewRequests?.[0], statuses, (0, get_1.default)(collection, [key, innerKey], {}))); }); }); (0, utils_1.prepareReviews)(reviews, collection, dateKey, userKey, (0, calculations_1.getPullRequestSize)(pullRequest?.additions, pullRequest?.deletions), teams); @@ -814,7 +814,7 @@ const collectData = (data, teams) => { }); Object.entries(collection).map(([key, value]) => { Object.entries(value).forEach(([innerKey, innerValue]) => { - collection[key][innerKey] = (0, utils_1.preparePullRequestStats)(innerValue); + (0, set_1.default)(collection, [key, innerKey], (0, utils_1.preparePullRequestStats)(innerValue)); }); }); return collection; @@ -1393,12 +1393,17 @@ exports.prepareConductedReviews = prepareConductedReviews; /***/ }), /***/ 88196: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.prepareDiscussions = void 0; +const set_1 = __importDefault(__nccwpck_require__(82900)); +const get_1 = __importDefault(__nccwpck_require__(56908)); const constants_1 = __nccwpck_require__(95354); const getDiscussionType_1 = __nccwpck_require__(49575); const prepareDiscussions = (comments, collection, index, dateKey, pullRequestLogin, teams) => { @@ -1410,117 +1415,137 @@ const prepareDiscussions = (comments, collection, index, dateKey, pullRequestLog ["total", dateKey].forEach((key) => { discussions?.forEach((discussion) => { const userLogin = discussion.user?.login || constants_1.invalidUserLogin; - [ - userLogin, - pullRequestLogin, - "total", - ...(teams[userLogin] || []), - ...(teams[pullRequestLogin] || []), - ].forEach((checkingKey) => { - if (collection[checkingKey][key].discussionsTypes === undefined) { - collection[checkingKey][key].discussionsTypes = {}; - } - }); (0, getDiscussionType_1.getDiscussionType)(discussion.body).forEach((type) => { [userLogin, ...(teams[userLogin] || [])].forEach((userKey) => { - collection[userKey][key].discussionsTypes[type] = { - ...(collection[userKey][key].discussionsTypes[type] || {}), + (0, set_1.default)(collection, [userKey, key, "discussionsTypes", type], { + ...(0, get_1.default)(collection, [userKey, key, "discussionsTypes", type], {}), conducted: { - total: (collection[userKey][key].discussionsTypes[type]?.conducted - ?.total || 0) + 1, - agreed: (collection[userKey][key].discussionsTypes[type]?.conducted - ?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0), - disagreed: (collection[userKey][key].discussionsTypes[type]?.conducted - ?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0), + total: (0, get_1.default)(collection, [ + userKey, + key, + "discussionsTypes", + type, + "conducted", + "total", + ], 0) + 1, + agreed: (0, get_1.default)(collection, [ + userKey, + key, + "discussionsTypes", + type, + "conducted", + "agreed", + ], 0) + (discussion.reactions?.["+1"] ? 1 : 0), + disagreed: (0, get_1.default)(collection, [ + userKey, + key, + "discussionsTypes", + type, + "conducted", + "disagreed", + ], 0) + (discussion.reactions?.["-1"] ? 1 : 0), }, - }; + }); }); [pullRequestLogin, ...(teams[pullRequestLogin] || [])].forEach((userKey) => { - collection[userKey][key].discussionsTypes[type] = { - ...(collection[userKey][key].discussionsTypes[type] || {}), + (0, set_1.default)(collection, [userKey, key, "discussionsTypes", type], { + ...(0, get_1.default)(collection, [userKey, key, "discussionsTypes", type], {}), received: { - total: (collection[userKey][key].discussionsTypes[type]?.received - ?.total || 0) + 1, - agreed: (collection[userKey][key].discussionsTypes[type]?.received - ?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0), - disagreed: (collection[userKey][key].discussionsTypes[type]?.received - ?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0), + total: (0, get_1.default)(collection, [ + userKey, + key, + "discussionsTypes", + type, + "received", + "total", + ], 0) + 1, + agreed: (0, get_1.default)(collection, [ + userKey, + key, + "discussionsTypes", + type, + "received", + "agreed", + ], 0) + (discussion.reactions?.["+1"] ? 1 : 0), + disagreed: (0, get_1.default)(collection, [ + userKey, + key, + "discussionsTypes", + type, + "received", + "disagreed", + ], 0) + (discussion.reactions?.["-1"] ? 1 : 0), }, - }; + }); }); - collection.total[key].discussionsTypes[type] = { - ...(collection.total[key].discussionsTypes[type] || {}), + (0, set_1.default)(collection, ["total", key, "discussionsTypes", type], { + ...(0, get_1.default)(collection, ["total", key, "discussionsTypes", type], {}), conducted: { - total: (collection.total[key].discussionsTypes[type]?.conducted - ?.total || 0) + 1, - agreed: (collection.total[key].discussionsTypes[type]?.conducted - ?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0), - disagreed: (collection.total[key].discussionsTypes[type]?.conducted - ?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0), + total: (0, get_1.default)(collection, ["total", key, "discussionsTypes", type, "conducted", "total"], 0) + 1, + agreed: (0, get_1.default)(collection, ["total", key, "discussionsTypes", type, "conducted", "agreed"], 0) + (discussion.reactions?.["+1"] ? 1 : 0), + disagreed: (0, get_1.default)(collection, [ + "total", + key, + "discussionsTypes", + type, + "conducted", + "disagreed", + ], 0) + (discussion.reactions?.["-1"] ? 1 : 0), }, received: { - total: (collection.total[key].discussionsTypes[type]?.received?.total || - 0) + 1, - agreed: (collection.total[key].discussionsTypes[type]?.received - ?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0), - disagreed: (collection.total[key].discussionsTypes[type]?.received - ?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0), + total: (0, get_1.default)(collection, ["total", key, "discussionsTypes", type, "received", "total"], 0) + 1, + agreed: (0, get_1.default)(collection, ["total", key, "discussionsTypes", type, "received", "agreed"], 0) + (discussion.reactions?.["+1"] ? 1 : 0), + disagreed: (0, get_1.default)(collection, [ + "total", + key, + "discussionsTypes", + type, + "received", + "disagreed", + ], 0) + (discussion.reactions?.["-1"] ? 1 : 0), }, - }; + }); }); }); comments[index]?.forEach((comment) => { const userLogin = comment.user?.login || constants_1.invalidUserLogin; if (pullRequestLogin !== userLogin) { - if (!collection[userLogin]) { - collection[userLogin] = {}; - } - if (!collection[userLogin][key]) { - collection[userLogin][key] = {}; - } [userLogin, "total", ...(teams[userLogin] || [])].forEach((userKey) => { - collection[userKey][key].commentsConducted = - (collection[userKey][key].commentsConducted || 0) + 1; + (0, set_1.default)(collection, [userKey, key, "commentsConducted"], (0, get_1.default)(collection, [userKey, key, "commentsConducted"], 0) + 1); }); } }); if (pullRequestLogin) { [pullRequestLogin, "total", ...(teams[pullRequestLogin] || [])].forEach((userKey) => { - collection[userKey][key]["reviewComments"] = - (reviewComments?.length || 0) + - (collection[userKey][key].reviewComments || 0); + (0, set_1.default)(collection, [userKey, key, "reviewComments"], (reviewComments?.length || 0) + + (0, get_1.default)(collection, [userKey, key, "reviewComments"], 0)); }); } discussions?.forEach((discussion) => { const userLogin = discussion.user?.login || constants_1.invalidUserLogin; [userLogin, "total", ...(teams[userLogin] || [])].forEach((userKey) => { - collection[userKey][key].discussions = { - ...collection[userKey][key].discussions, + (0, set_1.default)(collection, [userKey, key, "discussions"], { + ...(0, get_1.default)(collection, [userKey, key, "discussions"], {}), conducted: { - total: (collection[userKey][key].discussions?.conducted?.total || 0) + 1, - agreed: (collection[userKey][key].discussions?.conducted?.agreed || 0) + - (discussion.reactions?.["+1"] ? 1 : 0), - disagreed: (collection[userKey][key].discussions?.conducted?.disagreed || - 0) + (discussion.reactions?.["-1"] ? 1 : 0), + total: (0, get_1.default)(collection, [userKey, key, "discussions", "conducted", "total"], 0) + 1, + agreed: (0, get_1.default)(collection, [userKey, key, "discussions", "conducted", "agreed"], 0) + (discussion.reactions?.["+1"] ? 1 : 0), + disagreed: (0, get_1.default)(collection, [userKey, key, "discussions", "conducted", "disagreed"], 0) + (discussion.reactions?.["-1"] ? 1 : 0), }, - }; + }); }); }); if (pullRequestLogin) { const agreedDiscussions = discussions?.filter((discussion) => discussion.reactions?.["+1"]); const disagreedDiscussions = discussions?.filter((discussion) => discussion.reactions?.["-1"]); [pullRequestLogin, "total", ...(teams[pullRequestLogin] || [])].forEach((userKey) => { - collection[userKey][key].discussions = { - ...collection[userKey][key].discussions, + (0, set_1.default)(collection, [userKey, key, "discussions"], { + ...(0, get_1.default)(collection, [userKey, key, "discussions"], {}), received: { - total: (collection[userKey][key].discussions?.received?.total || 0) + - (discussions?.length || 0), - agreed: (collection[userKey][key].discussions?.received?.agreed || 0) + - (agreedDiscussions?.length || 0), - disagreed: (collection[userKey][key].discussions?.received?.disagreed || - 0) + (disagreedDiscussions?.length || 0), + total: (0, get_1.default)(collection, [userKey, key, "discussions", "received", "total"], 0) + (discussions?.length || 0), + agreed: (0, get_1.default)(collection, [userKey, key, "discussions", "received", "agreed"], 0) + (agreedDiscussions?.length || 0), + disagreed: (0, get_1.default)(collection, [userKey, key, "discussions", "received", "disagreed"], 0) + (disagreedDiscussions?.length || 0), }, - }; + }); }); } }); @@ -1701,16 +1726,23 @@ exports.preparePullRequestTimeline = preparePullRequestTimeline; /***/ }), /***/ 62381: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.prepareRequestedReviews = void 0; +const set_1 = __importDefault(__nccwpck_require__(82900)); +const get_1 = __importDefault(__nccwpck_require__(56908)); const constants_1 = __nccwpck_require__(95354); const prepareRequestedReviews = (requests = [], collection, dateKey, teams) => { const requestedReviewers = requests.reduce((acc, request) => { - const user = request.requested_reviewer?.login || constants_1.invalidUserLogin; + const user = request.requested_reviewer + ? request.requested_reviewer?.login || constants_1.invalidUserLogin + : request.requested_team?.name || "Invalid Team"; return { ...acc, [user]: 1 }; }, {}); requestedReviewers["total"] = Object.keys(requestedReviewers).length; @@ -1721,16 +1753,8 @@ const prepareRequestedReviews = (requests = [], collection, dateKey, teams) => { }); [dateKey, "total"].forEach((date) => { Object.entries({ ...requestedReviewers }).forEach(([user, value]) => { - [user, ...(teams[user] || [])].forEach((userKey) => { - if (!collection[userKey]) { - collection[userKey] = {}; - } - }); - collection[user][date] = { - ...collection[user][date], - reviewRequestsConducted: (collection[user][date]?.reviewRequestsConducted || 0) + - value, - }; + (0, set_1.default)(collection, [user, date, "reviewRequestsConducted"], (0, get_1.default)(collection, [user, date, "reviewRequestsConducted"], 0) + + value); }); }); }; @@ -1740,12 +1764,17 @@ exports.prepareRequestedReviews = prepareRequestedReviews; /***/ }), /***/ 85761: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.prepareResponseTime = void 0; +const set_1 = __importDefault(__nccwpck_require__(82900)); +const get_1 = __importDefault(__nccwpck_require__(56908)); const utils_1 = __nccwpck_require__(41002); const calculations_1 = __nccwpck_require__(16576); const prepareResponseTime = (events = [], pullRequest, collection, dateKey, teams) => { @@ -1767,27 +1796,25 @@ const prepareResponseTime = (events = [], pullRequest, collection, dateKey, team startOfWorkingTime: (0, utils_1.getValueAsIs)("CORE_HOURS_START"), }, (0, utils_1.getMultipleValuesInput)("HOLIDAYS"))); ["total", user, ...(teams[user] || [])].forEach((userKey) => { - collection[userKey][key] = { - ...collection[userKey][key], + (0, set_1.default)(collection, [userKey, key], { + ...(0, get_1.default)(collection, [userKey, key], {}), timeFromInitialRequestToResponse: typeof timeFromInitialRequestToResponse === "number" ? [ - ...(collection[userKey][key] - .timeFromInitialRequestToResponse || []), + ...(0, get_1.default)(collection, [userKey, key, "timeFromInitialRequestToResponse"], []), timeFromInitialRequestToResponse, ] - : collection[userKey][key].timeFromInitialRequestToResponse, + : (0, get_1.default)(collection, [userKey, key, "timeFromInitialRequestToResponse"], []), timeFromOpenToResponse: typeof timeFromOpenToResponse === "number" ? [ - ...(collection[userKey][key].timeFromOpenToResponse || []), + ...(0, get_1.default)(collection, [userKey, key, "timeFromOpenToResponse"], []), timeFromOpenToResponse, ] - : collection[user][key].timeFromOpenToResponse, + : (0, get_1.default)(collection, [userKey, key, "timeFromOpenToResponse"], []), timeFromRepeatedRequestToResponse: [ - ...(collection[userKey][key].timeFromRepeatedRequestToResponse || - []), + ...(0, get_1.default)(collection, [userKey, key, "timeFromRepeatedRequestToResponse"], []), ...timeFromRepeatedRequestToResponse.filter((el) => typeof el === "number"), ], - }; + }); }); }); }); @@ -1798,12 +1825,17 @@ exports.prepareResponseTime = prepareResponseTime; /***/ }), /***/ 60934: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.prepareReviews = void 0; +const set_1 = __importDefault(__nccwpck_require__(82900)); +const get_1 = __importDefault(__nccwpck_require__(56908)); const constants_1 = __nccwpck_require__(95354); const prepareConductedReviews_1 = __nccwpck_require__(15278); const prepareReviews = (reviews = [], collection, dateKey, pullRequestLogin, pullRequestSize, teams) => { @@ -1818,9 +1850,6 @@ const prepareReviews = (reviews = [], collection, dateKey, pullRequestLogin, pul return acc; }, {}) || {}).concat("total"); users.forEach((user) => { - if (!collection[user]) { - collection[user] = {}; - } const userReviews = Array.isArray(reviews) && user !== "total" && !teamNames.includes(user) ? reviews?.filter((review) => { const userLogin = review.user?.login || constants_1.invalidUserLogin; @@ -1828,7 +1857,7 @@ const prepareReviews = (reviews = [], collection, dateKey, pullRequestLogin, pul }) : reviews; [dateKey, "total"].forEach((key) => { - collection[user][key] = (0, prepareConductedReviews_1.prepareConductedReviews)(pullRequestLogin, userReviews, collection[user][key], pullRequestSize, teams); + (0, set_1.default)(collection, [user, key], (0, prepareConductedReviews_1.prepareConductedReviews)(pullRequestLogin, userReviews, (0, get_1.default)(collection, [user, key], {}), pullRequestSize, teams)); }); }); }; @@ -3105,7 +3134,7 @@ const createResponseTable = (data, users, date) => { return [ `**${user}**`, data[user]?.[date]?.reviewRequestsConducted?.toString() || "0", - data[user]?.[date]?.reviewsConducted?.total?.total.toString() || + data[user]?.[date]?.reviewsConducted?.total?.total?.toString() || "0", (0, formatMinutesDuration_1.formatMinutesDuration)(data[user]?.[date]?.[type]?.timeFromOpenToResponse || 0), @@ -41744,6 +41773,1833 @@ function toNumber(value) { module.exports = once; +/***/ }), + +/***/ 35902: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var hashClear = __nccwpck_require__(11789), + hashDelete = __nccwpck_require__(60712), + hashGet = __nccwpck_require__(45395), + hashHas = __nccwpck_require__(35232), + hashSet = __nccwpck_require__(47320); + +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `Hash`. +Hash.prototype.clear = hashClear; +Hash.prototype['delete'] = hashDelete; +Hash.prototype.get = hashGet; +Hash.prototype.has = hashHas; +Hash.prototype.set = hashSet; + +module.exports = Hash; + + +/***/ }), + +/***/ 96608: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var listCacheClear = __nccwpck_require__(69792), + listCacheDelete = __nccwpck_require__(97716), + listCacheGet = __nccwpck_require__(45789), + listCacheHas = __nccwpck_require__(59386), + listCacheSet = __nccwpck_require__(17399); + +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `ListCache`. +ListCache.prototype.clear = listCacheClear; +ListCache.prototype['delete'] = listCacheDelete; +ListCache.prototype.get = listCacheGet; +ListCache.prototype.has = listCacheHas; +ListCache.prototype.set = listCacheSet; + +module.exports = ListCache; + + +/***/ }), + +/***/ 80881: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var getNative = __nccwpck_require__(24479), + root = __nccwpck_require__(89882); + +/* Built-in method references that are verified to be native. */ +var Map = getNative(root, 'Map'); + +module.exports = Map; + + +/***/ }), + +/***/ 80938: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var mapCacheClear = __nccwpck_require__(1610), + mapCacheDelete = __nccwpck_require__(56657), + mapCacheGet = __nccwpck_require__(81372), + mapCacheHas = __nccwpck_require__(40609), + mapCacheSet = __nccwpck_require__(45582); + +/** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `MapCache`. +MapCache.prototype.clear = mapCacheClear; +MapCache.prototype['delete'] = mapCacheDelete; +MapCache.prototype.get = mapCacheGet; +MapCache.prototype.has = mapCacheHas; +MapCache.prototype.set = mapCacheSet; + +module.exports = MapCache; + + +/***/ }), + +/***/ 19213: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var root = __nccwpck_require__(89882); + +/** Built-in value references. */ +var Symbol = root.Symbol; + +module.exports = Symbol; + + +/***/ }), + +/***/ 94356: +/***/ ((module) => { + +/** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} + +module.exports = arrayMap; + + +/***/ }), + +/***/ 39725: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var baseAssignValue = __nccwpck_require__(13868), + eq = __nccwpck_require__(61901); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } +} + +module.exports = assignValue; + + +/***/ }), + +/***/ 96752: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var eq = __nccwpck_require__(61901); + +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; +} + +module.exports = assocIndexOf; + + +/***/ }), + +/***/ 13868: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var defineProperty = __nccwpck_require__(416); + +/** + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function baseAssignValue(object, key, value) { + if (key == '__proto__' && defineProperty) { + defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } +} + +module.exports = baseAssignValue; + + +/***/ }), + +/***/ 75758: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var castPath = __nccwpck_require__(2688), + toKey = __nccwpck_require__(69071); + +/** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ +function baseGet(object, path) { + path = castPath(path, object); + + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; +} + +module.exports = baseGet; + + +/***/ }), + +/***/ 97497: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var Symbol = __nccwpck_require__(19213), + getRawTag = __nccwpck_require__(80923), + objectToString = __nccwpck_require__(14200); + +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); +} + +module.exports = baseGetTag; + + +/***/ }), + +/***/ 50411: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var isFunction = __nccwpck_require__(17799), + isMasked = __nccwpck_require__(29058), + isObject = __nccwpck_require__(33334), + toSource = __nccwpck_require__(96928); + +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** Used for built-in method references. */ +var funcProto = Function.prototype, + objectProto = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); +} + +module.exports = baseIsNative; + + +/***/ }), + +/***/ 78580: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var assignValue = __nccwpck_require__(39725), + castPath = __nccwpck_require__(2688), + isIndex = __nccwpck_require__(32936), + isObject = __nccwpck_require__(33334), + toKey = __nccwpck_require__(69071); + +/** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ +function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } + path = castPath(path, object); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = toKey(path[index]), + newValue = value; + + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; + } + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); + } + } + assignValue(nested, key, newValue); + nested = nested[key]; + } + return object; +} + +module.exports = baseSet; + + +/***/ }), + +/***/ 96792: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var Symbol = __nccwpck_require__(19213), + arrayMap = __nccwpck_require__(94356), + isArray = __nccwpck_require__(44869), + isSymbol = __nccwpck_require__(66403); + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +module.exports = baseToString; + + +/***/ }), + +/***/ 2688: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var isArray = __nccwpck_require__(44869), + isKey = __nccwpck_require__(69084), + stringToPath = __nccwpck_require__(61853), + toString = __nccwpck_require__(32931); + +/** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. + */ +function castPath(value, object) { + if (isArray(value)) { + return value; + } + return isKey(value, object) ? [value] : stringToPath(toString(value)); +} + +module.exports = castPath; + + +/***/ }), + +/***/ 78380: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var root = __nccwpck_require__(89882); + +/** Used to detect overreaching core-js shims. */ +var coreJsData = root['__core-js_shared__']; + +module.exports = coreJsData; + + +/***/ }), + +/***/ 416: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var getNative = __nccwpck_require__(24479); + +var defineProperty = (function() { + try { + var func = getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} +}()); + +module.exports = defineProperty; + + +/***/ }), + +/***/ 52085: +/***/ ((module) => { + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +module.exports = freeGlobal; + + +/***/ }), + +/***/ 69980: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var isKeyable = __nccwpck_require__(13308); + +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} + +module.exports = getMapData; + + +/***/ }), + +/***/ 24479: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var baseIsNative = __nccwpck_require__(50411), + getValue = __nccwpck_require__(13542); + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; +} + +module.exports = getNative; + + +/***/ }), + +/***/ 80923: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var Symbol = __nccwpck_require__(19213); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; +} + +module.exports = getRawTag; + + +/***/ }), + +/***/ 13542: +/***/ ((module) => { + +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue(object, key) { + return object == null ? undefined : object[key]; +} + +module.exports = getValue; + + +/***/ }), + +/***/ 11789: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var nativeCreate = __nccwpck_require__(93041); + +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; +} + +module.exports = hashClear; + + +/***/ }), + +/***/ 60712: +/***/ ((module) => { + +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; +} + +module.exports = hashDelete; + + +/***/ }), + +/***/ 45395: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var nativeCreate = __nccwpck_require__(93041); + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty.call(data, key) ? data[key] : undefined; +} + +module.exports = hashGet; + + +/***/ }), + +/***/ 35232: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var nativeCreate = __nccwpck_require__(93041); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas(key) { + var data = this.__data__; + return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); +} + +module.exports = hashHas; + + +/***/ }), + +/***/ 47320: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var nativeCreate = __nccwpck_require__(93041); + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; +} + +module.exports = hashSet; + + +/***/ }), + +/***/ 32936: +/***/ ((module) => { + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); +} + +module.exports = isIndex; + + +/***/ }), + +/***/ 69084: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var isArray = __nccwpck_require__(44869), + isSymbol = __nccwpck_require__(66403); + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/; + +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey(value, object) { + if (isArray(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); +} + +module.exports = isKey; + + +/***/ }), + +/***/ 13308: +/***/ ((module) => { + +/** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); +} + +module.exports = isKeyable; + + +/***/ }), + +/***/ 29058: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var coreJsData = __nccwpck_require__(78380); + +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); +} + +module.exports = isMasked; + + +/***/ }), + +/***/ 69792: +/***/ ((module) => { + +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} + +module.exports = listCacheClear; + + +/***/ }), + +/***/ 97716: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var assocIndexOf = __nccwpck_require__(96752); + +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/** Built-in value references. */ +var splice = arrayProto.splice; + +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; +} + +module.exports = listCacheDelete; + + +/***/ }), + +/***/ 45789: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var assocIndexOf = __nccwpck_require__(96752); + +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; +} + +module.exports = listCacheGet; + + +/***/ }), + +/***/ 59386: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var assocIndexOf = __nccwpck_require__(96752); + +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; +} + +module.exports = listCacheHas; + + +/***/ }), + +/***/ 17399: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var assocIndexOf = __nccwpck_require__(96752); + +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; +} + +module.exports = listCacheSet; + + +/***/ }), + +/***/ 1610: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var Hash = __nccwpck_require__(35902), + ListCache = __nccwpck_require__(96608), + Map = __nccwpck_require__(80881); + +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; +} + +module.exports = mapCacheClear; + + +/***/ }), + +/***/ 56657: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var getMapData = __nccwpck_require__(69980); + +/** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; +} + +module.exports = mapCacheDelete; + + +/***/ }), + +/***/ 81372: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var getMapData = __nccwpck_require__(69980); + +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet(key) { + return getMapData(this, key).get(key); +} + +module.exports = mapCacheGet; + + +/***/ }), + +/***/ 40609: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var getMapData = __nccwpck_require__(69980); + +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas(key) { + return getMapData(this, key).has(key); +} + +module.exports = mapCacheHas; + + +/***/ }), + +/***/ 45582: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var getMapData = __nccwpck_require__(69980); + +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} + +module.exports = mapCacheSet; + + +/***/ }), + +/***/ 29422: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var memoize = __nccwpck_require__(19885); + +/** Used as the maximum memoize cache size. */ +var MAX_MEMOIZE_SIZE = 500; + +/** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. + * + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ +function memoizeCapped(func) { + var result = memoize(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; + }); + + var cache = result.cache; + return result; +} + +module.exports = memoizeCapped; + + +/***/ }), + +/***/ 93041: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var getNative = __nccwpck_require__(24479); + +/* Built-in method references that are verified to be native. */ +var nativeCreate = getNative(Object, 'create'); + +module.exports = nativeCreate; + + +/***/ }), + +/***/ 14200: +/***/ ((module) => { + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +module.exports = objectToString; + + +/***/ }), + +/***/ 89882: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var freeGlobal = __nccwpck_require__(52085); + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +module.exports = root; + + +/***/ }), + +/***/ 61853: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var memoizeCapped = __nccwpck_require__(29422); + +/** Used to match property names within property paths. */ +var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; + +/** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ +var stringToPath = memoizeCapped(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; +}); + +module.exports = stringToPath; + + +/***/ }), + +/***/ 69071: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var isSymbol = __nccwpck_require__(66403); + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ +function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +module.exports = toKey; + + +/***/ }), + +/***/ 96928: +/***/ ((module) => { + +/** Used for built-in method references. */ +var funcProto = Function.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ +function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; +} + +module.exports = toSource; + + +/***/ }), + +/***/ 61901: +/***/ ((module) => { + +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq(value, other) { + return value === other || (value !== value && other !== other); +} + +module.exports = eq; + + +/***/ }), + +/***/ 56908: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var baseGet = __nccwpck_require__(75758); + +/** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ +function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, path); + return result === undefined ? defaultValue : result; +} + +module.exports = get; + + +/***/ }), + +/***/ 44869: +/***/ ((module) => { + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +module.exports = isArray; + + +/***/ }), + +/***/ 17799: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var baseGetTag = __nccwpck_require__(97497), + isObject = __nccwpck_require__(33334); + +/** `Object#toString` result references. */ +var asyncTag = '[object AsyncFunction]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + proxyTag = '[object Proxy]'; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + if (!isObject(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; +} + +module.exports = isFunction; + + +/***/ }), + +/***/ 33334: +/***/ ((module) => { + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +module.exports = isObject; + + +/***/ }), + +/***/ 85926: +/***/ ((module) => { + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +module.exports = isObjectLike; + + +/***/ }), + +/***/ 66403: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var baseGetTag = __nccwpck_require__(97497), + isObjectLike = __nccwpck_require__(85926); + +/** `Object#toString` result references. */ +var symbolTag = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && baseGetTag(value) == symbolTag); +} + +module.exports = isSymbol; + + +/***/ }), + +/***/ 19885: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var MapCache = __nccwpck_require__(80938); + +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ +function memoize(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || MapCache); + return memoized; +} + +// Expose `MapCache`. +memoize.Cache = MapCache; + +module.exports = memoize; + + +/***/ }), + +/***/ 82900: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var baseSet = __nccwpck_require__(78580); + +/** + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, + * it's created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.set(object, 'a[0].b.c', 4); + * console.log(object.a[0].b.c); + * // => 4 + * + * _.set(object, ['x', '0', 'y', 'z'], 5); + * console.log(object.x[0].y.z); + * // => 5 + */ +function set(object, path, value) { + return object == null ? object : baseSet(object, path, value); +} + +module.exports = set; + + +/***/ }), + +/***/ 32931: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var baseToString = __nccwpck_require__(96792); + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString(value) { + return value == null ? '' : baseToString(value); +} + +module.exports = toString; + + /***/ }), /***/ 28869: diff --git a/package-lock.json b/package-lock.json index fff18c3..9b658df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,24 +1,26 @@ { "name": "pull-request-analytics-action", - "version": "3.0.0", + "version": "3.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pull-request-analytics-action", - "version": "3.0.0", + "version": "3.1.1", "license": "MIT", "dependencies": { "@actions/core": "^1.10.1", "@octokit/plugin-throttling": "^8.1.3", "date-fns": "^2.30.0", "dotenv": "^16.3.1", + "lodash": "^4.17.21", "mixpanel": "^0.18.0", "octokit": "^3.1.2" }, "devDependencies": { "@tsconfig/node20": "^20.1.2", "@types/jest": "^29.5.10", + "@types/lodash": "^4.17.7", "@typescript-eslint/eslint-plugin": "^6.12.0", "@typescript-eslint/parser": "^6.12.0", "@vercel/ncc": "^0.38.1", @@ -1771,6 +1773,12 @@ "@types/node": "*" } }, + "node_modules/@types/lodash": { + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", + "integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==", + "dev": true + }, "node_modules/@types/node": { "version": "20.10.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.0.tgz", @@ -4358,6 +4366,11 @@ "node": ">=8" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, "node_modules/lodash.includes": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", diff --git a/package.json b/package.json index 894874e..08ae51b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pull-request-analytics-action", - "version": "3.1.0", + "version": "3.1.1", "description": "Generates detailed PR analytics reports within GitHub, focusing on review efficiency and team performance.", "main": "build/index.js", "scripts": { @@ -19,6 +19,7 @@ "@octokit/plugin-throttling": "^8.1.3", "date-fns": "^2.30.0", "dotenv": "^16.3.1", + "lodash": "^4.17.21", "mixpanel": "^0.18.0", "octokit": "^3.1.2" }, @@ -31,6 +32,7 @@ "devDependencies": { "@tsconfig/node20": "^20.1.2", "@types/jest": "^29.5.10", + "@types/lodash": "^4.17.7", "@typescript-eslint/eslint-plugin": "^6.12.0", "@typescript-eslint/parser": "^6.12.0", "@vercel/ncc": "^0.38.1", diff --git a/src/converters/collectData.ts b/src/converters/collectData.ts index ada355c..d186473 100644 --- a/src/converters/collectData.ts +++ b/src/converters/collectData.ts @@ -1,4 +1,7 @@ import { format, parseISO } from "date-fns"; +import set from "lodash/set"; +import get from "lodash/get"; + import { makeComplexRequest } from "../requests"; import { Collection } from "./types"; import { @@ -54,25 +57,29 @@ export const collectData = ( : invalidDate; const userKey = pullRequest.user?.login || invalidUserLogin; - [userKey, ...(teams[userKey] || [])].forEach((key) => { - if (!collection[key]) { - collection[key] = {}; - } - }); prepareRequestedReviews(reviewRequests, collection, dateKey, teams); ["total", userKey, ...(teams[userKey] || [])].forEach((key) => { ["total", dateKey].forEach((innerKey) => { - collection[key][innerKey] = preparePullRequestInfo( - pullRequest, - collection[key][innerKey] + set( + collection, + [key, innerKey], + preparePullRequestInfo( + pullRequest, + get(collection, [key, innerKey], {}) + ) ); - collection[key][innerKey] = preparePullRequestTimeline( - pullRequest, - reviews, - reviewRequests?.[0], - statuses, - collection[key][innerKey] + + set( + collection, + [key, innerKey], + preparePullRequestTimeline( + pullRequest, + reviews, + reviewRequests?.[0], + statuses, + get(collection, [key, innerKey], {}) + ) ); }); }); @@ -104,7 +111,7 @@ export const collectData = ( Object.entries(collection).map(([key, value]) => { Object.entries(value).forEach(([innerKey, innerValue]) => { - collection[key][innerKey] = preparePullRequestStats(innerValue); + set(collection, [key, innerKey], preparePullRequestStats(innerValue)); }); }); diff --git a/src/converters/utils/prepareDiscussions.ts b/src/converters/utils/prepareDiscussions.ts index 451198c..ff1bca7 100644 --- a/src/converters/utils/prepareDiscussions.ts +++ b/src/converters/utils/prepareDiscussions.ts @@ -1,3 +1,6 @@ +import set from "lodash/set"; +import get from "lodash/get"; + import { makeComplexRequest } from "../../requests"; import { invalidUserLogin } from "../constants"; import { Collection } from "../types"; @@ -23,94 +26,171 @@ export const prepareDiscussions = ( ["total", dateKey].forEach((key) => { discussions?.forEach((discussion) => { const userLogin = discussion.user?.login || invalidUserLogin; - [ - userLogin, - pullRequestLogin, - "total", - ...(teams[userLogin] || []), - ...(teams[pullRequestLogin] || []), - ].forEach((checkingKey) => { - if (collection[checkingKey][key].discussionsTypes === undefined) { - collection[checkingKey][key].discussionsTypes = {}; - } - }); getDiscussionType(discussion.body).forEach((type) => { [userLogin, ...(teams[userLogin] || [])].forEach((userKey) => { - collection[userKey][key].discussionsTypes![type] = { - ...(collection[userKey][key].discussionsTypes![type] || {}), + set(collection, [userKey, key, "discussionsTypes", type], { + ...get(collection, [userKey, key, "discussionsTypes", type], {}), conducted: { total: - (collection[userKey][key].discussionsTypes![type]?.conducted - ?.total || 0) + 1, + get( + collection, + [ + userKey, + key, + "discussionsTypes", + type, + "conducted", + "total", + ], + 0 + ) + 1, agreed: - (collection[userKey][key].discussionsTypes![type]?.conducted - ?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0), + get( + collection, + [ + userKey, + key, + "discussionsTypes", + type, + "conducted", + "agreed", + ], + 0 + ) + (discussion.reactions?.["+1"] ? 1 : 0), disagreed: - (collection[userKey][key].discussionsTypes![type]?.conducted - ?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0), + get( + collection, + [ + userKey, + key, + "discussionsTypes", + type, + "conducted", + "disagreed", + ], + 0 + ) + (discussion.reactions?.["-1"] ? 1 : 0), }, - }; + }); }); [pullRequestLogin, ...(teams[pullRequestLogin] || [])].forEach( (userKey) => { - collection[userKey][key].discussionsTypes![type] = { - ...(collection[userKey][key].discussionsTypes![type] || {}), + set(collection, [userKey, key, "discussionsTypes", type], { + ...get(collection, [userKey, key, "discussionsTypes", type], {}), received: { total: - (collection[userKey][key].discussionsTypes![type]?.received - ?.total || 0) + 1, + get( + collection, + [ + userKey, + key, + "discussionsTypes", + type, + "received", + "total", + ], + 0 + ) + 1, agreed: - (collection[userKey][key].discussionsTypes![type]?.received - ?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0), + get( + collection, + [ + userKey, + key, + "discussionsTypes", + type, + "received", + "agreed", + ], + 0 + ) + (discussion.reactions?.["+1"] ? 1 : 0), disagreed: - (collection[userKey][key].discussionsTypes![type]?.received - ?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0), + get( + collection, + [ + userKey, + key, + "discussionsTypes", + type, + "received", + "disagreed", + ], + 0 + ) + (discussion.reactions?.["-1"] ? 1 : 0), }, - }; + }); } ); - - collection.total[key].discussionsTypes![type] = { - ...(collection.total[key].discussionsTypes![type] || {}), + set(collection, ["total", key, "discussionsTypes", type], { + ...get(collection, ["total", key, "discussionsTypes", type], {}), conducted: { total: - (collection.total[key].discussionsTypes![type]?.conducted - ?.total || 0) + 1, + get( + collection, + ["total", key, "discussionsTypes", type, "conducted", "total"], + 0 + ) + 1, agreed: - (collection.total[key].discussionsTypes![type]?.conducted - ?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0), + get( + collection, + ["total", key, "discussionsTypes", type, "conducted", "agreed"], + 0 + ) + (discussion.reactions?.["+1"] ? 1 : 0), disagreed: - (collection.total[key].discussionsTypes![type]?.conducted - ?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0), + get( + collection, + [ + "total", + key, + "discussionsTypes", + type, + "conducted", + "disagreed", + ], + 0 + ) + (discussion.reactions?.["-1"] ? 1 : 0), }, received: { total: - (collection.total[key].discussionsTypes![type]?.received?.total || - 0) + 1, + get( + collection, + ["total", key, "discussionsTypes", type, "received", "total"], + 0 + ) + 1, agreed: - (collection.total[key].discussionsTypes![type]?.received - ?.agreed || 0) + (discussion.reactions?.["+1"] ? 1 : 0), + get( + collection, + ["total", key, "discussionsTypes", type, "received", "agreed"], + 0 + ) + (discussion.reactions?.["+1"] ? 1 : 0), disagreed: - (collection.total[key].discussionsTypes![type]?.received - ?.disagreed || 0) + (discussion.reactions?.["-1"] ? 1 : 0), + get( + collection, + [ + "total", + key, + "discussionsTypes", + type, + "received", + "disagreed", + ], + 0 + ) + (discussion.reactions?.["-1"] ? 1 : 0), }, - }; + }); }); }); comments[index]?.forEach((comment) => { const userLogin = comment.user?.login || invalidUserLogin; if (pullRequestLogin !== userLogin) { - if (!collection[userLogin]) { - collection[userLogin] = {}; - } - if (!collection[userLogin][key]) { - collection[userLogin][key] = {}; - } [userLogin, "total", ...(teams[userLogin] || [])].forEach((userKey) => { - collection[userKey][key].commentsConducted = - (collection[userKey][key].commentsConducted || 0) + 1; + set( + collection, + [userKey, key, "commentsConducted"], + get(collection, [userKey, key, "commentsConducted"], 0) + 1 + ); }); } }); @@ -118,9 +198,12 @@ export const prepareDiscussions = ( if (pullRequestLogin) { [pullRequestLogin, "total", ...(teams[pullRequestLogin] || [])].forEach( (userKey) => { - collection[userKey][key]["reviewComments"] = + set( + collection, + [userKey, key, "reviewComments"], (reviewComments?.length || 0) + - (collection[userKey][key].reviewComments || 0); + get(collection, [userKey, key, "reviewComments"], 0) + ); } ); } @@ -128,19 +211,29 @@ export const prepareDiscussions = ( discussions?.forEach((discussion) => { const userLogin = discussion.user?.login || invalidUserLogin; [userLogin, "total", ...(teams[userLogin] || [])].forEach((userKey) => { - collection[userKey][key].discussions = { - ...collection[userKey][key].discussions, + set(collection, [userKey, key, "discussions"], { + ...get(collection, [userKey, key, "discussions"], {}), conducted: { total: - (collection[userKey][key].discussions?.conducted?.total || 0) + 1, + get( + collection, + [userKey, key, "discussions", "conducted", "total"], + 0 + ) + 1, agreed: - (collection[userKey][key].discussions?.conducted?.agreed || 0) + - (discussion.reactions?.["+1"] ? 1 : 0), + get( + collection, + [userKey, key, "discussions", "conducted", "agreed"], + 0 + ) + (discussion.reactions?.["+1"] ? 1 : 0), disagreed: - (collection[userKey][key].discussions?.conducted?.disagreed || - 0) + (discussion.reactions?.["-1"] ? 1 : 0), + get( + collection, + [userKey, key, "discussions", "conducted", "disagreed"], + 0 + ) + (discussion.reactions?.["-1"] ? 1 : 0), }, - }; + }); }); }); @@ -154,20 +247,29 @@ export const prepareDiscussions = ( [pullRequestLogin, "total", ...(teams[pullRequestLogin] || [])].forEach( (userKey) => { - collection[userKey][key].discussions = { - ...collection[userKey][key].discussions, + set(collection, [userKey, key, "discussions"], { + ...get(collection, [userKey, key, "discussions"], {}), received: { total: - (collection[userKey][key].discussions?.received?.total || 0) + - (discussions?.length || 0), + get( + collection, + [userKey, key, "discussions", "received", "total"], + 0 + ) + (discussions?.length || 0), agreed: - (collection[userKey][key].discussions?.received?.agreed || 0) + - (agreedDiscussions?.length || 0), + get( + collection, + [userKey, key, "discussions", "received", "agreed"], + 0 + ) + (agreedDiscussions?.length || 0), disagreed: - (collection[userKey][key].discussions?.received?.disagreed || - 0) + (disagreedDiscussions?.length || 0), + get( + collection, + [userKey, key, "discussions", "received", "disagreed"], + 0 + ) + (disagreedDiscussions?.length || 0), }, - }; + }); } ); } diff --git a/src/converters/utils/prepareRequestedReviews.ts b/src/converters/utils/prepareRequestedReviews.ts index 612b1d0..45b8423 100644 --- a/src/converters/utils/prepareRequestedReviews.ts +++ b/src/converters/utils/prepareRequestedReviews.ts @@ -1,3 +1,6 @@ +import set from "lodash/set"; +import get from "lodash/get"; + import { invalidUserLogin } from "../constants"; import { Collection } from "../types"; @@ -8,7 +11,9 @@ export const prepareRequestedReviews = ( teams: Record ) => { const requestedReviewers = requests.reduce((acc, request) => { - const user = request.requested_reviewer?.login || invalidUserLogin; + const user = request.requested_reviewer + ? request.requested_reviewer?.login || invalidUserLogin + : request.requested_team?.name || "Invalid Team"; return { ...acc, [user]: 1 }; }, {}); @@ -22,18 +27,12 @@ export const prepareRequestedReviews = ( [dateKey, "total"].forEach((date) => { Object.entries({ ...requestedReviewers }).forEach(([user, value]) => { - [user, ...(teams[user] || [])].forEach((userKey) => { - if (!collection[userKey]) { - collection[userKey] = {}; - } - }); - - collection[user][date] = { - ...collection[user][date], - reviewRequestsConducted: - (collection[user][date]?.reviewRequestsConducted || 0) + - (value as number), - }; + set( + collection, + [user, date, "reviewRequestsConducted"], + get(collection, [user, date, "reviewRequestsConducted"], 0) + + (value as number) + ); }); }); }; diff --git a/src/converters/utils/prepareResponseTime.ts b/src/converters/utils/prepareResponseTime.ts index 5dd9ff4..3dba835 100644 --- a/src/converters/utils/prepareResponseTime.ts +++ b/src/converters/utils/prepareResponseTime.ts @@ -1,3 +1,6 @@ +import set from "lodash/set"; +import get from "lodash/get"; + import { getMultipleValuesInput, getValueAsIs } from "../../common/utils"; import { makeComplexRequest } from "../../requests"; import { Collection } from "../types"; @@ -52,31 +55,45 @@ export const prepareResponseTime = ( ); ["total", user, ...(teams[user] || [])].forEach((userKey) => { - collection[userKey][key] = { - ...collection[userKey][key], + set(collection, [userKey, key], { + ...get(collection, [userKey, key], {}), timeFromInitialRequestToResponse: typeof timeFromInitialRequestToResponse === "number" ? [ - ...(collection[userKey][key] - .timeFromInitialRequestToResponse || []), + ...get( + collection, + [userKey, key, "timeFromInitialRequestToResponse"], + [] + ), timeFromInitialRequestToResponse, ] - : collection[userKey][key].timeFromInitialRequestToResponse, + : get( + collection, + [userKey, key, "timeFromInitialRequestToResponse"], + [] + ), timeFromOpenToResponse: typeof timeFromOpenToResponse === "number" ? [ - ...(collection[userKey][key].timeFromOpenToResponse || []), + ...get( + collection, + [userKey, key, "timeFromOpenToResponse"], + [] + ), timeFromOpenToResponse, ] - : collection[user][key].timeFromOpenToResponse, + : get(collection, [userKey, key, "timeFromOpenToResponse"], []), timeFromRepeatedRequestToResponse: [ - ...(collection[userKey][key].timeFromRepeatedRequestToResponse || - []), + ...get( + collection, + [userKey, key, "timeFromRepeatedRequestToResponse"], + [] + ), ...(timeFromRepeatedRequestToResponse.filter( (el) => typeof el === "number" ) as number[]), ], - }; + }); }); }); } diff --git a/src/converters/utils/prepareReviews.ts b/src/converters/utils/prepareReviews.ts index 9011370..1b1cc67 100644 --- a/src/converters/utils/prepareReviews.ts +++ b/src/converters/utils/prepareReviews.ts @@ -1,3 +1,6 @@ +import set from "lodash/set"; +import get from "lodash/get"; + import { invalidUserLogin } from "../constants"; import { Collection } from "../types"; import { PullRequestSize } from "./calculations/getPullRequestSize"; @@ -28,9 +31,6 @@ export const prepareReviews = ( ).concat("total"); users.forEach((user) => { - if (!collection[user]) { - collection[user] = {}; - } const userReviews = Array.isArray(reviews) && user !== "total" && !teamNames.includes(user) ? reviews?.filter((review) => { @@ -39,12 +39,16 @@ export const prepareReviews = ( }) : reviews; [dateKey, "total"].forEach((key) => { - collection[user][key] = prepareConductedReviews( - pullRequestLogin, - userReviews, - collection[user][key], - pullRequestSize, - teams + set( + collection, + [user, key], + prepareConductedReviews( + pullRequestLogin, + userReviews, + get(collection, [user, key], {}), + pullRequestSize, + teams + ) ); }); }); diff --git a/src/view/utils/createResponseTable.ts b/src/view/utils/createResponseTable.ts index 97546d0..1b6f9de 100644 --- a/src/view/utils/createResponseTable.ts +++ b/src/view/utils/createResponseTable.ts @@ -34,7 +34,7 @@ export const createResponseTable = ( return [ `**${user}**`, data[user]?.[date]?.reviewRequestsConducted?.toString() || "0", - data[user]?.[date]?.reviewsConducted?.total?.total.toString() || + data[user]?.[date]?.reviewsConducted?.total?.total?.toString() || "0", formatMinutesDuration( data[user]?.[date]?.[type as StatsType]?.timeFromOpenToResponse ||