@lighthouse/common 6.9.0-canary.1 → 6.9.0-canary.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,9 +12,9 @@ function getAuditItemsData(items, data) {
|
|
|
12
12
|
awsS3BaseUrl,
|
|
13
13
|
cloudinaryBaseUrl,
|
|
14
14
|
cloudfrontBaseUrl,
|
|
15
|
-
Policy,
|
|
16
|
-
KeyPairId,
|
|
17
|
-
Signature,
|
|
15
|
+
Policy = '',
|
|
16
|
+
KeyPairId = '',
|
|
17
|
+
Signature = '',
|
|
18
18
|
shouldUseCloudfront
|
|
19
19
|
} = {},
|
|
20
20
|
entity: {
|
|
@@ -56,6 +56,10 @@ function getAuditItemsData(items, data) {
|
|
|
56
56
|
const hasScore = item.score !== null && item.score !== -1;
|
|
57
57
|
const rawAssets = item.assets || [];
|
|
58
58
|
const assetCount = rawAssets.length;
|
|
59
|
+
console.log({
|
|
60
|
+
rawAssets,
|
|
61
|
+
item
|
|
62
|
+
});
|
|
59
63
|
const assets = rawAssets.map((asset, assetIndex) => {
|
|
60
64
|
const assetUrl = (0, _.buildFetchUrl)(asset, {
|
|
61
65
|
awsS3BaseUrl,
|
|
@@ -7,9 +7,12 @@ export function getAuditItemsData(items, data) {
|
|
|
7
7
|
awsS3BaseUrl = _data$settings2.awsS3BaseUrl,
|
|
8
8
|
cloudinaryBaseUrl = _data$settings2.cloudinaryBaseUrl,
|
|
9
9
|
cloudfrontBaseUrl = _data$settings2.cloudfrontBaseUrl,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
_data$settings2$Polic = _data$settings2.Policy,
|
|
11
|
+
Policy = _data$settings2$Polic === void 0 ? '' : _data$settings2$Polic,
|
|
12
|
+
_data$settings2$KeyPa = _data$settings2.KeyPairId,
|
|
13
|
+
KeyPairId = _data$settings2$KeyPa === void 0 ? '' : _data$settings2$KeyPa,
|
|
14
|
+
_data$settings2$Signa = _data$settings2.Signature,
|
|
15
|
+
Signature = _data$settings2$Signa === void 0 ? '' : _data$settings2$Signa,
|
|
13
16
|
shouldUseCloudfront = _data$settings2.shouldUseCloudfront,
|
|
14
17
|
_data$entity = data.entity,
|
|
15
18
|
_data$entity2 = _data$entity === void 0 ? {} : _data$entity,
|
|
@@ -49,6 +52,10 @@ export function getAuditItemsData(items, data) {
|
|
|
49
52
|
var hasScore = item.score !== null && item.score !== -1;
|
|
50
53
|
var rawAssets = item.assets || [];
|
|
51
54
|
var assetCount = rawAssets.length;
|
|
55
|
+
console.log({
|
|
56
|
+
rawAssets: rawAssets,
|
|
57
|
+
item: item
|
|
58
|
+
});
|
|
52
59
|
var assets = rawAssets.map(function (asset, assetIndex) {
|
|
53
60
|
var assetUrl = buildFetchUrl(asset, {
|
|
54
61
|
awsS3BaseUrl: awsS3BaseUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["find","groupBy","map","get","round","buildFetchUrl","getAuditItemsData","items","data","_data$settings","settings","_data$settings2","awsS3BaseUrl","cloudinaryBaseUrl","cloudfrontBaseUrl","Policy","KeyPairId","Signature","shouldUseCloudfront","_data$entity","entity","_data$entity2","groupScores","console","info","groupedItems","auditData","overallActualScore","overallMaximumScore","groupIndex","key","skipped","group","title","label","groupData","groupMaximumScore","groupActualScore","groupResultScore","groupPercentageResultScore","currentGroupScores","max","actual","result","percentageResult","item","itemIndex","hasScore","score","rawAssets","assets","assetCount","length","asset","assetIndex","assetUrl","height","width","quality","fit","link","concat","signedAssets","thumbnailUrl","_defineProperty","comments","matchingScore","scores","value","scoreLabel","scoreWeight","weight","questionId","_id"],"sources":["../../../src/helpers/get-audit-items-data/index.js"],"sourcesContent":["import { find, groupBy, map, get, round } from 'lodash'\n\nimport { buildFetchUrl } from '../'\n\nexport function getAuditItemsData(items, data) {\n const {\n settings: {\n awsS3BaseUrl,\n cloudinaryBaseUrl,\n cloudfrontBaseUrl,\n Policy,\n KeyPairId,\n Signature,\n shouldUseCloudfront,\n } = {},\n entity: { groupScores } = {},\n } = data\n console.info({ data })\n const groupedItems = groupBy(items, 'group.id')\n\n const auditData = {\n overallActualScore: 0,\n overallMaximumScore: 0,\n }\n\n auditData.items = map(groupedItems, (items, groupIndex) => {\n const key = groupIndex\n const skipped = !!items[0].group.skipped\n const title = items[0].group.label\n\n const groupData = {\n key,\n groupMaximumScore: 0,\n groupActualScore: 0,\n groupResultScore: 0,\n groupPercentageResultScore: 0,\n skipped,\n title,\n }\n\n const currentGroupScores = get(groupScores, key)\n\n if (currentGroupScores) {\n groupData.groupMaximumScore = round(currentGroupScores.max, 2)\n groupData.groupActualScore = round(currentGroupScores.actual, 2)\n groupData.groupResultScore = currentGroupScores.result\n groupData.groupPercentageResultScore = currentGroupScores.percentageResult\n }\n\n groupData.items = items.map((item, itemIndex) => {\n // NOTE: we handle scores of -1, 0 and 1\n // -1 scores are skipped from group max and actual score\n // 0 and 1 must be included in the final scores\n const hasScore = item.score !== null && item.score !== -1\n const rawAssets = item.assets || []\n const assetCount = rawAssets.length\n\n const assets = rawAssets.map((asset, assetIndex) => {\n const assetUrl = buildFetchUrl(asset, {\n awsS3BaseUrl,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n height: 400,\n width: 600,\n quality: 50,\n fit: true,\n shouldUseCloudfront,\n Policy,\n KeyPairId,\n Signature,\n })\n\n const link = shouldUseCloudfront\n ? `${cloudfrontBaseUrl}/${item.signedAssets[assetIndex]}`\n : `${awsS3BaseUrl}/${asset}`\n\n const thumbnailUrl = buildFetchUrl(asset, {\n awsS3BaseUrl,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n shouldUseCloudfront,\n width: 100,\n quality: 50,\n fit: true,\n shouldUseCloudfront,\n Policy,\n KeyPairId,\n Signature,\n })\n\n const key = `${groupIndex}-item-asset-${assetIndex}`\n\n return {\n assetUrl,\n key,\n link,\n thumbnailUrl,\n }\n })\n\n const comments = item.comments\n const label = item.label\n const score = item.score\n const key = `${groupIndex}-item-${itemIndex}`\n const matchingScore = find(item.scores, { value: score })\n\n // NOTE: ensure we have a score otherwise fallback to - value\n const scoreLabel =\n hasScore && matchingScore && !skipped ? matchingScore.label : '-'\n const scoreWeight = hasScore && !skipped ? item.scoreWeight : '-'\n const weight = hasScore ? item.weight : '-'\n\n return {\n assetCount,\n assets,\n comments,\n key,\n label,\n questionId: item._id,\n score,\n scoreLabel,\n scoreWeight,\n weight,\n }\n })\n\n return groupData\n })\n\n return auditData\n}\n"],"mappings":";AAAA,SAASA,IAAI,EAAEC,OAAO,EAAEC,GAAG,EAAEC,GAAG,EAAEC,KAAK,QAAQ,QAAQ;AAEvD,SAASC,aAAa,QAAQ,KAAK;AAEnC,OAAO,SAASC,iBAAiBA,CAACC,KAAK,EAAEC,IAAI,EAAE;EAC7C,IAAAC,cAAA,GAWID,IAAI,CAVNE,QAAQ;IAAAC,eAAA,GAAAF,cAAA,cAQJ,CAAC,CAAC,GAAAA,cAAA;IAPJG,YAAY,GAAAD,eAAA,CAAZC,YAAY;IACZC,iBAAiB,GAAAF,eAAA,CAAjBE,iBAAiB;IACjBC,iBAAiB,GAAAH,eAAA,CAAjBG,iBAAiB;
|
|
1
|
+
{"version":3,"file":"index.js","names":["find","groupBy","map","get","round","buildFetchUrl","getAuditItemsData","items","data","_data$settings","settings","_data$settings2","awsS3BaseUrl","cloudinaryBaseUrl","cloudfrontBaseUrl","_data$settings2$Polic","Policy","_data$settings2$KeyPa","KeyPairId","_data$settings2$Signa","Signature","shouldUseCloudfront","_data$entity","entity","_data$entity2","groupScores","console","info","groupedItems","auditData","overallActualScore","overallMaximumScore","groupIndex","key","skipped","group","title","label","groupData","groupMaximumScore","groupActualScore","groupResultScore","groupPercentageResultScore","currentGroupScores","max","actual","result","percentageResult","item","itemIndex","hasScore","score","rawAssets","assets","assetCount","length","log","asset","assetIndex","assetUrl","height","width","quality","fit","link","concat","signedAssets","thumbnailUrl","_defineProperty","comments","matchingScore","scores","value","scoreLabel","scoreWeight","weight","questionId","_id"],"sources":["../../../src/helpers/get-audit-items-data/index.js"],"sourcesContent":["import { find, groupBy, map, get, round } from 'lodash'\n\nimport { buildFetchUrl } from '../'\n\nexport function getAuditItemsData(items, data) {\n const {\n settings: {\n awsS3BaseUrl,\n cloudinaryBaseUrl,\n cloudfrontBaseUrl,\n Policy = '',\n KeyPairId = '',\n Signature = '',\n shouldUseCloudfront,\n } = {},\n entity: { groupScores } = {},\n } = data\n console.info({ data })\n const groupedItems = groupBy(items, 'group.id')\n\n const auditData = {\n overallActualScore: 0,\n overallMaximumScore: 0,\n }\n\n auditData.items = map(groupedItems, (items, groupIndex) => {\n const key = groupIndex\n const skipped = !!items[0].group.skipped\n const title = items[0].group.label\n\n const groupData = {\n key,\n groupMaximumScore: 0,\n groupActualScore: 0,\n groupResultScore: 0,\n groupPercentageResultScore: 0,\n skipped,\n title,\n }\n\n const currentGroupScores = get(groupScores, key)\n\n if (currentGroupScores) {\n groupData.groupMaximumScore = round(currentGroupScores.max, 2)\n groupData.groupActualScore = round(currentGroupScores.actual, 2)\n groupData.groupResultScore = currentGroupScores.result\n groupData.groupPercentageResultScore = currentGroupScores.percentageResult\n }\n\n groupData.items = items.map((item, itemIndex) => {\n // NOTE: we handle scores of -1, 0 and 1\n // -1 scores are skipped from group max and actual score\n // 0 and 1 must be included in the final scores\n const hasScore = item.score !== null && item.score !== -1\n const rawAssets = item.assets || []\n const assetCount = rawAssets.length\n\n console.log({ rawAssets, item })\n const assets = rawAssets.map((asset, assetIndex) => {\n const assetUrl = buildFetchUrl(asset, {\n awsS3BaseUrl,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n height: 400,\n width: 600,\n quality: 50,\n fit: true,\n shouldUseCloudfront,\n Policy,\n KeyPairId,\n Signature,\n })\n\n const link = shouldUseCloudfront\n ? `${cloudfrontBaseUrl}/${item.signedAssets[assetIndex]}`\n : `${awsS3BaseUrl}/${asset}`\n\n const thumbnailUrl = buildFetchUrl(asset, {\n awsS3BaseUrl,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n shouldUseCloudfront,\n width: 100,\n quality: 50,\n fit: true,\n shouldUseCloudfront,\n Policy,\n KeyPairId,\n Signature,\n })\n\n const key = `${groupIndex}-item-asset-${assetIndex}`\n\n return {\n assetUrl,\n key,\n link,\n thumbnailUrl,\n }\n })\n\n const comments = item.comments\n const label = item.label\n const score = item.score\n const key = `${groupIndex}-item-${itemIndex}`\n const matchingScore = find(item.scores, { value: score })\n\n // NOTE: ensure we have a score otherwise fallback to - value\n const scoreLabel =\n hasScore && matchingScore && !skipped ? matchingScore.label : '-'\n const scoreWeight = hasScore && !skipped ? item.scoreWeight : '-'\n const weight = hasScore ? item.weight : '-'\n\n return {\n assetCount,\n assets,\n comments,\n key,\n label,\n questionId: item._id,\n score,\n scoreLabel,\n scoreWeight,\n weight,\n }\n })\n\n return groupData\n })\n\n return auditData\n}\n"],"mappings":";AAAA,SAASA,IAAI,EAAEC,OAAO,EAAEC,GAAG,EAAEC,GAAG,EAAEC,KAAK,QAAQ,QAAQ;AAEvD,SAASC,aAAa,QAAQ,KAAK;AAEnC,OAAO,SAASC,iBAAiBA,CAACC,KAAK,EAAEC,IAAI,EAAE;EAC7C,IAAAC,cAAA,GAWID,IAAI,CAVNE,QAAQ;IAAAC,eAAA,GAAAF,cAAA,cAQJ,CAAC,CAAC,GAAAA,cAAA;IAPJG,YAAY,GAAAD,eAAA,CAAZC,YAAY;IACZC,iBAAiB,GAAAF,eAAA,CAAjBE,iBAAiB;IACjBC,iBAAiB,GAAAH,eAAA,CAAjBG,iBAAiB;IAAAC,qBAAA,GAAAJ,eAAA,CACjBK,MAAM;IAANA,MAAM,GAAAD,qBAAA,cAAG,EAAE,GAAAA,qBAAA;IAAAE,qBAAA,GAAAN,eAAA,CACXO,SAAS;IAATA,SAAS,GAAAD,qBAAA,cAAG,EAAE,GAAAA,qBAAA;IAAAE,qBAAA,GAAAR,eAAA,CACdS,SAAS;IAATA,SAAS,GAAAD,qBAAA,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