chore: code formatting
This commit is contained in:
@@ -70,7 +70,7 @@ placeholder.run = async vars => {
|
||||
//Setup
|
||||
beforeAll(async () => {
|
||||
//Clean community template
|
||||
await fs.promises.rm(path.join(__dirname, "../source/templates/@classic"), { recursive: true, force:true })
|
||||
await fs.promises.rm(path.join(__dirname, "../source/templates/@classic"), { recursive: true, force: true })
|
||||
//Start web instance
|
||||
await web.start()
|
||||
})
|
||||
@@ -79,7 +79,7 @@ afterAll(async () => {
|
||||
//Stop web instance
|
||||
await web.stop()
|
||||
//Clean community template
|
||||
await fs.promises.rm(path.join(__dirname, "../source/templates/@classic"), { recursive: true, force:true })
|
||||
await fs.promises.rm(path.join(__dirname, "../source/templates/@classic"), { recursive: true, force: true })
|
||||
})
|
||||
|
||||
//Load metadata (as jest doesn't support ESM modules, we use this dirty hack)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
//Last.fm api
|
||||
if (/^https:..ws.audioscrobbler.com.*$/.test(url)) {
|
||||
//Get recently played tracks
|
||||
@@ -10,146 +10,146 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
const track = faker.random.words(5)
|
||||
const date = faker.date.recent()
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
recenttracks:{
|
||||
"@attr":{
|
||||
page:"1",
|
||||
perPage:"1",
|
||||
user:"RJ",
|
||||
total:"100",
|
||||
pages:"100",
|
||||
status: 200,
|
||||
data: {
|
||||
recenttracks: {
|
||||
"@attr": {
|
||||
page: "1",
|
||||
perPage: "1",
|
||||
user: "RJ",
|
||||
total: "100",
|
||||
pages: "100",
|
||||
},
|
||||
track:[
|
||||
track: [
|
||||
{
|
||||
artist:{
|
||||
mbid:"",
|
||||
"#text":artist,
|
||||
artist: {
|
||||
mbid: "",
|
||||
"#text": artist,
|
||||
},
|
||||
album:{
|
||||
mbid:"",
|
||||
"#text":album,
|
||||
album: {
|
||||
mbid: "",
|
||||
"#text": album,
|
||||
},
|
||||
image:[
|
||||
image: [
|
||||
{
|
||||
size:"small",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "small",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
{
|
||||
size:"medium",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "medium",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
{
|
||||
size:"large",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "large",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
{
|
||||
size:"extralarge",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "extralarge",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
],
|
||||
streamable:"0",
|
||||
date:{
|
||||
uts:Math.floor(date.getTime() / 1000),
|
||||
"#text":date.toUTCString().slice(5, 22),
|
||||
streamable: "0",
|
||||
date: {
|
||||
uts: Math.floor(date.getTime() / 1000),
|
||||
"#text": date.toUTCString().slice(5, 22),
|
||||
},
|
||||
url:faker.internet.url(),
|
||||
name:track,
|
||||
mbid:"",
|
||||
url: faker.internet.url(),
|
||||
name: track,
|
||||
mbid: "",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
else if (/user.gettoptracks/.test(url)) {
|
||||
else if (/user.gettoptracks/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking lastfm api result > ${url}`)
|
||||
const artist = faker.random.word()
|
||||
const track = faker.random.words(5)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
toptracks:{
|
||||
"@attr":{
|
||||
page:"1",
|
||||
perPage:"1",
|
||||
user:"RJ",
|
||||
total:"100",
|
||||
pages:"100",
|
||||
status: 200,
|
||||
data: {
|
||||
toptracks: {
|
||||
"@attr": {
|
||||
page: "1",
|
||||
perPage: "1",
|
||||
user: "RJ",
|
||||
total: "100",
|
||||
pages: "100",
|
||||
},
|
||||
track:[
|
||||
track: [
|
||||
{
|
||||
artist:{
|
||||
mbid:"",
|
||||
name:artist,
|
||||
artist: {
|
||||
mbid: "",
|
||||
name: artist,
|
||||
},
|
||||
image:[
|
||||
image: [
|
||||
{
|
||||
size:"small",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "small",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
{
|
||||
size:"medium",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "medium",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
{
|
||||
size:"large",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "large",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
{
|
||||
size:"extralarge",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "extralarge",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
],
|
||||
url:faker.internet.url(),
|
||||
name:track,
|
||||
mbid:"",
|
||||
url: faker.internet.url(),
|
||||
name: track,
|
||||
mbid: "",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
else if (/user.gettopartists/.test(url)) {
|
||||
else if (/user.gettopartists/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking lastfm api result > ${url}`)
|
||||
const artist = faker.random.word()
|
||||
const playcount = faker.random.number()
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
topartists:{
|
||||
"@attr":{
|
||||
page:"1",
|
||||
perPage:"1",
|
||||
user:"RJ",
|
||||
total:"100",
|
||||
pages:"100",
|
||||
status: 200,
|
||||
data: {
|
||||
topartists: {
|
||||
"@attr": {
|
||||
page: "1",
|
||||
perPage: "1",
|
||||
user: "RJ",
|
||||
total: "100",
|
||||
pages: "100",
|
||||
},
|
||||
artist:[
|
||||
artist: [
|
||||
{
|
||||
image:[
|
||||
image: [
|
||||
{
|
||||
size:"small",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "small",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
{
|
||||
size:"medium",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "medium",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
{
|
||||
size:"large",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "large",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
{
|
||||
size:"extralarge",
|
||||
"#text":faker.image.abstract(),
|
||||
size: "extralarge",
|
||||
"#text": faker.image.abstract(),
|
||||
},
|
||||
],
|
||||
streamable:"0",
|
||||
streamable: "0",
|
||||
playcount,
|
||||
url:faker.internet.url(),
|
||||
name:artist,
|
||||
mbid:"",
|
||||
url: faker.internet.url(),
|
||||
name: artist,
|
||||
mbid: "",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url}) {
|
||||
export default function({ faker, url }) {
|
||||
//Last.fm api
|
||||
if (/^https:..testapp.herokuapp.com.*$/.test(url)) {
|
||||
//Get Nightscout Data
|
||||
console.debug(`metrics/compute/mocks > mocking nightscout api result > ${url}`)
|
||||
const lastInterval = Math.floor(new Date() / 300000) * 300000
|
||||
return ({
|
||||
status:200,
|
||||
data:new Array(12).fill(null).map(_ => ({
|
||||
_id:faker.git.commitSha().substring(0, 23),
|
||||
device:"xDrip-DexcomG5",
|
||||
date:lastInterval,
|
||||
dateString:new Date(lastInterval).toISOString(),
|
||||
sgv:faker.datatype.number({min:40, max:400}),
|
||||
delta:faker.datatype.number({min:-10, max:10}),
|
||||
direction:faker.random.arrayElement(["SingleUp", "DoubleUp", "FortyFiveUp", "Flat", "FortyFiveDown", "SingleDown", "DoubleDown"]),
|
||||
type:"sgv",
|
||||
filtered:0,
|
||||
unfiltered:0,
|
||||
rssi:100,
|
||||
noise:1,
|
||||
sysTime:new Date(lastInterval).toISOString(),
|
||||
utcOffset:faker.datatype.number({min:-12, max:14}) * 60,
|
||||
status: 200,
|
||||
data: new Array(12).fill(null).map(_ => ({
|
||||
_id: faker.git.commitSha().substring(0, 23),
|
||||
device: "xDrip-DexcomG5",
|
||||
date: lastInterval,
|
||||
dateString: new Date(lastInterval).toISOString(),
|
||||
sgv: faker.datatype.number({ min: 40, max: 400 }),
|
||||
delta: faker.datatype.number({ min: -10, max: 10 }),
|
||||
direction: faker.random.arrayElement(["SingleUp", "DoubleUp", "FortyFiveUp", "Flat", "FortyFiveDown", "SingleDown", "DoubleDown"]),
|
||||
type: "sgv",
|
||||
filtered: 0,
|
||||
unfiltered: 0,
|
||||
rssi: 100,
|
||||
noise: 1,
|
||||
sysTime: new Date(lastInterval).toISOString(),
|
||||
utcOffset: faker.datatype.number({ min: -12, max: 14 }) * 60,
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
//Tested url
|
||||
const tested = url.match(/&url=(?<tested>.*?)(?:&|$)/)?.groups?.tested ?? faker.internet.url()
|
||||
//Pagespeed api
|
||||
@@ -8,96 +8,96 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
if (/v5.runPagespeed.*&key=MOCKED_TOKEN/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking pagespeed api result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
captchaResult:"CAPTCHA_NOT_NEEDED",
|
||||
id:tested,
|
||||
lighthouseResult:{
|
||||
requestedUrl:tested,
|
||||
finalUrl:tested,
|
||||
lighthouseVersion:"6.3.0",
|
||||
audits:{
|
||||
"final-screenshot":{
|
||||
id:"final-screenshot",
|
||||
title:"Final Screenshot",
|
||||
score:null,
|
||||
details:{
|
||||
data:null,
|
||||
type:"screenshot",
|
||||
timestamp:Date.now(),
|
||||
status: 200,
|
||||
data: {
|
||||
captchaResult: "CAPTCHA_NOT_NEEDED",
|
||||
id: tested,
|
||||
lighthouseResult: {
|
||||
requestedUrl: tested,
|
||||
finalUrl: tested,
|
||||
lighthouseVersion: "6.3.0",
|
||||
audits: {
|
||||
"final-screenshot": {
|
||||
id: "final-screenshot",
|
||||
title: "Final Screenshot",
|
||||
score: null,
|
||||
details: {
|
||||
data: null,
|
||||
type: "screenshot",
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
},
|
||||
metrics:{
|
||||
id:"metrics",
|
||||
title:"Metrics",
|
||||
score:null,
|
||||
details:{
|
||||
items:[
|
||||
metrics: {
|
||||
id: "metrics",
|
||||
title: "Metrics",
|
||||
score: null,
|
||||
details: {
|
||||
items: [
|
||||
{
|
||||
observedFirstContentfulPaint:faker.datatype.number(500),
|
||||
observedFirstVisualChangeTs:faker.time.recent(),
|
||||
observedFirstContentfulPaintTs:faker.time.recent(),
|
||||
firstContentfulPaint:faker.datatype.number(500),
|
||||
observedDomContentLoaded:faker.datatype.number(500),
|
||||
observedFirstMeaningfulPaint:faker.datatype.number(1000),
|
||||
maxPotentialFID:faker.datatype.number(500),
|
||||
observedLoad:faker.datatype.number(500),
|
||||
firstMeaningfulPaint:faker.datatype.number(500),
|
||||
observedCumulativeLayoutShift:faker.datatype.float({max:1}),
|
||||
observedSpeedIndex:faker.datatype.number(1000),
|
||||
observedSpeedIndexTs:faker.time.recent(),
|
||||
observedTimeOriginTs:faker.time.recent(),
|
||||
observedLargestContentfulPaint:faker.datatype.number(1000),
|
||||
cumulativeLayoutShift:faker.datatype.float({max:1}),
|
||||
observedFirstPaintTs:faker.time.recent(),
|
||||
observedTraceEndTs:faker.time.recent(),
|
||||
largestContentfulPaint:faker.datatype.number(2000),
|
||||
observedTimeOrigin:faker.datatype.number(10),
|
||||
speedIndex:faker.datatype.number(1000),
|
||||
observedTraceEnd:faker.datatype.number(2000),
|
||||
observedDomContentLoadedTs:faker.time.recent(),
|
||||
observedFirstPaint:faker.datatype.number(500),
|
||||
totalBlockingTime:faker.datatype.number(500),
|
||||
observedLastVisualChangeTs:faker.time.recent(),
|
||||
observedFirstVisualChange:faker.datatype.number(500),
|
||||
observedLargestContentfulPaintTs:faker.time.recent(),
|
||||
estimatedInputLatency:faker.datatype.number(100),
|
||||
observedLoadTs:faker.time.recent(),
|
||||
observedLastVisualChange:faker.datatype.number(1000),
|
||||
firstCPUIdle:faker.datatype.number(1000),
|
||||
interactive:faker.datatype.number(1000),
|
||||
observedNavigationStartTs:faker.time.recent(),
|
||||
observedNavigationStart:faker.datatype.number(10),
|
||||
observedFirstMeaningfulPaintTs:faker.time.recent(),
|
||||
observedFirstContentfulPaint: faker.datatype.number(500),
|
||||
observedFirstVisualChangeTs: faker.time.recent(),
|
||||
observedFirstContentfulPaintTs: faker.time.recent(),
|
||||
firstContentfulPaint: faker.datatype.number(500),
|
||||
observedDomContentLoaded: faker.datatype.number(500),
|
||||
observedFirstMeaningfulPaint: faker.datatype.number(1000),
|
||||
maxPotentialFID: faker.datatype.number(500),
|
||||
observedLoad: faker.datatype.number(500),
|
||||
firstMeaningfulPaint: faker.datatype.number(500),
|
||||
observedCumulativeLayoutShift: faker.datatype.float({ max: 1 }),
|
||||
observedSpeedIndex: faker.datatype.number(1000),
|
||||
observedSpeedIndexTs: faker.time.recent(),
|
||||
observedTimeOriginTs: faker.time.recent(),
|
||||
observedLargestContentfulPaint: faker.datatype.number(1000),
|
||||
cumulativeLayoutShift: faker.datatype.float({ max: 1 }),
|
||||
observedFirstPaintTs: faker.time.recent(),
|
||||
observedTraceEndTs: faker.time.recent(),
|
||||
largestContentfulPaint: faker.datatype.number(2000),
|
||||
observedTimeOrigin: faker.datatype.number(10),
|
||||
speedIndex: faker.datatype.number(1000),
|
||||
observedTraceEnd: faker.datatype.number(2000),
|
||||
observedDomContentLoadedTs: faker.time.recent(),
|
||||
observedFirstPaint: faker.datatype.number(500),
|
||||
totalBlockingTime: faker.datatype.number(500),
|
||||
observedLastVisualChangeTs: faker.time.recent(),
|
||||
observedFirstVisualChange: faker.datatype.number(500),
|
||||
observedLargestContentfulPaintTs: faker.time.recent(),
|
||||
estimatedInputLatency: faker.datatype.number(100),
|
||||
observedLoadTs: faker.time.recent(),
|
||||
observedLastVisualChange: faker.datatype.number(1000),
|
||||
firstCPUIdle: faker.datatype.number(1000),
|
||||
interactive: faker.datatype.number(1000),
|
||||
observedNavigationStartTs: faker.time.recent(),
|
||||
observedNavigationStart: faker.datatype.number(10),
|
||||
observedFirstMeaningfulPaintTs: faker.time.recent(),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
categories:{
|
||||
"best-practices":{
|
||||
id:"best-practices",
|
||||
title:"Best Practices",
|
||||
score:faker.datatype.float({max:1}),
|
||||
categories: {
|
||||
"best-practices": {
|
||||
id: "best-practices",
|
||||
title: "Best Practices",
|
||||
score: faker.datatype.float({ max: 1 }),
|
||||
},
|
||||
seo:{
|
||||
id:"seo",
|
||||
title:"SEO",
|
||||
score:faker.datatype.float({max:1}),
|
||||
seo: {
|
||||
id: "seo",
|
||||
title: "SEO",
|
||||
score: faker.datatype.float({ max: 1 }),
|
||||
},
|
||||
accessibility:{
|
||||
id:"accessibility",
|
||||
title:"Accessibility",
|
||||
score:faker.datatype.float({max:1}),
|
||||
accessibility: {
|
||||
id: "accessibility",
|
||||
title: "Accessibility",
|
||||
score: faker.datatype.float({ max: 1 }),
|
||||
},
|
||||
performance:{
|
||||
id:"performance",
|
||||
title:"Performance",
|
||||
score:faker.datatype.float({max:1}),
|
||||
performance: {
|
||||
id: "performance",
|
||||
title: "Performance",
|
||||
score: faker.datatype.float({ max: 1 }),
|
||||
},
|
||||
},
|
||||
},
|
||||
analysisUTCTimestamp:`${faker.date.recent()}`,
|
||||
analysisUTCTimestamp: `${faker.date.recent()}`,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
//Wakatime api
|
||||
if (/^https:..api.poopmap.net$/.test(url)) {
|
||||
//Get user profile
|
||||
if (/public_links\/MOCKED_TOKEN/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking poopmap api result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
poops:new Array(12 + faker.datatype.number(6)).fill(null).map(_ => ({
|
||||
id:79744699,
|
||||
latitude:faker.address.latitude(),
|
||||
longitude:faker.address.longitude(),
|
||||
created_at:faker.date.past().toISOString(),
|
||||
note:"",
|
||||
place:"",
|
||||
rating:faker.datatype.number(5),
|
||||
followers_count:faker.datatype.number(100),
|
||||
comments_count:faker.datatype.number(12)
|
||||
}))
|
||||
status: 200,
|
||||
data: {
|
||||
poops: new Array(12 + faker.datatype.number(6)).fill(null).map(_ => ({
|
||||
id: 79744699,
|
||||
latitude: faker.address.latitude(),
|
||||
longitude: faker.address.longitude(),
|
||||
created_at: faker.date.past().toISOString(),
|
||||
note: "",
|
||||
place: "",
|
||||
rating: faker.datatype.number(5),
|
||||
followers_count: faker.datatype.number(100),
|
||||
comments_count: faker.datatype.number(12),
|
||||
})),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
//Spotify api
|
||||
if (/^https:..api.spotify.com.*$/.test(url)) {
|
||||
//Get recently played tracks
|
||||
@@ -8,140 +8,140 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
const artist = faker.random.words()
|
||||
const track = faker.random.words(5)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
items:[
|
||||
status: 200,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
track:{
|
||||
album:{
|
||||
album_type:"single",
|
||||
artists:[
|
||||
track: {
|
||||
album: {
|
||||
album_type: "single",
|
||||
artists: [
|
||||
{
|
||||
name:artist,
|
||||
type:"artist",
|
||||
name: artist,
|
||||
type: "artist",
|
||||
},
|
||||
],
|
||||
images:[
|
||||
images: [
|
||||
{
|
||||
height:640,
|
||||
url:faker.image.abstract(),
|
||||
width:640,
|
||||
height: 640,
|
||||
url: faker.image.abstract(),
|
||||
width: 640,
|
||||
},
|
||||
{
|
||||
height:300,
|
||||
url:faker.image.abstract(),
|
||||
width:300,
|
||||
height: 300,
|
||||
url: faker.image.abstract(),
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
height:64,
|
||||
url:faker.image.abstract(),
|
||||
width:64,
|
||||
height: 64,
|
||||
url: faker.image.abstract(),
|
||||
width: 64,
|
||||
},
|
||||
],
|
||||
name:track,
|
||||
release_date:`${faker.date.past()}`.substring(0, 10),
|
||||
type:"album",
|
||||
name: track,
|
||||
release_date: `${faker.date.past()}`.substring(0, 10),
|
||||
type: "album",
|
||||
},
|
||||
artists:[
|
||||
artists: [
|
||||
{
|
||||
name:artist,
|
||||
type:"artist",
|
||||
name: artist,
|
||||
type: "artist",
|
||||
},
|
||||
],
|
||||
name:track,
|
||||
preview_url:faker.internet.url(),
|
||||
type:"track",
|
||||
name: track,
|
||||
preview_url: faker.internet.url(),
|
||||
type: "track",
|
||||
},
|
||||
played_at:`${faker.date.recent()}`,
|
||||
context:{
|
||||
type:"album",
|
||||
played_at: `${faker.date.recent()}`,
|
||||
context: {
|
||||
type: "album",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
}
|
||||
else if (/me.top.tracks/.test(url) && (options?.headers?.Authorization === "Bearer MOCKED_TOKEN_ACCESS")) {
|
||||
else if (/me.top.tracks/.test(url) && (options?.headers?.Authorization === "Bearer MOCKED_TOKEN_ACCESS")) {
|
||||
console.debug(`metrics/compute/mocks > mocking spotify api result > ${url}`)
|
||||
const artist = faker.random.words()
|
||||
const track = faker.random.words(5)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
items:[
|
||||
status: 200,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
album:{
|
||||
album_type:"single",
|
||||
artists:[
|
||||
album: {
|
||||
album_type: "single",
|
||||
artists: [
|
||||
{
|
||||
name:artist,
|
||||
type:"artist",
|
||||
name: artist,
|
||||
type: "artist",
|
||||
},
|
||||
],
|
||||
images:[
|
||||
images: [
|
||||
{
|
||||
height:640,
|
||||
url:faker.image.abstract(),
|
||||
width:640,
|
||||
height: 640,
|
||||
url: faker.image.abstract(),
|
||||
width: 640,
|
||||
},
|
||||
{
|
||||
height:300,
|
||||
url:faker.image.abstract(),
|
||||
width:300,
|
||||
height: 300,
|
||||
url: faker.image.abstract(),
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
height:64,
|
||||
url:faker.image.abstract(),
|
||||
width:64,
|
||||
height: 64,
|
||||
url: faker.image.abstract(),
|
||||
width: 64,
|
||||
},
|
||||
],
|
||||
name:track,
|
||||
release_date:`${faker.date.past()}`.substring(0, 10),
|
||||
type:"album",
|
||||
name: track,
|
||||
release_date: `${faker.date.past()}`.substring(0, 10),
|
||||
type: "album",
|
||||
},
|
||||
artists:[
|
||||
artists: [
|
||||
{
|
||||
name:artist,
|
||||
type:"artist",
|
||||
name: artist,
|
||||
type: "artist",
|
||||
},
|
||||
],
|
||||
name:track,
|
||||
preview_url:faker.internet.url(),
|
||||
type:"track",
|
||||
name: track,
|
||||
preview_url: faker.internet.url(),
|
||||
type: "track",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
}
|
||||
else if (/me.top.artists/.test(url) && (options?.headers?.Authorization === "Bearer MOCKED_TOKEN_ACCESS")) {
|
||||
else if (/me.top.artists/.test(url) && (options?.headers?.Authorization === "Bearer MOCKED_TOKEN_ACCESS")) {
|
||||
console.debug(`metrics/compute/mocks > mocking spotify api result > ${url}`)
|
||||
const genre = faker.random.words()
|
||||
const track = faker.random.words(5)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
items:[
|
||||
status: 200,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
genres: [genre],
|
||||
images:[
|
||||
images: [
|
||||
{
|
||||
height:640,
|
||||
url:faker.image.abstract(),
|
||||
width:640,
|
||||
height: 640,
|
||||
url: faker.image.abstract(),
|
||||
width: 640,
|
||||
},
|
||||
{
|
||||
height:300,
|
||||
url:faker.image.abstract(),
|
||||
width:300,
|
||||
height: 300,
|
||||
url: faker.image.abstract(),
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
height:64,
|
||||
url:faker.image.abstract(),
|
||||
width:64,
|
||||
height: 64,
|
||||
url: faker.image.abstract(),
|
||||
width: 64,
|
||||
},
|
||||
],
|
||||
name:track,
|
||||
type:"artist",
|
||||
name: track,
|
||||
type: "artist",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
//Stackoverflow api
|
||||
if (/^https:..api.stackexchange.com.2.2.*$/.test(url)) {
|
||||
//Extract user id
|
||||
@@ -9,24 +9,24 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
if (/users[/]\d+[/][?]site=stackoverflow$/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking stackoverflow api result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
items:[
|
||||
status: 200,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
badge_counts:{bronze:faker.datatype.number(500), silver:faker.datatype.number(300), gold:faker.datatype.number(100)},
|
||||
accept_rate:faker.datatype.number(100),
|
||||
answer_count:faker.datatype.number(1000),
|
||||
question_count:faker.datatype.number(1000),
|
||||
view_count:faker.datatype.number(10000),
|
||||
creation_date:faker.date.past(),
|
||||
display_name:faker.internet.userName(),
|
||||
badge_counts: { bronze: faker.datatype.number(500), silver: faker.datatype.number(300), gold: faker.datatype.number(100) },
|
||||
accept_rate: faker.datatype.number(100),
|
||||
answer_count: faker.datatype.number(1000),
|
||||
question_count: faker.datatype.number(1000),
|
||||
view_count: faker.datatype.number(10000),
|
||||
creation_date: faker.date.past(),
|
||||
display_name: faker.internet.userName(),
|
||||
user_id,
|
||||
reputation:faker.datatype.number(100000),
|
||||
reputation: faker.datatype.number(100000),
|
||||
},
|
||||
],
|
||||
has_more:false,
|
||||
quota_max:300,
|
||||
quota_remaining:faker.datatype.number(300),
|
||||
has_more: false,
|
||||
quota_max: 300,
|
||||
quota_remaining: faker.datatype.number(300),
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -34,9 +34,9 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
if (/[?]site=stackoverflow&filter=total$/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking stackoverflow api result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
total:faker.datatype.number(10000),
|
||||
status: 200,
|
||||
data: {
|
||||
total: faker.datatype.number(10000),
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -44,29 +44,29 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
if ((/questions[?]site=stackoverflow/.test(url)) || (/questions[/][\d;]+[?]site=stackoverflow/.test(url))) {
|
||||
console.debug(`metrics/compute/mocks > mocking stackoverflow api result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
items:new Array(pagesize).fill(null).map(_ => ({
|
||||
tags:new Array(5).fill(null).map(_ => faker.lorem.slug()),
|
||||
owner:{display_name:faker.internet.userName()},
|
||||
is_answered:faker.datatype.boolean(),
|
||||
view_count:faker.datatype.number(10000),
|
||||
accepted_answer_id:faker.datatype.number(1000000),
|
||||
answer_count:faker.datatype.number(100),
|
||||
score:faker.datatype.number(1000),
|
||||
creation_date:faker.time.recent(),
|
||||
down_vote_count:faker.datatype.number(1000),
|
||||
up_vote_count:faker.datatype.number(1000),
|
||||
comment_count:faker.datatype.number(1000),
|
||||
favorite_count:faker.datatype.number(1000),
|
||||
title:faker.lorem.sentence(),
|
||||
body_markdown:faker.lorem.paragraphs(),
|
||||
link:faker.internet.url(),
|
||||
question_id:faker.datatype.number(1000000),
|
||||
status: 200,
|
||||
data: {
|
||||
items: new Array(pagesize).fill(null).map(_ => ({
|
||||
tags: new Array(5).fill(null).map(_ => faker.lorem.slug()),
|
||||
owner: { display_name: faker.internet.userName() },
|
||||
is_answered: faker.datatype.boolean(),
|
||||
view_count: faker.datatype.number(10000),
|
||||
accepted_answer_id: faker.datatype.number(1000000),
|
||||
answer_count: faker.datatype.number(100),
|
||||
score: faker.datatype.number(1000),
|
||||
creation_date: faker.time.recent(),
|
||||
down_vote_count: faker.datatype.number(1000),
|
||||
up_vote_count: faker.datatype.number(1000),
|
||||
comment_count: faker.datatype.number(1000),
|
||||
favorite_count: faker.datatype.number(1000),
|
||||
title: faker.lorem.sentence(),
|
||||
body_markdown: faker.lorem.paragraphs(),
|
||||
link: faker.internet.url(),
|
||||
question_id: faker.datatype.number(1000000),
|
||||
})),
|
||||
has_more:false,
|
||||
quota_max:300,
|
||||
quota_remaining:faker.datatype.number(300),
|
||||
has_more: false,
|
||||
quota_max: 300,
|
||||
quota_remaining: faker.datatype.number(300),
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -74,24 +74,24 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
if ((/answers[?]site=stackoverflow/.test(url)) || (/answers[/][\d;]+[?]site=stackoverflow/.test(url))) {
|
||||
console.debug(`metrics/compute/mocks > mocking stackoverflow api result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
items:new Array(pagesize).fill(null).map(_ => ({
|
||||
owner:{display_name:faker.internet.userName()},
|
||||
link:faker.internet.url(),
|
||||
is_accepted:faker.datatype.boolean(),
|
||||
score:faker.datatype.number(1000),
|
||||
down_vote_count:faker.datatype.number(1000),
|
||||
up_vote_count:faker.datatype.number(1000),
|
||||
comment_count:faker.datatype.number(1000),
|
||||
creation_date:faker.time.recent(),
|
||||
question_id:faker.datatype.number(1000000),
|
||||
body_markdown:faker.lorem.paragraphs(),
|
||||
answer_id:faker.datatype.number(1000000),
|
||||
status: 200,
|
||||
data: {
|
||||
items: new Array(pagesize).fill(null).map(_ => ({
|
||||
owner: { display_name: faker.internet.userName() },
|
||||
link: faker.internet.url(),
|
||||
is_accepted: faker.datatype.boolean(),
|
||||
score: faker.datatype.number(1000),
|
||||
down_vote_count: faker.datatype.number(1000),
|
||||
up_vote_count: faker.datatype.number(1000),
|
||||
comment_count: faker.datatype.number(1000),
|
||||
creation_date: faker.time.recent(),
|
||||
question_id: faker.datatype.number(1000000),
|
||||
body_markdown: faker.lorem.paragraphs(),
|
||||
answer_id: faker.datatype.number(1000000),
|
||||
})),
|
||||
has_more:false,
|
||||
quota_max:300,
|
||||
quota_remaining:faker.datatype.number(300),
|
||||
has_more: false,
|
||||
quota_max: 300,
|
||||
quota_remaining: faker.datatype.number(300),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
//Twitter api
|
||||
if (/^https:..api.twitter.com.*$/.test(url)) {
|
||||
//Get user profile
|
||||
@@ -7,13 +7,13 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
console.debug(`metrics/compute/mocks > mocking twitter api result > ${url}`)
|
||||
const username = url.match(/username[/](?<username>.*?)[?]/)?.groups?.username ?? faker.internet.userName()
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
data:{
|
||||
profile_image_url:faker.image.people(),
|
||||
name:faker.name.findName(),
|
||||
verified:faker.datatype.boolean(),
|
||||
id:faker.datatype.number(1000000).toString(),
|
||||
status: 200,
|
||||
data: {
|
||||
data: {
|
||||
profile_image_url: faker.image.people(),
|
||||
name: faker.name.findName(),
|
||||
verified: faker.datatype.boolean(),
|
||||
id: faker.datatype.number(1000000).toString(),
|
||||
username,
|
||||
},
|
||||
},
|
||||
@@ -23,39 +23,39 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
if ((/tweets.search.recent/.test(url)) && (options?.headers?.Authorization === "Bearer MOCKED_TOKEN")) {
|
||||
console.debug(`metrics/compute/mocks > mocking twitter api result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
data:[
|
||||
status: 200,
|
||||
data: {
|
||||
data: [
|
||||
{
|
||||
id:faker.datatype.number(100000000000000).toString(),
|
||||
created_at:`${faker.date.recent()}`,
|
||||
entities:{
|
||||
mentions:[
|
||||
{start:22, end:33, username:"lowlighter"},
|
||||
id: faker.datatype.number(100000000000000).toString(),
|
||||
created_at: `${faker.date.recent()}`,
|
||||
entities: {
|
||||
mentions: [
|
||||
{ start: 22, end: 33, username: "lowlighter" },
|
||||
],
|
||||
},
|
||||
text:"Checkout metrics from @lowlighter ! #GitHub",
|
||||
text: "Checkout metrics from @lowlighter ! #GitHub",
|
||||
},
|
||||
{
|
||||
id:faker.datatype.number(100000000000000).toString(),
|
||||
created_at:`${faker.date.recent()}`,
|
||||
text:faker.lorem.paragraph(),
|
||||
id: faker.datatype.number(100000000000000).toString(),
|
||||
created_at: `${faker.date.recent()}`,
|
||||
text: faker.lorem.paragraph(),
|
||||
},
|
||||
],
|
||||
includes:{
|
||||
users:[
|
||||
includes: {
|
||||
users: [
|
||||
{
|
||||
id:faker.datatype.number(100000000000000).toString(),
|
||||
name:"lowlighter",
|
||||
username:"lowlighter",
|
||||
id: faker.datatype.number(100000000000000).toString(),
|
||||
name: "lowlighter",
|
||||
username: "lowlighter",
|
||||
},
|
||||
],
|
||||
},
|
||||
meta:{
|
||||
newest_id:faker.datatype.number(100000000000000).toString(),
|
||||
oldest_id:faker.datatype.number(100000000000000).toString(),
|
||||
result_count:2,
|
||||
next_token:"MOCKED_CURSOR",
|
||||
meta: {
|
||||
newest_id: faker.datatype.number(100000000000000).toString(),
|
||||
oldest_id: faker.datatype.number(100000000000000).toString(),
|
||||
result_count: 2,
|
||||
next_token: "MOCKED_CURSOR",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
//Wakatime api
|
||||
if (/^https:..wakatime.com.api.v1.users..*.stats.*$/.test(url)) {
|
||||
//Get user profile
|
||||
@@ -11,13 +11,13 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
get digital() {
|
||||
return `${this.hours}:${this.minutes}`
|
||||
},
|
||||
hours:faker.datatype.number(1000),
|
||||
minutes:faker.datatype.number(1000),
|
||||
name:array ? faker.random.arrayElement(array) : faker.random.words(2).replace(/ /g, "-").toLocaleLowerCase(),
|
||||
percent:0,
|
||||
total_seconds:faker.datatype.number(1000000),
|
||||
hours: faker.datatype.number(1000),
|
||||
minutes: faker.datatype.number(1000),
|
||||
name: array ? faker.random.arrayElement(array) : faker.random.words(2).replace(/ /g, "-").toLocaleLowerCase(),
|
||||
percent: 0,
|
||||
total_seconds: faker.datatype.number(1000000),
|
||||
}))
|
||||
results = results.filter(({name}) => elements.includes(name) ? false : (elements.push(name), true))
|
||||
results = results.filter(({ name }) => elements.includes(name) ? false : (elements.push(name), true))
|
||||
let percents = 100
|
||||
for (const result of results) {
|
||||
result.percent = 1 + faker.datatype.number(percents - 1)
|
||||
@@ -26,26 +26,26 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
return results
|
||||
}
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
data:{
|
||||
best_day:{
|
||||
created_at:faker.date.recent(),
|
||||
date:`${faker.date.recent()}`.substring(0, 10),
|
||||
total_seconds:faker.datatype.number(1000000),
|
||||
status: 200,
|
||||
data: {
|
||||
data: {
|
||||
best_day: {
|
||||
created_at: faker.date.recent(),
|
||||
date: `${faker.date.recent()}`.substring(0, 10),
|
||||
total_seconds: faker.datatype.number(1000000),
|
||||
},
|
||||
categories:stats(),
|
||||
daily_average:faker.datatype.number(12 * 60 * 60),
|
||||
daily_average_including_other_language:faker.datatype.number(12 * 60 * 60),
|
||||
dependencies:stats(),
|
||||
editors:stats(["VS Code", "Chrome", "IntelliJ", "PhpStorm", "WebStorm", "Android Studio", "Visual Studio", "Sublime Text", "PyCharm", "Vim", "Atom", "Xcode"]),
|
||||
languages:stats(["JavaScript", "TypeScript", "PHP", "Java", "Python", "Vue.js", "HTML", "C#", "JSON", "Dart", "SCSS", "Kotlin", "JSX", "Go", "Ruby", "YAML"]),
|
||||
machines:stats(),
|
||||
operating_systems:stats(["Mac", "Windows", "Linux"]),
|
||||
project:null,
|
||||
projects:/api_key=MOCKED_TOKEN_NO_PROJECTS/.test(url) ? null : stats(),
|
||||
total_seconds:faker.datatype.number(1000000000),
|
||||
total_seconds_including_other_language:faker.datatype.number(1000000000),
|
||||
categories: stats(),
|
||||
daily_average: faker.datatype.number(12 * 60 * 60),
|
||||
daily_average_including_other_language: faker.datatype.number(12 * 60 * 60),
|
||||
dependencies: stats(),
|
||||
editors: stats(["VS Code", "Chrome", "IntelliJ", "PhpStorm", "WebStorm", "Android Studio", "Visual Studio", "Sublime Text", "PyCharm", "Vim", "Atom", "Xcode"]),
|
||||
languages: stats(["JavaScript", "TypeScript", "PHP", "Java", "Python", "Vue.js", "HTML", "C#", "JSON", "Dart", "SCSS", "Kotlin", "JSX", "Go", "Ruby", "YAML"]),
|
||||
machines: stats(),
|
||||
operating_systems: stats(["Mac", "Windows", "Linux"]),
|
||||
project: null,
|
||||
projects: /api_key=MOCKED_TOKEN_NO_PROJECTS/.test(url) ? null : stats(),
|
||||
total_seconds: faker.datatype.number(1000000000),
|
||||
total_seconds_including_other_language: faker.datatype.number(1000000000),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
//Wakatime api
|
||||
if (/^https:..apidojo-yahoo-finance-v1.p.rapidapi.com.stock.v2.*$/.test(url)) {
|
||||
//Get company profile
|
||||
if (/get-profile/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking yahoo finance api result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
price:{
|
||||
marketCap:{
|
||||
raw:faker.datatype.number(1000000000),
|
||||
status: 200,
|
||||
data: {
|
||||
price: {
|
||||
marketCap: {
|
||||
raw: faker.datatype.number(1000000000),
|
||||
},
|
||||
symbol:"OCTO",
|
||||
symbol: "OCTO",
|
||||
},
|
||||
quoteType:{
|
||||
shortName:faker.company.companyName(),
|
||||
longName:faker.company.companyName(),
|
||||
exchangeTimezoneName:faker.address.timeZone(),
|
||||
symbol:"OCTO",
|
||||
quoteType: {
|
||||
shortName: faker.company.companyName(),
|
||||
longName: faker.company.companyName(),
|
||||
exchangeTimezoneName: faker.address.timeZone(),
|
||||
symbol: "OCTO",
|
||||
},
|
||||
calendarEvents:{},
|
||||
summaryDetail:{},
|
||||
symbol:"OCTO",
|
||||
assetProfile:{
|
||||
fullTimeEmployees:faker.datatype.number(10000),
|
||||
city:faker.address.city(),
|
||||
country:faker.address.country(),
|
||||
calendarEvents: {},
|
||||
summaryDetail: {},
|
||||
symbol: "OCTO",
|
||||
assetProfile: {
|
||||
fullTimeEmployees: faker.datatype.number(10000),
|
||||
city: faker.address.city(),
|
||||
country: faker.address.country(),
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -35,23 +35,23 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
if (/get-chart/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking yahoo finance api result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
chart:{
|
||||
result:[
|
||||
status: 200,
|
||||
data: {
|
||||
chart: {
|
||||
result: [
|
||||
{
|
||||
meta:{
|
||||
currency:"USD",
|
||||
symbol:"OCTO",
|
||||
regularMarketPrice:faker.datatype.number(10000) / 100,
|
||||
chartPreviousClose:faker.datatype.number(10000) / 100,
|
||||
previousClose:faker.datatype.number(10000) / 100,
|
||||
meta: {
|
||||
currency: "USD",
|
||||
symbol: "OCTO",
|
||||
regularMarketPrice: faker.datatype.number(10000) / 100,
|
||||
chartPreviousClose: faker.datatype.number(10000) / 100,
|
||||
previousClose: faker.datatype.number(10000) / 100,
|
||||
},
|
||||
timestamp:new Array(1000).fill(Date.now()).map((x, i) => x + i * 60000),
|
||||
indicators:{
|
||||
quote:[
|
||||
timestamp: new Array(1000).fill(Date.now()).map((x, i) => x + i * 60000),
|
||||
indicators: {
|
||||
quote: [
|
||||
{
|
||||
close:new Array(1000).fill(null).map(_ => faker.datatype.number(10000) / 100),
|
||||
close: new Array(1000).fill(null).map(_ => faker.datatype.number(10000) / 100),
|
||||
get low() {
|
||||
return this.close
|
||||
},
|
||||
@@ -61,7 +61,7 @@ export default function({faker, url, options, login = faker.internet.userName()}
|
||||
get open() {
|
||||
return this.close
|
||||
},
|
||||
volume:[],
|
||||
volume: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, body, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, body, login = faker.internet.userName() }) {
|
||||
if (/^https:..graphql.anilist.co.*$/.test(url)) {
|
||||
//Initialization and media generator
|
||||
const {query} = body
|
||||
const media = ({type}) => ({
|
||||
title:{romaji:faker.lorem.words(), english:faker.lorem.words(), native:faker.lorem.words()},
|
||||
description:faker.lorem.paragraphs(),
|
||||
const { query } = body
|
||||
const media = ({ type }) => ({
|
||||
title: { romaji: faker.lorem.words(), english: faker.lorem.words(), native: faker.lorem.words() },
|
||||
description: faker.lorem.paragraphs(),
|
||||
type,
|
||||
status:faker.random.arrayElement(["FINISHED", "RELEASING", "NOT_YET_RELEASED", "CANCELLED", "HIATUS"]),
|
||||
episodes:100 + faker.datatype.number(100),
|
||||
volumes:faker.datatype.number(100),
|
||||
chapters:100 + faker.datatype.number(1000),
|
||||
averageScore:faker.datatype.number(100),
|
||||
countryOfOrigin:"JP",
|
||||
genres:new Array(6).fill(null).map(_ => faker.lorem.word()),
|
||||
coverImage:{medium:null},
|
||||
startDate:{year:faker.date.past(20).getFullYear()},
|
||||
status: faker.random.arrayElement(["FINISHED", "RELEASING", "NOT_YET_RELEASED", "CANCELLED", "HIATUS"]),
|
||||
episodes: 100 + faker.datatype.number(100),
|
||||
volumes: faker.datatype.number(100),
|
||||
chapters: 100 + faker.datatype.number(1000),
|
||||
averageScore: faker.datatype.number(100),
|
||||
countryOfOrigin: "JP",
|
||||
genres: new Array(6).fill(null).map(_ => faker.lorem.word()),
|
||||
coverImage: { medium: null },
|
||||
startDate: { year: faker.date.past(20).getFullYear() },
|
||||
})
|
||||
//User statistics query
|
||||
if (/^query Statistics /.test(query)) {
|
||||
console.debug("metrics/compute/mocks > mocking anilist api result > Statistics")
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
data:{
|
||||
User:{
|
||||
id:faker.datatype.number(100000),
|
||||
name:faker.internet.userName(),
|
||||
about:null,
|
||||
statistics:{
|
||||
anime:{
|
||||
count:faker.datatype.number(1000),
|
||||
minutesWatched:faker.datatype.number(100000),
|
||||
episodesWatched:faker.datatype.number(10000),
|
||||
genres:new Array(4).fill(null).map(_ => ({genre:faker.lorem.word()})),
|
||||
status: 200,
|
||||
data: {
|
||||
data: {
|
||||
User: {
|
||||
id: faker.datatype.number(100000),
|
||||
name: faker.internet.userName(),
|
||||
about: null,
|
||||
statistics: {
|
||||
anime: {
|
||||
count: faker.datatype.number(1000),
|
||||
minutesWatched: faker.datatype.number(100000),
|
||||
episodesWatched: faker.datatype.number(10000),
|
||||
genres: new Array(4).fill(null).map(_ => ({ genre: faker.lorem.word() })),
|
||||
},
|
||||
manga:{
|
||||
count:faker.datatype.number(1000),
|
||||
chaptersRead:faker.datatype.number(100000),
|
||||
volumesRead:faker.datatype.number(10000),
|
||||
genres:new Array(4).fill(null).map(_ => ({genre:faker.lorem.word()})),
|
||||
manga: {
|
||||
count: faker.datatype.number(1000),
|
||||
chaptersRead: faker.datatype.number(100000),
|
||||
volumesRead: faker.datatype.number(10000),
|
||||
genres: new Array(4).fill(null).map(_ => ({ genre: faker.lorem.word() })),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -51,17 +51,17 @@ export default function({faker, url, body, login = faker.internet.userName()}) {
|
||||
if (/^query FavoritesCharacters /.test(query)) {
|
||||
console.debug("metrics/compute/mocks > mocking anilist api result > Favorites characters")
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
data:{
|
||||
User:{
|
||||
favourites:{
|
||||
characters:{
|
||||
nodes:new Array(2 + faker.datatype.number(16)).fill(null).map(_ => ({
|
||||
name:{full:faker.name.findName(), native:faker.name.findName()},
|
||||
image:{medium:null},
|
||||
status: 200,
|
||||
data: {
|
||||
data: {
|
||||
User: {
|
||||
favourites: {
|
||||
characters: {
|
||||
nodes: new Array(2 + faker.datatype.number(16)).fill(null).map(_ => ({
|
||||
name: { full: faker.name.findName(), native: faker.name.findName() },
|
||||
image: { medium: null },
|
||||
})),
|
||||
pageInfo:{currentPage:1, hasNextPage:false},
|
||||
pageInfo: { currentPage: 1, hasNextPage: false },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -74,14 +74,14 @@ export default function({faker, url, body, login = faker.internet.userName()}) {
|
||||
console.debug("metrics/compute/mocks > mocking anilist api result > Favorites")
|
||||
const type = /anime[(]/.test(query) ? "ANIME" : /manga[(]/.test(query) ? "MANGA" : "OTHER"
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
data:{
|
||||
User:{
|
||||
favourites:{
|
||||
[type.toLocaleLowerCase()]:{
|
||||
nodes:new Array(16).fill(null).map(_ => media({type})),
|
||||
pageInfo:{currentPage:1, hasNextPage:false},
|
||||
status: 200,
|
||||
data: {
|
||||
data: {
|
||||
User: {
|
||||
favourites: {
|
||||
[type.toLocaleLowerCase()]: {
|
||||
nodes: new Array(16).fill(null).map(_ => media({ type })),
|
||||
pageInfo: { currentPage: 1, hasNextPage: false },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -92,24 +92,24 @@ export default function({faker, url, body, login = faker.internet.userName()}) {
|
||||
//Medias query
|
||||
if (/^query Medias /.test(query)) {
|
||||
console.debug("metrics/compute/mocks > mocking anilist api result > Medias")
|
||||
const {type} = body.variables
|
||||
const { type } = body.variables
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
data:{
|
||||
MediaListCollection:{
|
||||
lists:[
|
||||
status: 200,
|
||||
data: {
|
||||
data: {
|
||||
MediaListCollection: {
|
||||
lists: [
|
||||
{
|
||||
name:{ANIME:"Watching", MANGA:"Reading", OTHER:"Completed"}[type],
|
||||
isCustomList:false,
|
||||
entries:new Array(16).fill(null).map(_ => ({
|
||||
status:faker.random.arrayElement(["CURRENT", "PLANNING", "COMPLETED", "DROPPED", "PAUSED", "REPEATING"]),
|
||||
progress:faker.datatype.number(100),
|
||||
progressVolumes:null,
|
||||
score:0,
|
||||
startedAt:{year:null, month:null, day:null},
|
||||
completedAt:{year:null, month:null, day:null},
|
||||
media:media({type}),
|
||||
name: { ANIME: "Watching", MANGA: "Reading", OTHER: "Completed" }[type],
|
||||
isCustomList: false,
|
||||
entries: new Array(16).fill(null).map(_ => ({
|
||||
status: faker.random.arrayElement(["CURRENT", "PLANNING", "COMPLETED", "DROPPED", "PAUSED", "REPEATING"]),
|
||||
progress: faker.datatype.number(100),
|
||||
progressVolumes: null,
|
||||
score: 0,
|
||||
startedAt: { year: null, month: null, day: null },
|
||||
completedAt: { year: null, month: null, day: null },
|
||||
media: media({ type }),
|
||||
})),
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, body, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, body, login = faker.internet.userName() }) {
|
||||
if (/^https:..api.hashnode.com.*$/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking hashnode result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
data:{
|
||||
user:{
|
||||
publication:{
|
||||
posts:new Array(30).fill(null).map(_ => ({
|
||||
title:faker.lorem.sentence(),
|
||||
brief:faker.lorem.paragraph(),
|
||||
coverImage:null,
|
||||
dateAdded:faker.date.recent(),
|
||||
status: 200,
|
||||
data: {
|
||||
data: {
|
||||
user: {
|
||||
publication: {
|
||||
posts: new Array(30).fill(null).map(_ => ({
|
||||
title: faker.lorem.sentence(),
|
||||
brief: faker.lorem.paragraph(),
|
||||
coverImage: null,
|
||||
dateAdded: faker.date.recent(),
|
||||
})),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
import urls from "url"
|
||||
|
||||
/**Mocked data */
|
||||
export default function({faker, url, body, login = faker.internet.userName()}) {
|
||||
export default function({ faker, url, body, login = faker.internet.userName() }) {
|
||||
if (/^https:..accounts.spotify.com.api.token.*$/.test(url)) {
|
||||
//Access token generator
|
||||
const params = new urls.URLSearchParams(body)
|
||||
if ((params.get("grant_type") === "refresh_token") && (params.get("client_id") === "MOCKED_CLIENT_ID") && (params.get("client_secret") === "MOCKED_CLIENT_SECRET") && (params.get("refresh_token") === "MOCKED_REFRESH_TOKEN")) {
|
||||
console.debug(`metrics/compute/mocks > mocking spotify api result > ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
data:{
|
||||
access_token:"MOCKED_TOKEN_ACCESS",
|
||||
token_type:"Bearer",
|
||||
expires_in:3600,
|
||||
scope:"user-read-recently-played user-read-private",
|
||||
status: 200,
|
||||
data: {
|
||||
access_token: "MOCKED_TOKEN_ACCESS",
|
||||
token_type: "Bearer",
|
||||
expires_in: 3600,
|
||||
scope: "user-read-recently-played user-read-private",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,59 +1,58 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, url, options, login = faker.internet.userName()}) {
|
||||
if (/^https:..music.youtube.com.youtubei.v1.*$/.test(url)) {
|
||||
//Get recently played tracks
|
||||
if (/browse/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking yt music api result > ${url}`)
|
||||
const artist = faker.random.word()
|
||||
const track = faker.random.words(5)
|
||||
const artwork = faker.image.imageUrl()
|
||||
return ({
|
||||
contents:{
|
||||
singleColumnBrowseResultsRenderer:{
|
||||
tabs:[{
|
||||
tabRenderer:{
|
||||
content:{
|
||||
sectionListRenderer:{
|
||||
contents:[{
|
||||
contents:[{
|
||||
musicResponsiveListItemRenderer:{
|
||||
thumbnail:{
|
||||
musicThumbnailRenderer:{
|
||||
thumbnail:{
|
||||
thumbnails:[{
|
||||
url:artwork,
|
||||
}]
|
||||
},
|
||||
}
|
||||
},
|
||||
flexColumns:[{
|
||||
musicResponsiveListItemFlexColumnRenderer:{
|
||||
text:{
|
||||
runs:[{
|
||||
text:track,
|
||||
}]
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
musicResponsiveListItemFlexColumnRenderer:{
|
||||
text:{
|
||||
runs:[{
|
||||
text:artist,
|
||||
}]
|
||||
},
|
||||
}
|
||||
}],
|
||||
}
|
||||
}],
|
||||
}],
|
||||
},
|
||||
export default function({ faker, url, options, login = faker.internet.userName() }) {
|
||||
if (/^https:..music.youtube.com.youtubei.v1.*$/.test(url)) {
|
||||
//Get recently played tracks
|
||||
if (/browse/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking yt music api result > ${url}`)
|
||||
const artist = faker.random.word()
|
||||
const track = faker.random.words(5)
|
||||
const artwork = faker.image.imageUrl()
|
||||
return ({
|
||||
contents: {
|
||||
singleColumnBrowseResultsRenderer: {
|
||||
tabs: [{
|
||||
tabRenderer: {
|
||||
content: {
|
||||
sectionListRenderer: {
|
||||
contents: [{
|
||||
contents: [{
|
||||
musicResponsiveListItemRenderer: {
|
||||
thumbnail: {
|
||||
musicThumbnailRenderer: {
|
||||
thumbnail: {
|
||||
thumbnails: [{
|
||||
url: artwork,
|
||||
}],
|
||||
},
|
||||
},
|
||||
},
|
||||
flexColumns: [{
|
||||
musicResponsiveListItemFlexColumnRenderer: {
|
||||
text: {
|
||||
runs: [{
|
||||
text: track,
|
||||
}],
|
||||
},
|
||||
},
|
||||
}, {
|
||||
musicResponsiveListItemFlexColumnRenderer: {
|
||||
text: {
|
||||
runs: [{
|
||||
text: artist,
|
||||
}],
|
||||
},
|
||||
},
|
||||
}],
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}],
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +1,70 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > achievements/metrics")
|
||||
return ({
|
||||
user:{
|
||||
repositories:{
|
||||
nodes:[
|
||||
user: {
|
||||
repositories: {
|
||||
nodes: [
|
||||
{
|
||||
createdAt:faker.date.recent(),
|
||||
nameWithOwner:`${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
createdAt: faker.date.recent(),
|
||||
nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
},
|
||||
],
|
||||
totalCount:faker.datatype.number(100),
|
||||
totalCount: faker.datatype.number(100),
|
||||
},
|
||||
forks:{
|
||||
nodes:[
|
||||
forks: {
|
||||
nodes: [
|
||||
{
|
||||
createdAt:faker.date.recent(),
|
||||
nameWithOwner:`${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
createdAt: faker.date.recent(),
|
||||
nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
},
|
||||
],
|
||||
totalCount:faker.datatype.number(100),
|
||||
totalCount: faker.datatype.number(100),
|
||||
},
|
||||
popular:{
|
||||
nodes:[{stargazers:{totalCount:faker.datatype.number(50000)}}],
|
||||
popular: {
|
||||
nodes: [{ stargazers: { totalCount: faker.datatype.number(50000) } }],
|
||||
},
|
||||
pullRequests:{
|
||||
nodes:[
|
||||
pullRequests: {
|
||||
nodes: [
|
||||
{
|
||||
createdAt:faker.date.recent(),
|
||||
title:faker.lorem.sentence(),
|
||||
repository:{nameWithOwner:`${faker.internet.userName()}/${faker.lorem.slug()}`},
|
||||
createdAt: faker.date.recent(),
|
||||
title: faker.lorem.sentence(),
|
||||
repository: { nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}` },
|
||||
},
|
||||
],
|
||||
totalCount:faker.datatype.number(50000),
|
||||
totalCount: faker.datatype.number(50000),
|
||||
},
|
||||
contributionsCollection:{
|
||||
pullRequestReviewContributions:{
|
||||
nodes:[
|
||||
contributionsCollection: {
|
||||
pullRequestReviewContributions: {
|
||||
nodes: [
|
||||
{
|
||||
occurredAt:faker.date.recent(),
|
||||
pullRequest:{
|
||||
title:faker.lorem.sentence(),
|
||||
number:faker.datatype.number(1000),
|
||||
repository:{nameWithOwner:`${faker.internet.userName()}/${faker.lorem.slug()}`},
|
||||
occurredAt: faker.date.recent(),
|
||||
pullRequest: {
|
||||
title: faker.lorem.sentence(),
|
||||
number: faker.datatype.number(1000),
|
||||
repository: { nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}` },
|
||||
},
|
||||
},
|
||||
],
|
||||
totalCount:faker.datatype.number(1000),
|
||||
totalCount: faker.datatype.number(1000),
|
||||
},
|
||||
},
|
||||
projects:{totalCount:faker.datatype.number(100)},
|
||||
packages:{totalCount:faker.datatype.number(100)},
|
||||
organizations:{nodes:[], totalCount:faker.datatype.number(5)},
|
||||
gists:{
|
||||
nodes:[{createdAt:faker.date.recent(), name:faker.lorem.slug()}],
|
||||
totalCount:faker.datatype.number(1000),
|
||||
projects: { totalCount: faker.datatype.number(100) },
|
||||
packages: { totalCount: faker.datatype.number(100) },
|
||||
organizations: { nodes: [], totalCount: faker.datatype.number(5) },
|
||||
gists: {
|
||||
nodes: [{ createdAt: faker.date.recent(), name: faker.lorem.slug() }],
|
||||
totalCount: faker.datatype.number(1000),
|
||||
},
|
||||
starredRepositories:{totalCount:faker.datatype.number(1000)},
|
||||
followers:{totalCount:faker.datatype.number(10000)},
|
||||
following:{totalCount:faker.datatype.number(10000)},
|
||||
bio:faker.lorem.sentence(),
|
||||
status:{message:faker.lorem.paragraph()},
|
||||
sponsorshipsAsSponsor:{totalCount:faker.datatype.number(100)},
|
||||
discussionsStarted:{totalCount:faker.datatype.number(1000)},
|
||||
discussionsComments:{totalCount:faker.datatype.number(1000)},
|
||||
discussionAnswers:{totalCount:faker.datatype.number(1000)},
|
||||
starredRepositories: { totalCount: faker.datatype.number(1000) },
|
||||
followers: { totalCount: faker.datatype.number(10000) },
|
||||
following: { totalCount: faker.datatype.number(10000) },
|
||||
bio: faker.lorem.sentence(),
|
||||
status: { message: faker.lorem.paragraph() },
|
||||
sponsorshipsAsSponsor: { totalCount: faker.datatype.number(100) },
|
||||
discussionsStarted: { totalCount: faker.datatype.number(1000) },
|
||||
discussionsComments: { totalCount: faker.datatype.number(1000) },
|
||||
discussionAnswers: { totalCount: faker.datatype.number(1000) },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > achievements/metrics")
|
||||
return ({
|
||||
repository:{viewerHasStarred:faker.datatype.boolean()},
|
||||
viewer:{login},
|
||||
repository: { viewerHasStarred: faker.datatype.boolean() },
|
||||
viewer: { login },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > achievements/octocat")
|
||||
return ({
|
||||
user:{viewerIsFollowing:faker.datatype.boolean()},
|
||||
viewer:{login},
|
||||
user: { viewerIsFollowing: faker.datatype.boolean() },
|
||||
viewer: { login },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > achievements/organizations")
|
||||
return ({
|
||||
organization:{
|
||||
repositories:{
|
||||
nodes:[
|
||||
organization: {
|
||||
repositories: {
|
||||
nodes: [
|
||||
{
|
||||
createdAt:faker.date.recent(),
|
||||
nameWithOwner:`${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
createdAt: faker.date.recent(),
|
||||
nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
},
|
||||
],
|
||||
totalCount:faker.datatype.number(100),
|
||||
totalCount: faker.datatype.number(100),
|
||||
},
|
||||
forks:{
|
||||
nodes:[
|
||||
forks: {
|
||||
nodes: [
|
||||
{
|
||||
createdAt:faker.date.recent(),
|
||||
nameWithOwner:`${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
createdAt: faker.date.recent(),
|
||||
nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
},
|
||||
],
|
||||
totalCount:faker.datatype.number(100),
|
||||
totalCount: faker.datatype.number(100),
|
||||
},
|
||||
popular:{
|
||||
nodes:[{stargazers:{totalCount:faker.datatype.number(50000)}}],
|
||||
popular: {
|
||||
nodes: [{ stargazers: { totalCount: faker.datatype.number(50000) } }],
|
||||
},
|
||||
projects:{totalCount:faker.datatype.number(100)},
|
||||
packages:{totalCount:faker.datatype.number(100)},
|
||||
membersWithRole:{totalCount:faker.datatype.number(100)},
|
||||
sponsorshipsAsSponsor:{totalCount:faker.datatype.number(100)},
|
||||
projects: { totalCount: faker.datatype.number(100) },
|
||||
packages: { totalCount: faker.datatype.number(100) },
|
||||
membersWithRole: { totalCount: faker.datatype.number(100) },
|
||||
sponsorshipsAsSponsor: { totalCount: faker.datatype.number(100) },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > achievements/ranking")
|
||||
return ({
|
||||
repo_rank:{repositoryCount:faker.datatype.number(100000)},
|
||||
forks_rank:{repositoryCount:faker.datatype.number(100000)},
|
||||
created_rank:{userCount:faker.datatype.number(100000)},
|
||||
user_rank:{userCount:faker.datatype.number(100000)},
|
||||
repo_total:{repositoryCount:faker.datatype.number(100000)},
|
||||
user_total:{userCount:faker.datatype.number(100000)},
|
||||
repo_rank: { repositoryCount: faker.datatype.number(100000) },
|
||||
forks_rank: { repositoryCount: faker.datatype.number(100000) },
|
||||
created_rank: { userCount: faker.datatype.number(100000) },
|
||||
user_rank: { userCount: faker.datatype.number(100000) },
|
||||
repo_total: { repositoryCount: faker.datatype.number(100000) },
|
||||
user_total: { userCount: faker.datatype.number(100000) },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user:{
|
||||
calendar:{
|
||||
contributionCalendar:{
|
||||
weeks:[
|
||||
user: {
|
||||
calendar: {
|
||||
contributionCalendar: {
|
||||
weeks: [
|
||||
{
|
||||
contributionDays:[
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
contributionDays: [
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
],
|
||||
},
|
||||
{
|
||||
contributionDays:[
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
contributionDays: [
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
],
|
||||
},
|
||||
{
|
||||
contributionDays:[
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
{color:faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"])},
|
||||
contributionDays: [
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
{ color: faker.random.arrayElement(["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]) },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user:{
|
||||
contributionsCollection:{
|
||||
totalRepositoriesWithContributedCommits:faker.datatype.number(100),
|
||||
totalCommitContributions:faker.datatype.number(10000),
|
||||
restrictedContributionsCount:faker.datatype.number(10000),
|
||||
totalIssueContributions:faker.datatype.number(100),
|
||||
totalPullRequestContributions:faker.datatype.number(1000),
|
||||
totalPullRequestReviewContributions:faker.datatype.number(1000),
|
||||
user: {
|
||||
contributionsCollection: {
|
||||
totalRepositoriesWithContributedCommits: faker.datatype.number(100),
|
||||
totalCommitContributions: faker.datatype.number(10000),
|
||||
restrictedContributionsCount: faker.datatype.number(10000),
|
||||
totalIssueContributions: faker.datatype.number(100),
|
||||
totalPullRequestContributions: faker.datatype.number(1000),
|
||||
totalPullRequestReviewContributions: faker.datatype.number(1000),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user:{
|
||||
packages:{totalCount:faker.datatype.number(10)},
|
||||
starredRepositories:{totalCount:faker.datatype.number(1000)},
|
||||
watching:{totalCount:faker.datatype.number(100)},
|
||||
sponsorshipsAsSponsor:{totalCount:faker.datatype.number(10)},
|
||||
sponsorshipsAsMaintainer:{totalCount:faker.datatype.number(10)},
|
||||
repositoriesContributedTo:{totalCount:faker.datatype.number(100)},
|
||||
followers:{totalCount:faker.datatype.number(1000)},
|
||||
following:{totalCount:faker.datatype.number(1000)},
|
||||
issueComments:{totalCount:faker.datatype.number(1000)},
|
||||
organizations:{totalCount:faker.datatype.number(10)},
|
||||
user: {
|
||||
packages: { totalCount: faker.datatype.number(10) },
|
||||
starredRepositories: { totalCount: faker.datatype.number(1000) },
|
||||
watching: { totalCount: faker.datatype.number(100) },
|
||||
sponsorshipsAsSponsor: { totalCount: faker.datatype.number(10) },
|
||||
sponsorshipsAsMaintainer: { totalCount: faker.datatype.number(10) },
|
||||
repositoriesContributedTo: { totalCount: faker.datatype.number(100) },
|
||||
followers: { totalCount: faker.datatype.number(1000) },
|
||||
following: { totalCount: faker.datatype.number(1000) },
|
||||
issueComments: { totalCount: faker.datatype.number(1000) },
|
||||
organizations: { totalCount: faker.datatype.number(10) },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user:{
|
||||
repositories:{totalCount:faker.datatype.number(100), totalDiskUsage:faker.datatype.number(100000)},
|
||||
user: {
|
||||
repositories: { totalCount: faker.datatype.number(100), totalDiskUsage: faker.datatype.number(100000) },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/repositories")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user:{
|
||||
user: {
|
||||
get repositoriesContributedTo() {
|
||||
return this.repositories
|
||||
},
|
||||
repositories:{
|
||||
edges:[],
|
||||
nodes:[],
|
||||
repositories: {
|
||||
edges: [],
|
||||
nodes: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
: ({
|
||||
user:{
|
||||
user: {
|
||||
get repositoriesContributedTo() {
|
||||
return this.repositories
|
||||
},
|
||||
repositories:{
|
||||
edges:[
|
||||
repositories: {
|
||||
edges: [
|
||||
{
|
||||
cursor:"MOCKED_CURSOR",
|
||||
cursor: "MOCKED_CURSOR",
|
||||
},
|
||||
],
|
||||
nodes:[
|
||||
nodes: [
|
||||
{
|
||||
name:faker.random.words(),
|
||||
watchers:{totalCount:faker.datatype.number(1000)},
|
||||
stargazers:{totalCount:faker.datatype.number(10000)},
|
||||
owner:{login},
|
||||
languages:{
|
||||
edges:[
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
name: faker.random.words(),
|
||||
watchers: { totalCount: faker.datatype.number(1000) },
|
||||
stargazers: { totalCount: faker.datatype.number(10000) },
|
||||
owner: { login },
|
||||
languages: {
|
||||
edges: [
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
],
|
||||
},
|
||||
issues_open:{totalCount:faker.datatype.number(100)},
|
||||
issues_closed:{totalCount:faker.datatype.number(100)},
|
||||
pr_open:{totalCount:faker.datatype.number(100)},
|
||||
pr_closed:{totalCount:faker.datatype.number(100)},
|
||||
pr_merged:{totalCount:faker.datatype.number(100)},
|
||||
releases:{totalCount:faker.datatype.number(100)},
|
||||
forkCount:faker.datatype.number(100),
|
||||
licenseInfo:{spdxId:"MIT"},
|
||||
deployments:{totalCount:faker.datatype.number(100)},
|
||||
environments:{totalCount:faker.datatype.number(100)},
|
||||
issues_open: { totalCount: faker.datatype.number(100) },
|
||||
issues_closed: { totalCount: faker.datatype.number(100) },
|
||||
pr_open: { totalCount: faker.datatype.number(100) },
|
||||
pr_closed: { totalCount: faker.datatype.number(100) },
|
||||
pr_merged: { totalCount: faker.datatype.number(100) },
|
||||
releases: { totalCount: faker.datatype.number(100) },
|
||||
forkCount: faker.datatype.number(100),
|
||||
licenseInfo: { spdxId: "MIT" },
|
||||
deployments: { totalCount: faker.datatype.number(100) },
|
||||
environments: { totalCount: faker.datatype.number(100) },
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/repository")
|
||||
return ({
|
||||
user:{
|
||||
repository:{
|
||||
name:"metrics",
|
||||
owner:{login},
|
||||
createdAt:new Date().toISOString(),
|
||||
diskUsage:Math.floor(Math.random() * 10000),
|
||||
homepageUrl:faker.internet.url(),
|
||||
watchers:{totalCount:faker.datatype.number(1000)},
|
||||
stargazers:{totalCount:faker.datatype.number(10000)},
|
||||
languages:{
|
||||
edges:[
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
{size:faker.datatype.number(100000), node:{color:faker.internet.color(), name:faker.lorem.word()}},
|
||||
user: {
|
||||
repository: {
|
||||
name: "metrics",
|
||||
owner: { login },
|
||||
createdAt: new Date().toISOString(),
|
||||
diskUsage: Math.floor(Math.random() * 10000),
|
||||
homepageUrl: faker.internet.url(),
|
||||
watchers: { totalCount: faker.datatype.number(1000) },
|
||||
stargazers: { totalCount: faker.datatype.number(10000) },
|
||||
languages: {
|
||||
edges: [
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
{ size: faker.datatype.number(100000), node: { color: faker.internet.color(), name: faker.lorem.word() } },
|
||||
],
|
||||
},
|
||||
issues_open:{totalCount:faker.datatype.number(100)},
|
||||
issues_closed:{totalCount:faker.datatype.number(100)},
|
||||
pr_open:{totalCount:faker.datatype.number(100)},
|
||||
pr_closed:{totalCount:faker.datatype.number(100)},
|
||||
pr_merged:{totalCount:faker.datatype.number(100)},
|
||||
releases:{totalCount:faker.datatype.number(100)},
|
||||
forkCount:faker.datatype.number(100),
|
||||
licenseInfo:{spdxId:"MIT"},
|
||||
deployments:{totalCount:faker.datatype.number(100)},
|
||||
environments:{totalCount:faker.datatype.number(100)},
|
||||
issues_open: { totalCount: faker.datatype.number(100) },
|
||||
issues_closed: { totalCount: faker.datatype.number(100) },
|
||||
pr_open: { totalCount: faker.datatype.number(100) },
|
||||
pr_closed: { totalCount: faker.datatype.number(100) },
|
||||
pr_merged: { totalCount: faker.datatype.number(100) },
|
||||
releases: { totalCount: faker.datatype.number(100) },
|
||||
forkCount: faker.datatype.number(100),
|
||||
licenseInfo: { spdxId: "MIT" },
|
||||
deployments: { totalCount: faker.datatype.number(100) },
|
||||
environments: { totalCount: faker.datatype.number(100) },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > base/user")
|
||||
return ({
|
||||
user:{
|
||||
databaseId:faker.datatype.number(10000000),
|
||||
name:faker.name.findName(),
|
||||
user: {
|
||||
databaseId: faker.datatype.number(10000000),
|
||||
name: faker.name.findName(),
|
||||
login,
|
||||
createdAt:`${faker.date.past(10)}`,
|
||||
avatarUrl:faker.image.people(),
|
||||
websiteUrl:faker.internet.url(),
|
||||
isHireable:faker.datatype.boolean(),
|
||||
twitterUsername:login,
|
||||
createdAt: `${faker.date.past(10)}`,
|
||||
avatarUrl: faker.image.people(),
|
||||
websiteUrl: faker.internet.url(),
|
||||
isHireable: faker.datatype.boolean(),
|
||||
twitterUsername: login,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > contributors/commit")
|
||||
return ({
|
||||
repository:{
|
||||
object:{
|
||||
oid:"MOCKED_SHA",
|
||||
abbreviatedOid:"MOCKED_SHA",
|
||||
messageHeadline:faker.lorem.sentence(),
|
||||
committedDate:faker.date.recent(),
|
||||
repository: {
|
||||
object: {
|
||||
oid: "MOCKED_SHA",
|
||||
abbreviatedOid: "MOCKED_SHA",
|
||||
messageHeadline: faker.lorem.sentence(),
|
||||
committedDate: faker.date.recent(),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > discussions/categories")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user:{
|
||||
repositoryDiscussions:{
|
||||
edges:[],
|
||||
nodes:[],
|
||||
}
|
||||
}
|
||||
user: {
|
||||
repositoryDiscussions: {
|
||||
edges: [],
|
||||
nodes: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
: ({
|
||||
user:{
|
||||
repositoryDiscussions:{
|
||||
edges:new Array(100).fill(null).map(_ => ({cursor:"MOCKED_CURSOR"})),
|
||||
nodes:new Array(100).fill(null).map(_ => ({
|
||||
category:{
|
||||
emoji:faker.random.arrayElement([":chart_with_upwards_trend:", ":chart_with_downwards_trend:", ":bar_char:"]),
|
||||
name:faker.lorem.slug()
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
user: {
|
||||
repositoryDiscussions: {
|
||||
edges: new Array(100).fill(null).map(_ => ({ cursor: "MOCKED_CURSOR" })),
|
||||
nodes: new Array(100).fill(null).map(_ => ({
|
||||
category: {
|
||||
emoji: faker.random.arrayElement([":chart_with_upwards_trend:", ":chart_with_downwards_trend:", ":bar_char:"]),
|
||||
name: faker.lorem.slug(),
|
||||
},
|
||||
})),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > discussions/comments")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user:{
|
||||
repositoryDiscussionsComments:{
|
||||
edges:[],
|
||||
nodes:[],
|
||||
}
|
||||
}
|
||||
user: {
|
||||
repositoryDiscussionsComments: {
|
||||
edges: [],
|
||||
nodes: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
: ({
|
||||
user:{
|
||||
repositoryDiscussionsComments:{
|
||||
edges:new Array(100).fill(null).map(_ => ({cursor:"MOCKED_CURSOR"})),
|
||||
nodes:new Array(100).fill(null).map(_ => ({upvoteCount: faker.datatype.number(10)}))
|
||||
}
|
||||
}
|
||||
user: {
|
||||
repositoryDiscussionsComments: {
|
||||
edges: new Array(100).fill(null).map(_ => ({ cursor: "MOCKED_CURSOR" })),
|
||||
nodes: new Array(100).fill(null).map(_ => ({ upvoteCount: faker.datatype.number(10) })),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > discussions/statistics")
|
||||
return ({
|
||||
user:{
|
||||
started:{totalCount:faker.datatype.number(1000)},
|
||||
comments:{totalCount:faker.datatype.number(1000)},
|
||||
answers:{totalCount:faker.datatype.number(1000)}
|
||||
}
|
||||
user: {
|
||||
started: { totalCount: faker.datatype.number(1000) },
|
||||
comments: { totalCount: faker.datatype.number(1000) },
|
||||
answers: { totalCount: faker.datatype.number(1000) },
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > followup/repository/collaborators")
|
||||
return ({
|
||||
repository:{
|
||||
collaborators:{
|
||||
nodes:["github-user"]
|
||||
}
|
||||
repository: {
|
||||
collaborators: {
|
||||
nodes: ["github-user"],
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > followup/repository")
|
||||
return ({
|
||||
issues_open:{issueCount:faker.datatype.number(100)},
|
||||
issues_drafts:{issueCount:faker.datatype.number(100)},
|
||||
issues_skipped:{issueCount:faker.datatype.number(100)},
|
||||
issues_closed:{issueCount:faker.datatype.number(100)},
|
||||
pr_open:{issueCount:faker.datatype.number(100)},
|
||||
pr_drafts:{issueCount:faker.datatype.number(100)},
|
||||
pr_closed:{issueCount:faker.datatype.number(100)},
|
||||
pr_merged:{issueCount:faker.datatype.number(100)},
|
||||
issues_open: { issueCount: faker.datatype.number(100) },
|
||||
issues_drafts: { issueCount: faker.datatype.number(100) },
|
||||
issues_skipped: { issueCount: faker.datatype.number(100) },
|
||||
issues_closed: { issueCount: faker.datatype.number(100) },
|
||||
pr_open: { issueCount: faker.datatype.number(100) },
|
||||
pr_drafts: { issueCount: faker.datatype.number(100) },
|
||||
pr_closed: { issueCount: faker.datatype.number(100) },
|
||||
pr_merged: { issueCount: faker.datatype.number(100) },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > followup/user")
|
||||
return ({
|
||||
issues_open:{issueCount:faker.datatype.number(100)},
|
||||
issues_drafts:{issueCount:faker.datatype.number(100)},
|
||||
issues_skipped:{issueCount:faker.datatype.number(100)},
|
||||
issues_closed:{issueCount:faker.datatype.number(100)},
|
||||
pr_open:{issueCount:faker.datatype.number(100)},
|
||||
pr_drafts:{issueCount:faker.datatype.number(100)},
|
||||
pr_closed:{issueCount:faker.datatype.number(100)},
|
||||
pr_merged:{issueCount:faker.datatype.number(100)},
|
||||
issues_open: { issueCount: faker.datatype.number(100) },
|
||||
issues_drafts: { issueCount: faker.datatype.number(100) },
|
||||
issues_skipped: { issueCount: faker.datatype.number(100) },
|
||||
issues_closed: { issueCount: faker.datatype.number(100) },
|
||||
pr_open: { issueCount: faker.datatype.number(100) },
|
||||
pr_drafts: { issueCount: faker.datatype.number(100) },
|
||||
pr_closed: { issueCount: faker.datatype.number(100) },
|
||||
pr_merged: { issueCount: faker.datatype.number(100) },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > gists/default")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user:{
|
||||
gists:{
|
||||
edges:[],
|
||||
nodes:[],
|
||||
user: {
|
||||
gists: {
|
||||
edges: [],
|
||||
nodes: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
: ({
|
||||
user:{
|
||||
gists:{
|
||||
edges:[
|
||||
user: {
|
||||
gists: {
|
||||
edges: [
|
||||
{
|
||||
cursor:"MOCKED_CURSOR",
|
||||
cursor: "MOCKED_CURSOR",
|
||||
},
|
||||
],
|
||||
totalCount:faker.datatype.number(100),
|
||||
nodes:[
|
||||
totalCount: faker.datatype.number(100),
|
||||
nodes: [
|
||||
{
|
||||
stargazerCount:faker.datatype.number(10),
|
||||
isFork:false,
|
||||
forks:{totalCount:faker.datatype.number(10)},
|
||||
files:[{name:faker.system.fileName()}],
|
||||
comments:{totalCount:faker.datatype.number(10)},
|
||||
stargazerCount: faker.datatype.number(10),
|
||||
isFork: false,
|
||||
forks: { totalCount: faker.datatype.number(10) },
|
||||
files: [{ name: faker.system.fileName() }],
|
||||
comments: { totalCount: faker.datatype.number(10) },
|
||||
},
|
||||
{
|
||||
stargazerCount:faker.datatype.number(10),
|
||||
isFork:false,
|
||||
forks:{totalCount:faker.datatype.number(10)},
|
||||
files:[{name:faker.system.fileName()}],
|
||||
comments:{totalCount:faker.datatype.number(10)},
|
||||
stargazerCount: faker.datatype.number(10),
|
||||
isFork: false,
|
||||
forks: { totalCount: faker.datatype.number(10) },
|
||||
files: [{ name: faker.system.fileName() }],
|
||||
comments: { totalCount: faker.datatype.number(10) },
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > introduction/organization")
|
||||
return ({
|
||||
organization:{
|
||||
description:faker.lorem.sentences(),
|
||||
organization: {
|
||||
description: faker.lorem.sentences(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > introduction/repository")
|
||||
return ({
|
||||
repository:{
|
||||
description:faker.lorem.sentences(),
|
||||
repository: {
|
||||
description: faker.lorem.sentences(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > introduction/user")
|
||||
return ({
|
||||
user:{
|
||||
bio:faker.lorem.sentences(),
|
||||
user: {
|
||||
bio: faker.lorem.sentences(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > isocalendar/calendar")
|
||||
//Generate calendar
|
||||
const date = new Date(query.match(/from: "(?<date>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z)"/)?.groups?.date)
|
||||
@@ -9,21 +9,21 @@ export default function({faker, query, login = faker.internet.userName()}) {
|
||||
for (; date <= to; date.setDate(date.getDate() + 1)) {
|
||||
//Create new week on sunday
|
||||
if (date.getDay() === 0) {
|
||||
weeks.push({contributionDays})
|
||||
weeks.push({ contributionDays })
|
||||
contributionDays = []
|
||||
}
|
||||
//Random contributions
|
||||
const contributionCount = Math.min(10, Math.max(0, faker.datatype.number(14) - 4))
|
||||
contributionDays.push({
|
||||
contributionCount,
|
||||
color:["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"][Math.ceil(contributionCount / 10 / 0.25)],
|
||||
date:date.toISOString().substring(0, 10),
|
||||
color: ["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"][Math.ceil(contributionCount / 10 / 0.25)],
|
||||
date: date.toISOString().substring(0, 10),
|
||||
})
|
||||
}
|
||||
return ({
|
||||
user:{
|
||||
calendar:{
|
||||
contributionCalendar:{
|
||||
user: {
|
||||
calendar: {
|
||||
contributionCalendar: {
|
||||
weeks,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,276 +1,276 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > licenses/default")
|
||||
return ({
|
||||
licenses:[
|
||||
licenses: [
|
||||
{
|
||||
spdxId:"AGPL-3.0",
|
||||
name:"GNU Affero General Public License v3.0",
|
||||
nickname:"GNU AGPLv3",
|
||||
key:"agpl-3.0",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "AGPL-3.0",
|
||||
name: "GNU Affero General Public License v3.0",
|
||||
nickname: "GNU AGPLv3",
|
||||
key: "agpl-3.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"include-copyright", label:"License and copyright notice"},
|
||||
{key:"document-changes", label:"State changes"},
|
||||
{key:"disclose-source", label:"Disclose source"},
|
||||
{key:"network-use-disclose", label:"Network use is distribution"},
|
||||
{key:"same-license", label:"Same license"},
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "document-changes", label: "State changes" },
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "network-use-disclose", label: "Network use is distribution" },
|
||||
{ key: "same-license", label: "Same license" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"patent-use", label:"Patent use"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"Apache-2.0",
|
||||
name:"Apache License 2.0",
|
||||
nickname:null,
|
||||
key:"apache-2.0",
|
||||
limitations:[
|
||||
{key:"trademark-use", label:"Trademark use"},
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "Apache-2.0",
|
||||
name: "Apache License 2.0",
|
||||
nickname: null,
|
||||
key: "apache-2.0",
|
||||
limitations: [
|
||||
{ key: "trademark-use", label: "Trademark use" },
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"include-copyright", label:"License and copyright notice"},
|
||||
{key:"document-changes", label:"State changes"},
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "document-changes", label: "State changes" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"patent-use", label:"Patent use"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"BSD-2-Clause",
|
||||
name:'BSD 2-Clause "Simplified" License',
|
||||
nickname:null,
|
||||
key:"bsd-2-clause",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "BSD-2-Clause",
|
||||
name: 'BSD 2-Clause "Simplified" License',
|
||||
nickname: null,
|
||||
key: "bsd-2-clause",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"include-copyright", label:"License and copyright notice"},
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"BSD-3-Clause",
|
||||
name:'BSD 3-Clause "New" or "Revised" License',
|
||||
nickname:null,
|
||||
key:"bsd-3-clause",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "BSD-3-Clause",
|
||||
name: 'BSD 3-Clause "New" or "Revised" License',
|
||||
nickname: null,
|
||||
key: "bsd-3-clause",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"include-copyright", label:"License and copyright notice"},
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"BSL-1.0",
|
||||
name:"Boost Software License 1.0",
|
||||
nickname:null,
|
||||
key:"bsl-1.0",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "BSL-1.0",
|
||||
name: "Boost Software License 1.0",
|
||||
nickname: null,
|
||||
key: "bsl-1.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"include-copyright--source", label:"License and copyright notice for source"},
|
||||
conditions: [
|
||||
{ key: "include-copyright--source", label: "License and copyright notice for source" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"CC0-1.0",
|
||||
name:"Creative Commons Zero v1.0 Universal",
|
||||
nickname:null,
|
||||
key:"cc0-1.0",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"trademark-use", label:"Trademark use"},
|
||||
{key:"patent-use", label:"Patent use"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "CC0-1.0",
|
||||
name: "Creative Commons Zero v1.0 Universal",
|
||||
nickname: null,
|
||||
key: "cc0-1.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "trademark-use", label: "Trademark use" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
conditions: [],
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"EPL-2.0",
|
||||
name:"Eclipse Public License 2.0",
|
||||
nickname:null,
|
||||
key:"epl-2.0",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "EPL-2.0",
|
||||
name: "Eclipse Public License 2.0",
|
||||
nickname: null,
|
||||
key: "epl-2.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"disclose-source", label:"Disclose source"},
|
||||
{key:"include-copyright", label:"License and copyright notice"},
|
||||
{key:"same-license", label:"Same license"},
|
||||
conditions: [
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "same-license", label: "Same license" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"patent-use", label:"Patent use"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"GPL-2.0",
|
||||
name:"GNU General Public License v2.0",
|
||||
nickname:"GNU GPLv2",
|
||||
key:"gpl-2.0",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "GPL-2.0",
|
||||
name: "GNU General Public License v2.0",
|
||||
nickname: "GNU GPLv2",
|
||||
key: "gpl-2.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"include-copyright", label:"License and copyright notice"},
|
||||
{key:"document-changes", label:"State changes"},
|
||||
{key:"disclose-source", label:"Disclose source"},
|
||||
{key:"same-license", label:"Same license"},
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "document-changes", label: "State changes" },
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "same-license", label: "Same license" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"GPL-3.0",
|
||||
name:"GNU General Public License v3.0",
|
||||
nickname:"GNU GPLv3",
|
||||
key:"gpl-3.0",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "GPL-3.0",
|
||||
name: "GNU General Public License v3.0",
|
||||
nickname: "GNU GPLv3",
|
||||
key: "gpl-3.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"include-copyright", label:"License and copyright notice"},
|
||||
{key:"document-changes", label:"State changes"},
|
||||
{key:"disclose-source", label:"Disclose source"},
|
||||
{key:"same-license", label:"Same license"},
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "document-changes", label: "State changes" },
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "same-license", label: "Same license" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"patent-use", label:"Patent use"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"LGPL-2.1",
|
||||
name:"GNU Lesser General Public License v2.1",
|
||||
nickname:"GNU LGPLv2.1",
|
||||
key:"lgpl-2.1",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "LGPL-2.1",
|
||||
name: "GNU Lesser General Public License v2.1",
|
||||
nickname: "GNU LGPLv2.1",
|
||||
key: "lgpl-2.1",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"include-copyright", label:"License and copyright notice"},
|
||||
{key:"disclose-source", label:"Disclose source"},
|
||||
{key:"document-changes", label:"State changes"},
|
||||
{key:"same-license--library", label:"Same license (library)"},
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "document-changes", label: "State changes" },
|
||||
{ key: "same-license--library", label: "Same license (library)" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"MIT",
|
||||
name:"MIT License",
|
||||
nickname:null,
|
||||
key:"mit",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "MIT",
|
||||
name: "MIT License",
|
||||
nickname: null,
|
||||
key: "mit",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"include-copyright", label:"License and copyright notice"},
|
||||
conditions: [
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"MPL-2.0",
|
||||
name:"Mozilla Public License 2.0",
|
||||
nickname:null,
|
||||
key:"mpl-2.0",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"trademark-use", label:"Trademark use"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "MPL-2.0",
|
||||
name: "Mozilla Public License 2.0",
|
||||
nickname: null,
|
||||
key: "mpl-2.0",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "trademark-use", label: "Trademark use" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[
|
||||
{key:"disclose-source", label:"Disclose source"},
|
||||
{key:"include-copyright", label:"License and copyright notice"},
|
||||
{key:"same-license--file", label:"Same license (file)"},
|
||||
conditions: [
|
||||
{ key: "disclose-source", label: "Disclose source" },
|
||||
{ key: "include-copyright", label: "License and copyright notice" },
|
||||
{ key: "same-license--file", label: "Same license (file)" },
|
||||
],
|
||||
permissions:[
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
{key:"patent-use", label:"Patent use"},
|
||||
{key:"private-use", label:"Private use"},
|
||||
permissions: [
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
{ key: "patent-use", label: "Patent use" },
|
||||
{ key: "private-use", label: "Private use" },
|
||||
],
|
||||
},
|
||||
{
|
||||
spdxId:"Unlicense",
|
||||
name:"The Unlicense",
|
||||
nickname:null,
|
||||
key:"unlicense",
|
||||
limitations:[
|
||||
{key:"liability", label:"Liability"},
|
||||
{key:"warranty", label:"Warranty"},
|
||||
spdxId: "Unlicense",
|
||||
name: "The Unlicense",
|
||||
nickname: null,
|
||||
key: "unlicense",
|
||||
limitations: [
|
||||
{ key: "liability", label: "Liability" },
|
||||
{ key: "warranty", label: "Warranty" },
|
||||
],
|
||||
conditions:[],
|
||||
permissions:[
|
||||
{key:"private-use", label:"Private use"},
|
||||
{key:"commercial-use", label:"Commercial use"},
|
||||
{key:"modifications", label:"Modification"},
|
||||
{key:"distribution", label:"Distribution"},
|
||||
conditions: [],
|
||||
permissions: [
|
||||
{ key: "private-use", label: "Private use" },
|
||||
{ key: "commercial-use", label: "Commercial use" },
|
||||
{ key: "modifications", label: "Modification" },
|
||||
{ key: "distribution", label: "Distribution" },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > licenses/repository")
|
||||
return ({
|
||||
user:{
|
||||
repository:{
|
||||
licenseInfo:{spdxId:"MIT", name:"MIT License", nickname:null, key:"mit"},
|
||||
url:"https://github.com/lowlighter/metrics",
|
||||
databaseId:293860197,
|
||||
user: {
|
||||
repository: {
|
||||
licenseInfo: { spdxId: "MIT", name: "MIT License", nickname: null, key: "mit" },
|
||||
url: "https://github.com/lowlighter/metrics",
|
||||
databaseId: 293860197,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > notable/contributions")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user:{
|
||||
repositoriesContributedTo:{
|
||||
edges:[],
|
||||
user: {
|
||||
repositoriesContributedTo: {
|
||||
edges: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
: ({
|
||||
user:{
|
||||
repositoriesContributedTo:{
|
||||
edges:[
|
||||
user: {
|
||||
repositoriesContributedTo: {
|
||||
edges: [
|
||||
{
|
||||
cursor:"MOCKED_CURSOR",
|
||||
node:{
|
||||
isInOrganization:true,
|
||||
owner:{
|
||||
login:faker.internet.userName(),
|
||||
avatarUrl:null,
|
||||
cursor: "MOCKED_CURSOR",
|
||||
node: {
|
||||
isInOrganization: true,
|
||||
owner: {
|
||||
login: faker.internet.userName(),
|
||||
avatarUrl: null,
|
||||
},
|
||||
nameWithOwner:`${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
stargazers:{totalCount:faker.datatype.number(1000)},
|
||||
watchers:{totalCount:faker.datatype.number(1000)},
|
||||
forks:{totalCount:faker.datatype.number(1000)},
|
||||
nameWithOwner: `${faker.internet.userName()}/${faker.lorem.slug()}`,
|
||||
stargazers: { totalCount: faker.datatype.number(1000) },
|
||||
watchers: { totalCount: faker.datatype.number(1000) },
|
||||
forks: { totalCount: faker.datatype.number(1000) },
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > people/default")
|
||||
const type = query.match(/(?<type>followers|following)[(]/)?.groups?.type ?? "(unknown type)"
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user:{
|
||||
[type]:{
|
||||
edges:[],
|
||||
user: {
|
||||
[type]: {
|
||||
edges: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
: ({
|
||||
user:{
|
||||
[type]:{
|
||||
edges:new Array(Math.ceil(20 + 80 * Math.random())).fill(null).map((login = faker.internet.userName()) => ({
|
||||
cursor:"MOCKED_CURSOR",
|
||||
node:{
|
||||
user: {
|
||||
[type]: {
|
||||
edges: new Array(Math.ceil(20 + 80 * Math.random())).fill(null).map((login = faker.internet.userName()) => ({
|
||||
cursor: "MOCKED_CURSOR",
|
||||
node: {
|
||||
login,
|
||||
avatarUrl:null,
|
||||
avatarUrl: null,
|
||||
},
|
||||
})),
|
||||
},
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > people/repository")
|
||||
const type = query.match(/(?<type>stargazers|watchers)[(]/)?.groups?.type ?? "(unknown type)"
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user:{
|
||||
repository:{
|
||||
[type]:{
|
||||
edges:[],
|
||||
user: {
|
||||
repository: {
|
||||
[type]: {
|
||||
edges: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
: ({
|
||||
user:{
|
||||
repository:{
|
||||
[type]:{
|
||||
edges:new Array(Math.ceil(20 + 80 * Math.random())).fill(null).map((login = faker.internet.userName()) => ({
|
||||
cursor:"MOCKED_CURSOR",
|
||||
node:{
|
||||
user: {
|
||||
repository: {
|
||||
[type]: {
|
||||
edges: new Array(Math.ceil(20 + 80 * Math.random())).fill(null).map((login = faker.internet.userName()) => ({
|
||||
cursor: "MOCKED_CURSOR",
|
||||
node: {
|
||||
login,
|
||||
avatarUrl:null,
|
||||
avatarUrl: null,
|
||||
},
|
||||
})),
|
||||
},
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > people/sponsors")
|
||||
const type = query.match(/(?<type>sponsorshipsAsSponsor|sponsorshipsAsMaintainer)[(]/)?.groups?.type ?? "(unknown type)"
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user:{
|
||||
user: {
|
||||
login,
|
||||
[type]:{
|
||||
edges:[],
|
||||
[type]: {
|
||||
edges: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
: ({
|
||||
user:{
|
||||
user: {
|
||||
login,
|
||||
[type]:{
|
||||
edges:new Array(Math.ceil(20 + 80 * Math.random())).fill(null).map((login = faker.internet.userName()) => ({
|
||||
cursor:"MOCKED_CURSOR",
|
||||
node:{
|
||||
sponsorEntity:{
|
||||
login:faker.internet.userName(),
|
||||
avatarUrl:null,
|
||||
[type]: {
|
||||
edges: new Array(Math.ceil(20 + 80 * Math.random())).fill(null).map((login = faker.internet.userName()) => ({
|
||||
cursor: "MOCKED_CURSOR",
|
||||
node: {
|
||||
sponsorEntity: {
|
||||
login: faker.internet.userName(),
|
||||
avatarUrl: null,
|
||||
},
|
||||
sponsorable:{
|
||||
login:faker.internet.userName(),
|
||||
avatarUrl:null,
|
||||
sponsorable: {
|
||||
login: faker.internet.userName(),
|
||||
avatarUrl: null,
|
||||
},
|
||||
},
|
||||
})),
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > projects/repository")
|
||||
return ({
|
||||
user:{
|
||||
repository:{
|
||||
project:{
|
||||
name:"Repository project example",
|
||||
updatedAt:`${faker.date.recent()}`,
|
||||
body:faker.lorem.paragraph(),
|
||||
progress:{
|
||||
doneCount:faker.datatype.number(10),
|
||||
inProgressCount:faker.datatype.number(10),
|
||||
todoCount:faker.datatype.number(10),
|
||||
enabled:true,
|
||||
user: {
|
||||
repository: {
|
||||
project: {
|
||||
name: "Repository project example",
|
||||
updatedAt: `${faker.date.recent()}`,
|
||||
body: faker.lorem.paragraph(),
|
||||
progress: {
|
||||
doneCount: faker.datatype.number(10),
|
||||
inProgressCount: faker.datatype.number(10),
|
||||
todoCount: faker.datatype.number(10),
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > projects/user")
|
||||
return ({
|
||||
user:{
|
||||
projects:{
|
||||
totalCount:1,
|
||||
nodes:[
|
||||
user: {
|
||||
projects: {
|
||||
totalCount: 1,
|
||||
nodes: [
|
||||
{
|
||||
name:"User-owned project",
|
||||
updatedAt:`${faker.date.recent()}`,
|
||||
body:faker.lorem.paragraph(),
|
||||
progress:{
|
||||
doneCount:faker.datatype.number(10),
|
||||
inProgressCount:faker.datatype.number(10),
|
||||
todoCount:faker.datatype.number(10),
|
||||
enabled:true,
|
||||
name: "User-owned project",
|
||||
updatedAt: `${faker.date.recent()}`,
|
||||
body: faker.lorem.paragraph(),
|
||||
progress: {
|
||||
doneCount: faker.datatype.number(10),
|
||||
inProgressCount: faker.datatype.number(10),
|
||||
todoCount: faker.datatype.number(10),
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > reactions/default")
|
||||
const type = query.match(/(?<type>issues|issueComments)[(]/)?.groups?.type ?? "(unknown type)"
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
user:{
|
||||
[type]:{
|
||||
edges:[],
|
||||
nodes:[],
|
||||
user: {
|
||||
[type]: {
|
||||
edges: [],
|
||||
nodes: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
: ({
|
||||
user:{
|
||||
[type]:{
|
||||
edges:new Array(100).fill(null).map(_ => ({
|
||||
cursor:"MOCKED_CURSOR",
|
||||
node:{
|
||||
createdAt:faker.date.recent(),
|
||||
reactions:{
|
||||
nodes:new Array(50).fill(null).map(_ => ({
|
||||
user:{login:faker.internet.userName()},
|
||||
content:faker.random.arrayElement(["HEART", "THUMBS_UP", "THUMBS_DOWN", "LAUGH", "CONFUSED", "EYES", "ROCKET", "HOORAY"]),
|
||||
user: {
|
||||
[type]: {
|
||||
edges: new Array(100).fill(null).map(_ => ({
|
||||
cursor: "MOCKED_CURSOR",
|
||||
node: {
|
||||
createdAt: faker.date.recent(),
|
||||
reactions: {
|
||||
nodes: new Array(50).fill(null).map(_ => ({
|
||||
user: { login: faker.internet.userName() },
|
||||
content: faker.random.arrayElement(["HEART", "THUMBS_UP", "THUMBS_DOWN", "LAUGH", "CONFUSED", "EYES", "ROCKET", "HOORAY"]),
|
||||
})),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > stars/default")
|
||||
return ({
|
||||
repository:{
|
||||
repository: {
|
||||
createdAt: faker.date.past(),
|
||||
description:"📊 An image generator with 20+ metrics about your GitHub account such as activity, community, repositories, coding habits, website performances, music played, starred topics, etc. that you can put on your profile or elsewhere !",
|
||||
forkCount:faker.datatype.number(100),
|
||||
isFork:false,
|
||||
issues:{
|
||||
totalCount:faker.datatype.number(100),
|
||||
description: "📊 An image generator with 20+ metrics about your GitHub account such as activity, community, repositories, coding habits, website performances, music played, starred topics, etc. that you can put on your profile or elsewhere !",
|
||||
forkCount: faker.datatype.number(100),
|
||||
isFork: false,
|
||||
issues: {
|
||||
totalCount: faker.datatype.number(100),
|
||||
},
|
||||
nameWithOwner:"lowlighter/metrics",
|
||||
openGraphImageUrl:"https://repository-images.githubusercontent.com/293860197/7fd72080-496d-11eb-8fe0-238b38a0746a",
|
||||
pullRequests:{
|
||||
totalCount:faker.datatype.number(100),
|
||||
nameWithOwner: "lowlighter/metrics",
|
||||
openGraphImageUrl: "https://repository-images.githubusercontent.com/293860197/7fd72080-496d-11eb-8fe0-238b38a0746a",
|
||||
pullRequests: {
|
||||
totalCount: faker.datatype.number(100),
|
||||
},
|
||||
stargazerCount:faker.datatype.number(10000),
|
||||
licenseInfo:{
|
||||
nickname:null,
|
||||
name:"MIT License",
|
||||
stargazerCount: faker.datatype.number(10000),
|
||||
licenseInfo: {
|
||||
nickname: null,
|
||||
name: "MIT License",
|
||||
},
|
||||
primaryLanguage:{
|
||||
color:"#f1e05a",
|
||||
name:"JavaScript",
|
||||
primaryLanguage: {
|
||||
color: "#f1e05a",
|
||||
name: "JavaScript",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > sponsors/default")
|
||||
return ({
|
||||
user:{
|
||||
sponsorsListing:{
|
||||
fullDescription:faker.lorem.sentences(),
|
||||
activeGoal:{
|
||||
percentComplete:faker.datatype.number(100),
|
||||
title:faker.lorem.sentence(),
|
||||
description:faker.lorem.sentence(),
|
||||
}
|
||||
user: {
|
||||
sponsorsListing: {
|
||||
fullDescription: faker.lorem.sentences(),
|
||||
activeGoal: {
|
||||
percentComplete: faker.datatype.number(100),
|
||||
title: faker.lorem.sentence(),
|
||||
description: faker.lorem.sentence(),
|
||||
},
|
||||
},
|
||||
sponsorshipsAsMaintainer:{
|
||||
totalCount:faker.datatype.number(100),
|
||||
nodes:new Array(10).fill(null).map(_ => ({
|
||||
sponsorEntity:{
|
||||
login:faker.internet.userName(),
|
||||
avatarUrl:null,
|
||||
sponsorshipsAsMaintainer: {
|
||||
totalCount: faker.datatype.number(100),
|
||||
nodes: new Array(10).fill(null).map(_ => ({
|
||||
sponsorEntity: {
|
||||
login: faker.internet.userName(),
|
||||
avatarUrl: null,
|
||||
},
|
||||
tier:{
|
||||
monthlyPriceInDollars:faker.datatype.number(10),
|
||||
}
|
||||
}))
|
||||
}
|
||||
tier: {
|
||||
monthlyPriceInDollars: faker.datatype.number(10),
|
||||
},
|
||||
})),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > stargazers/default")
|
||||
return /after: "MOCKED_CURSOR"/m.test(query)
|
||||
? ({
|
||||
repository:{
|
||||
stargazers:{
|
||||
edges:[],
|
||||
repository: {
|
||||
stargazers: {
|
||||
edges: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
: ({
|
||||
repository:{
|
||||
stargazers:{
|
||||
edges:new Array(faker.datatype.number({min:50, max:100})).fill(null).map(() => ({
|
||||
starredAt:`${faker.date.recent(30)}`,
|
||||
cursor:"MOCKED_CURSOR",
|
||||
repository: {
|
||||
stargazers: {
|
||||
edges: new Array(faker.datatype.number({ min: 50, max: 100 })).fill(null).map(() => ({
|
||||
starredAt: `${faker.date.recent(30)}`,
|
||||
cursor: "MOCKED_CURSOR",
|
||||
})),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
/**Mocked data */
|
||||
export default function({faker, query, login = faker.internet.userName()}) {
|
||||
export default function({ faker, query, login = faker.internet.userName() }) {
|
||||
console.debug("metrics/compute/mocks > mocking graphql api result > stars/default")
|
||||
return ({
|
||||
user:{
|
||||
starredRepositories:{
|
||||
edges:[
|
||||
user: {
|
||||
starredRepositories: {
|
||||
edges: [
|
||||
{
|
||||
starredAt:`${faker.date.recent(14)}`,
|
||||
node:{
|
||||
description:"📊 An image generator with 20+ metrics about your GitHub account such as activity, community, repositories, coding habits, website performances, music played, starred topics, etc. that you can put on your profile or elsewhere !",
|
||||
forkCount:faker.datatype.number(100),
|
||||
isFork:false,
|
||||
issues:{
|
||||
totalCount:faker.datatype.number(100),
|
||||
starredAt: `${faker.date.recent(14)}`,
|
||||
node: {
|
||||
description: "📊 An image generator with 20+ metrics about your GitHub account such as activity, community, repositories, coding habits, website performances, music played, starred topics, etc. that you can put on your profile or elsewhere !",
|
||||
forkCount: faker.datatype.number(100),
|
||||
isFork: false,
|
||||
issues: {
|
||||
totalCount: faker.datatype.number(100),
|
||||
},
|
||||
nameWithOwner:"lowlighter/metrics",
|
||||
openGraphImageUrl:"https://repository-images.githubusercontent.com/293860197/7fd72080-496d-11eb-8fe0-238b38a0746a",
|
||||
pullRequests:{
|
||||
totalCount:faker.datatype.number(100),
|
||||
nameWithOwner: "lowlighter/metrics",
|
||||
openGraphImageUrl: "https://repository-images.githubusercontent.com/293860197/7fd72080-496d-11eb-8fe0-238b38a0746a",
|
||||
pullRequests: {
|
||||
totalCount: faker.datatype.number(100),
|
||||
},
|
||||
stargazerCount:faker.datatype.number(10000),
|
||||
licenseInfo:{
|
||||
nickname:null,
|
||||
name:"MIT License",
|
||||
stargazerCount: faker.datatype.number(10000),
|
||||
licenseInfo: {
|
||||
nickname: null,
|
||||
name: "MIT License",
|
||||
},
|
||||
primaryLanguage:{
|
||||
color:"#f1e05a",
|
||||
name:"JavaScript",
|
||||
primaryLanguage: {
|
||||
color: "#f1e05a",
|
||||
name: "JavaScript",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,340 +1,340 @@
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{username:login, page, per_page}]) {
|
||||
export default function({ faker }, target, that, [{ username: login, page, per_page }]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.activity.listEventsForAuthenticatedUser")
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/users/${login}/events?per_page=${per_page}&page=${page}`,
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
status: 200,
|
||||
url: `https://api.github.com/users/${login}/events?per_page=${per_page}&page=${page}`,
|
||||
headers: {
|
||||
server: "GitHub.com",
|
||||
status: "200 OK",
|
||||
"x-oauth-scopes": "repo",
|
||||
},
|
||||
data:page < 1 ? [] : [
|
||||
data: page < 1 ? [] : [
|
||||
{
|
||||
id:"10000000000",
|
||||
type:"CommitCommentEvent",
|
||||
actor:{
|
||||
id: "10000000000",
|
||||
type: "CommitCommentEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
comment:{
|
||||
user:{
|
||||
payload: {
|
||||
comment: {
|
||||
user: {
|
||||
login,
|
||||
},
|
||||
path:faker.system.fileName(),
|
||||
commit_id:"MOCKED_SHA",
|
||||
body:faker.lorem.sentence(),
|
||||
path: faker.system.fileName(),
|
||||
commit_id: "MOCKED_SHA",
|
||||
body: faker.lorem.sentence(),
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000001",
|
||||
type:"PullRequestReviewCommentEvent",
|
||||
actor:{
|
||||
id: "10000000001",
|
||||
type: "PullRequestReviewCommentEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
action:"created",
|
||||
comment:{
|
||||
user:{
|
||||
payload: {
|
||||
action: "created",
|
||||
comment: {
|
||||
user: {
|
||||
login,
|
||||
},
|
||||
body:faker.lorem.paragraph(),
|
||||
body: faker.lorem.paragraph(),
|
||||
},
|
||||
pull_request:{
|
||||
title:faker.lorem.sentence(),
|
||||
number:1,
|
||||
user:{
|
||||
login:faker.internet.userName(),
|
||||
pull_request: {
|
||||
title: faker.lorem.sentence(),
|
||||
number: 1,
|
||||
user: {
|
||||
login: faker.internet.userName(),
|
||||
},
|
||||
body:"",
|
||||
body: "",
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000002",
|
||||
type:"IssuesEvent",
|
||||
actor:{
|
||||
id: "10000000002",
|
||||
type: "IssuesEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
action:faker.random.arrayElement(["opened", "closed", "reopened"]),
|
||||
issue:{
|
||||
number:2,
|
||||
title:faker.lorem.sentence(),
|
||||
user:{
|
||||
payload: {
|
||||
action: faker.random.arrayElement(["opened", "closed", "reopened"]),
|
||||
issue: {
|
||||
number: 2,
|
||||
title: faker.lorem.sentence(),
|
||||
user: {
|
||||
login,
|
||||
},
|
||||
body:faker.lorem.paragraph(),
|
||||
performed_via_github_app:null,
|
||||
body: faker.lorem.paragraph(),
|
||||
performed_via_github_app: null,
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000003",
|
||||
type:"GollumEvent",
|
||||
actor:{
|
||||
id: "10000000003",
|
||||
type: "GollumEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
pages:[
|
||||
payload: {
|
||||
pages: [
|
||||
{
|
||||
page_name:faker.lorem.sentence(),
|
||||
title:faker.lorem.sentence(),
|
||||
summary:null,
|
||||
action:"created",
|
||||
sha:"MOCKED_SHA",
|
||||
page_name: faker.lorem.sentence(),
|
||||
title: faker.lorem.sentence(),
|
||||
summary: null,
|
||||
action: "created",
|
||||
sha: "MOCKED_SHA",
|
||||
},
|
||||
],
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000004",
|
||||
type:"IssueCommentEvent",
|
||||
actor:{
|
||||
id: "10000000004",
|
||||
type: "IssueCommentEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
action:"created",
|
||||
issue:{
|
||||
number:3,
|
||||
title:faker.lorem.sentence(),
|
||||
user:{
|
||||
payload: {
|
||||
action: "created",
|
||||
issue: {
|
||||
number: 3,
|
||||
title: faker.lorem.sentence(),
|
||||
user: {
|
||||
login,
|
||||
},
|
||||
labels:[
|
||||
labels: [
|
||||
{
|
||||
name:"lorem ipsum",
|
||||
color:"d876e3",
|
||||
name: "lorem ipsum",
|
||||
color: "d876e3",
|
||||
},
|
||||
],
|
||||
state:"open",
|
||||
state: "open",
|
||||
},
|
||||
comment:{
|
||||
body:faker.lorem.paragraph(),
|
||||
performed_via_github_app:null,
|
||||
comment: {
|
||||
body: faker.lorem.paragraph(),
|
||||
performed_via_github_app: null,
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000005",
|
||||
type:"ForkEvent",
|
||||
actor:{
|
||||
id: "10000000005",
|
||||
type: "ForkEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
forkee:{
|
||||
name:faker.random.word(),
|
||||
full_name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
payload: {
|
||||
forkee: {
|
||||
name: faker.random.word(),
|
||||
full_name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000006",
|
||||
type:"PullRequestReviewEvent",
|
||||
actor:{
|
||||
id: "10000000006",
|
||||
type: "PullRequestReviewEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
action:"created",
|
||||
review:{
|
||||
user:{
|
||||
payload: {
|
||||
action: "created",
|
||||
review: {
|
||||
user: {
|
||||
login,
|
||||
},
|
||||
state:"approved",
|
||||
state: "approved",
|
||||
},
|
||||
pull_request:{
|
||||
state:"open",
|
||||
number:4,
|
||||
locked:false,
|
||||
title:faker.lorem.sentence(),
|
||||
user:{
|
||||
login:faker.internet.userName(),
|
||||
pull_request: {
|
||||
state: "open",
|
||||
number: 4,
|
||||
locked: false,
|
||||
title: faker.lorem.sentence(),
|
||||
user: {
|
||||
login: faker.internet.userName(),
|
||||
},
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000007",
|
||||
type:"ReleaseEvent",
|
||||
actor:{
|
||||
id: "10000000007",
|
||||
type: "ReleaseEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
action:"published",
|
||||
release:{
|
||||
tag_name:`v${faker.datatype.number()}.${faker.datatype.number()}`,
|
||||
name:faker.random.words(4),
|
||||
draft:faker.datatype.boolean(),
|
||||
prerelease:faker.datatype.boolean(),
|
||||
payload: {
|
||||
action: "published",
|
||||
release: {
|
||||
tag_name: `v${faker.datatype.number()}.${faker.datatype.number()}`,
|
||||
name: faker.random.words(4),
|
||||
draft: faker.datatype.boolean(),
|
||||
prerelease: faker.datatype.boolean(),
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000008",
|
||||
type:"CreateEvent",
|
||||
actor:{
|
||||
id: "10000000008",
|
||||
type: "CreateEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
ref:faker.lorem.slug(),
|
||||
ref_type:faker.random.arrayElement(["tag", "branch"]),
|
||||
master_branch:"master",
|
||||
payload: {
|
||||
ref: faker.lorem.slug(),
|
||||
ref_type: faker.random.arrayElement(["tag", "branch"]),
|
||||
master_branch: "master",
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"100000000009",
|
||||
type:"WatchEvent",
|
||||
actor:{
|
||||
id: "100000000009",
|
||||
type: "WatchEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
repo: {
|
||||
name: "lowlighter/metrics",
|
||||
},
|
||||
payload:{action:"started"},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
payload: { action: "started" },
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000010",
|
||||
type:"DeleteEvent",
|
||||
actor:{
|
||||
id: "10000000010",
|
||||
type: "DeleteEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
ref:faker.lorem.slug(),
|
||||
ref_type:faker.random.arrayElement(["tag", "branch"]),
|
||||
payload: {
|
||||
ref: faker.lorem.slug(),
|
||||
ref_type: faker.random.arrayElement(["tag", "branch"]),
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000011",
|
||||
type:"PushEvent",
|
||||
actor:{
|
||||
id: "10000000011",
|
||||
type: "PushEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
size:1,
|
||||
ref:"refs/heads/master",
|
||||
commits:[
|
||||
payload: {
|
||||
size: 1,
|
||||
ref: "refs/heads/master",
|
||||
commits: [
|
||||
{
|
||||
sha:"MOCKED_SHA",
|
||||
message:faker.lorem.sentence(),
|
||||
url:"https://api.github.com/repos/lowlighter/metrics/commits/MOCKED_SHA",
|
||||
sha: "MOCKED_SHA",
|
||||
message: faker.lorem.sentence(),
|
||||
url: "https://api.github.com/repos/lowlighter/metrics/commits/MOCKED_SHA",
|
||||
},
|
||||
],
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000012",
|
||||
type:"PullRequestEvent",
|
||||
actor:{
|
||||
id: "10000000012",
|
||||
type: "PullRequestEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
action:faker.random.arrayElement(["opened", "closed"]),
|
||||
number:5,
|
||||
pull_request:{
|
||||
user:{
|
||||
payload: {
|
||||
action: faker.random.arrayElement(["opened", "closed"]),
|
||||
number: 5,
|
||||
pull_request: {
|
||||
user: {
|
||||
login,
|
||||
},
|
||||
state:"open",
|
||||
title:faker.lorem.sentence(),
|
||||
additions:faker.datatype.number(1000),
|
||||
deletions:faker.datatype.number(1000),
|
||||
changed_files:faker.datatype.number(10),
|
||||
state: "open",
|
||||
title: faker.lorem.sentence(),
|
||||
additions: faker.datatype.number(1000),
|
||||
deletions: faker.datatype.number(1000),
|
||||
changed_files: faker.datatype.number(10),
|
||||
},
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000013",
|
||||
type:"MemberEvent",
|
||||
actor:{
|
||||
id: "10000000013",
|
||||
type: "MemberEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{
|
||||
member:{
|
||||
login:faker.internet.userName(),
|
||||
payload: {
|
||||
member: {
|
||||
login: faker.internet.userName(),
|
||||
},
|
||||
action:"added",
|
||||
action: "added",
|
||||
},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
{
|
||||
id:"10000000014",
|
||||
type:"PublicEvent",
|
||||
actor:{
|
||||
id: "10000000014",
|
||||
type: "PublicEvent",
|
||||
actor: {
|
||||
login,
|
||||
},
|
||||
repo:{
|
||||
name:`${faker.random.word()}/${faker.random.word()}`,
|
||||
repo: {
|
||||
name: `${faker.random.word()}/${faker.random.word()}`,
|
||||
},
|
||||
payload:{},
|
||||
created_at:faker.date.recent(7),
|
||||
public:true,
|
||||
payload: {},
|
||||
created_at: faker.date.recent(7),
|
||||
public: true,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import listEventsForAuthenticatedUser from "./listEventsForAuthenticatedUser.mjs"
|
||||
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{username:login, page, per_page}]) {
|
||||
export default function({ faker }, target, that, [{ username: login, page, per_page }]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.activity.listRepoEvents")
|
||||
return listEventsForAuthenticatedUser(...arguments)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,23 +1,23 @@
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, args) {
|
||||
export default function({ faker }, target, that, args) {
|
||||
return ({
|
||||
status:200,
|
||||
url:"https://api.github.com/rate_limit",
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
status: 200,
|
||||
url: "https://api.github.com/rate_limit",
|
||||
headers: {
|
||||
server: "GitHub.com",
|
||||
status: "200 OK",
|
||||
"x-oauth-scopes": "repo",
|
||||
},
|
||||
data:{
|
||||
resources:{
|
||||
core:{limit:5000, used:0, remaining:5000, reset:0},
|
||||
search:{limit:30, used:0, remaining:30, reset:0},
|
||||
graphql:{limit:5000, used:0, remaining:5000, reset:0},
|
||||
integration_manifest:{limit:5000, used:0, remaining:5000, reset:0},
|
||||
source_import:{limit:100, used:0, remaining:100, reset:0},
|
||||
code_scanning_upload:{limit:500, used:0, remaining:500, reset:0},
|
||||
data: {
|
||||
resources: {
|
||||
core: { limit: 5000, used: 0, remaining: 5000, reset: 0 },
|
||||
search: { limit: 30, used: 0, remaining: 30, reset: 0 },
|
||||
graphql: { limit: 5000, used: 0, remaining: 5000, reset: 0 },
|
||||
integration_manifest: { limit: 5000, used: 0, remaining: 5000, reset: 0 },
|
||||
source_import: { limit: 100, used: 0, remaining: 100, reset: 0 },
|
||||
code_scanning_upload: { limit: 500, used: 0, remaining: 500, reset: 0 },
|
||||
},
|
||||
rate:{limit:5000, used:0, remaining:"MOCKED", reset:0},
|
||||
rate: { limit: 5000, used: 0, remaining: "MOCKED", reset: 0 },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{owner, repo}]) {
|
||||
export default function({ faker }, target, that, [{ owner, repo }]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getContributorsStats")
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/repos/${owner}/${repo}/stats/contributors`,
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
status: 200,
|
||||
url: `https://api.github.com/repos/${owner}/${repo}/stats/contributors`,
|
||||
headers: {
|
||||
server: "GitHub.com",
|
||||
status: "200 OK",
|
||||
"x-oauth-scopes": "repo",
|
||||
},
|
||||
data:[
|
||||
data: [
|
||||
{
|
||||
total:faker.datatype.number(10000),
|
||||
weeks:[
|
||||
{w:1, a:faker.datatype.number(10000), d:faker.datatype.number(10000), c:faker.datatype.number(10000)},
|
||||
{w:2, a:faker.datatype.number(10000), d:faker.datatype.number(10000), c:faker.datatype.number(10000)},
|
||||
{w:3, a:faker.datatype.number(10000), d:faker.datatype.number(10000), c:faker.datatype.number(10000)},
|
||||
{w:4, a:faker.datatype.number(10000), d:faker.datatype.number(10000), c:faker.datatype.number(10000)},
|
||||
total: faker.datatype.number(10000),
|
||||
weeks: [
|
||||
{ w: 1, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000) },
|
||||
{ w: 2, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000) },
|
||||
{ w: 3, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000) },
|
||||
{ w: 4, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000) },
|
||||
],
|
||||
author:{
|
||||
login:owner,
|
||||
author: {
|
||||
login: owner,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{owner, repo}]) {
|
||||
export default function({ faker }, target, that, [{ owner, repo }]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getViews")
|
||||
const count = faker.datatype.number(10000) * 2
|
||||
const uniques = faker.datatype.number(count) * 2
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/repos/${owner}/${repo}/traffic/views`,
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
status: 200,
|
||||
url: `https://api.github.com/repos/${owner}/${repo}/traffic/views`,
|
||||
headers: {
|
||||
server: "GitHub.com",
|
||||
status: "200 OK",
|
||||
"x-oauth-scopes": "repo",
|
||||
},
|
||||
data:{
|
||||
data: {
|
||||
count,
|
||||
uniques,
|
||||
views:[
|
||||
{timestamp:`${faker.date.recent()}`, count:count / 2, uniques:uniques / 2},
|
||||
{timestamp:`${faker.date.recent()}`, count:count / 2, uniques:uniques / 2},
|
||||
views: [
|
||||
{ timestamp: `${faker.date.recent()}`, count: count / 2, uniques: uniques / 2 },
|
||||
{ timestamp: `${faker.date.recent()}`, count: count / 2, uniques: uniques / 2 },
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{page, per_page, owner, repo}]) {
|
||||
export default function({ faker }, target, that, [{ page, per_page, owner, repo }]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.listCommits")
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/repos/${owner}/${repo}/commits?per_page=${per_page}&page=${page}`,
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
status: 200,
|
||||
url: `https://api.github.com/repos/${owner}/${repo}/commits?per_page=${per_page}&page=${page}`,
|
||||
headers: {
|
||||
server: "GitHub.com",
|
||||
status: "200 OK",
|
||||
"x-oauth-scopes": "repo",
|
||||
},
|
||||
data:page < 2
|
||||
data: page < 2
|
||||
? new Array(per_page).fill(null).map(() => ({
|
||||
sha:"MOCKED_SHA",
|
||||
sha: "MOCKED_SHA",
|
||||
get author() {
|
||||
return this.commit.author
|
||||
},
|
||||
commit:{
|
||||
message:faker.lorem.sentence(),
|
||||
author:{
|
||||
name:owner,
|
||||
login:faker.internet.userName(),
|
||||
avatar_url:null,
|
||||
date:`${faker.date.recent(14)}`,
|
||||
commit: {
|
||||
message: faker.lorem.sentence(),
|
||||
author: {
|
||||
name: owner,
|
||||
login: faker.internet.userName(),
|
||||
avatar_url: null,
|
||||
date: `${faker.date.recent(14)}`,
|
||||
},
|
||||
committer:{
|
||||
name:owner,
|
||||
login:faker.internet.userName(),
|
||||
avatar_url:null,
|
||||
date:`${faker.date.recent(14)}`,
|
||||
committer: {
|
||||
name: owner,
|
||||
login: faker.internet.userName(),
|
||||
avatar_url: null,
|
||||
date: `${faker.date.recent(14)}`,
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{owner, repo}]) {
|
||||
export default function({ faker }, target, that, [{ owner, repo }]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.listContributors")
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/repos/${owner}/${repo}/contributors`,
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
status: 200,
|
||||
url: `https://api.github.com/repos/${owner}/${repo}/contributors`,
|
||||
headers: {
|
||||
server: "GitHub.com",
|
||||
status: "200 OK",
|
||||
"x-oauth-scopes": "repo",
|
||||
},
|
||||
data:new Array(40 + faker.datatype.number(60)).fill(null).map(() => ({
|
||||
login:faker.internet.userName(),
|
||||
avatar_url:null,
|
||||
contributions:faker.datatype.number(1000),
|
||||
data: new Array(40 + faker.datatype.number(60)).fill(null).map(() => ({
|
||||
login: faker.internet.userName(),
|
||||
avatar_url: null,
|
||||
contributions: faker.datatype.number(1000),
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, args) {
|
||||
export default function({ faker }, target, that, args) {
|
||||
//Arguments
|
||||
const [url] = args
|
||||
//Head request
|
||||
if (/^HEAD .$/.test(url)) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.request HEAD")
|
||||
return ({
|
||||
status:200,
|
||||
url:"https://api.github.com/",
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
status: 200,
|
||||
url: "https://api.github.com/",
|
||||
headers: {
|
||||
server: "GitHub.com",
|
||||
status: "200 OK",
|
||||
"x-oauth-scopes": "repo",
|
||||
},
|
||||
data:undefined,
|
||||
data: undefined,
|
||||
})
|
||||
}
|
||||
//Commit content
|
||||
if (/^https:..api.github.com.repos.lowlighter.metrics.commits.MOCKED_SHA/.test(url)) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api result > rest.request ${url}`)
|
||||
return ({
|
||||
status:200,
|
||||
url:"https://api.github.com/repos/lowlighter/metrics/commits/MOCKED_SHA",
|
||||
data:{
|
||||
sha:"MOCKED_SHA",
|
||||
commit:{
|
||||
author:{
|
||||
name:faker.internet.userName(),
|
||||
email:faker.internet.email(),
|
||||
date:`${faker.date.recent(7)}`,
|
||||
status: 200,
|
||||
url: "https://api.github.com/repos/lowlighter/metrics/commits/MOCKED_SHA",
|
||||
data: {
|
||||
sha: "MOCKED_SHA",
|
||||
commit: {
|
||||
author: {
|
||||
name: faker.internet.userName(),
|
||||
email: faker.internet.email(),
|
||||
date: `${faker.date.recent(7)}`,
|
||||
},
|
||||
committer:{
|
||||
name:faker.internet.userName(),
|
||||
email:faker.internet.email(),
|
||||
date:`${faker.date.recent(7)}`,
|
||||
committer: {
|
||||
name: faker.internet.userName(),
|
||||
email: faker.internet.email(),
|
||||
date: `${faker.date.recent(7)}`,
|
||||
},
|
||||
url:"https://api.github.com/repos/lowlighter/metrics/commits/MOCKED_SHA",
|
||||
url: "https://api.github.com/repos/lowlighter/metrics/commits/MOCKED_SHA",
|
||||
},
|
||||
author:{
|
||||
login:faker.internet.userName(),
|
||||
id:faker.datatype.number(100000000),
|
||||
author: {
|
||||
login: faker.internet.userName(),
|
||||
id: faker.datatype.number(100000000),
|
||||
},
|
||||
committer:{
|
||||
login:faker.internet.userName(),
|
||||
id:faker.datatype.number(100000000),
|
||||
committer: {
|
||||
login: faker.internet.userName(),
|
||||
id: faker.datatype.number(100000000),
|
||||
},
|
||||
files:[
|
||||
files: [
|
||||
{
|
||||
sha:"MOCKED_SHA",
|
||||
filename:faker.system.fileName(),
|
||||
patch:'@@ -0,0 +1,5 @@\n+//Imports\n+ import app from "./src/app.mjs"\n+\n+//Start app\n+ await app()\n\\ No newline at end of file',
|
||||
sha: "MOCKED_SHA",
|
||||
filename: faker.system.fileName(),
|
||||
patch: '@@ -0,0 +1,5 @@\n+//Imports\n+ import app from "./src/app.mjs"\n+\n+//Start app\n+ await app()\n\\ No newline at end of file',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/**Mocked data */
|
||||
export default function({faker}, target, that, [{username}]) {
|
||||
export default function({ faker }, target, that, [{ username }]) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getByUsername")
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/users/${username}/`,
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
status: 200,
|
||||
url: `https://api.github.com/users/${username}/`,
|
||||
headers: {
|
||||
server: "GitHub.com",
|
||||
status: "200 OK",
|
||||
"x-oauth-scopes": "repo",
|
||||
},
|
||||
data:{
|
||||
login:faker.internet.userName(),
|
||||
avatar_url:null,
|
||||
contributions:faker.datatype.number(1000),
|
||||
data: {
|
||||
login: faker.internet.userName(),
|
||||
avatar_url: null,
|
||||
contributions: faker.datatype.number(1000),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,29 +10,29 @@ import urls from "url"
|
||||
let mocked = false
|
||||
|
||||
//Mocking
|
||||
export default async function({graphql, rest}) {
|
||||
export default async function({ graphql, rest }) {
|
||||
//Check if already mocked
|
||||
if (mocked)
|
||||
return {graphql, rest}
|
||||
return { graphql, rest }
|
||||
mocked = true
|
||||
console.debug("metrics/compute/mocks > mocking")
|
||||
|
||||
//Load mocks
|
||||
const __mocks = paths.join(paths.dirname(urls.fileURLToPath(import.meta.url)))
|
||||
const mock = async ({directory, mocks}) => {
|
||||
const mock = async ({ directory, mocks }) => {
|
||||
for (const entry of await fs.readdir(directory)) {
|
||||
if ((await fs.lstat(paths.join(directory, entry))).isDirectory()) {
|
||||
if (!mocks[entry])
|
||||
mocks[entry] = {}
|
||||
await mock({directory:paths.join(directory, entry), mocks:mocks[entry]})
|
||||
await mock({ directory: paths.join(directory, entry), mocks: mocks[entry] })
|
||||
}
|
||||
else
|
||||
else {
|
||||
mocks[entry.replace(/[.]mjs$/, "")] = (await import(urls.pathToFileURL(paths.join(directory, entry)).href)).default
|
||||
|
||||
}
|
||||
}
|
||||
return mocks
|
||||
}
|
||||
const mocks = await mock({directory:paths.join(__mocks, "api"), mocks:{}})
|
||||
const mocks = await mock({ directory: paths.join(__mocks, "api"), mocks: {} })
|
||||
|
||||
//GraphQL API mocking
|
||||
{
|
||||
@@ -49,7 +49,7 @@ export default async function({graphql, rest}) {
|
||||
//Search for mocked query
|
||||
for (const mocked of Object.keys(mocks.github.graphql)) {
|
||||
if (new RegExp(`^query ${mocked.replace(/([.]\w)/g, (_, g) => g.toLocaleUpperCase().substring(1)).replace(/^(\w)/g, (_, g) => g.toLocaleUpperCase())} `).test(query))
|
||||
return mocks.github.graphql[mocked]({faker, query, login})
|
||||
return mocks.github.graphql[mocked]({ faker, query, login })
|
||||
}
|
||||
|
||||
//Unmocked call
|
||||
@@ -64,26 +64,26 @@ export default async function({graphql, rest}) {
|
||||
console.debug("metrics/compute/mocks > mocking rest api")
|
||||
const unmocked = {}
|
||||
//Mocked
|
||||
const mocker = ({path = "rest", mocks, mocked}) => {
|
||||
const mocker = ({ path = "rest", mocks, mocked }) => {
|
||||
for (const [key, value] of Object.entries(mocks)) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api > mocking ${path}.${key}`)
|
||||
if (typeof value === "function") {
|
||||
unmocked[path] = value
|
||||
mocked[key] = new Proxy(unmocked[path], {apply:value.bind(null, {faker})})
|
||||
mocked[key] = new Proxy(unmocked[path], { apply: value.bind(null, { faker }) })
|
||||
}
|
||||
else {
|
||||
mocker({ path: `${path}.${key}`, mocks: mocks[key], mocked: mocked[key] })
|
||||
}
|
||||
else
|
||||
mocker({path:`${path}.${key}`, mocks:mocks[key], mocked:mocked[key]})
|
||||
|
||||
}
|
||||
}
|
||||
mocker({mocks:mocks.github.rest, mocked:rest})
|
||||
mocker({ mocks: mocks.github.rest, mocked: rest })
|
||||
}
|
||||
|
||||
//Axios mocking
|
||||
{
|
||||
//Unmocked
|
||||
console.debug("metrics/compute/mocks > mocking axios")
|
||||
const unmocked = {get:axios.get, post:axios.post}
|
||||
const unmocked = { get: axios.get, post: axios.post }
|
||||
|
||||
//Mocked post requests
|
||||
axios.post = new Proxy(unmocked.post, {
|
||||
@@ -93,7 +93,7 @@ export default async function({graphql, rest}) {
|
||||
|
||||
//Search for mocked request
|
||||
for (const service of Object.keys(mocks.axios.post)) {
|
||||
const mocked = mocks.axios.post[service]({faker, url, body})
|
||||
const mocked = mocks.axios.post[service]({ faker, url, body })
|
||||
if (mocked)
|
||||
return mocked
|
||||
}
|
||||
@@ -111,7 +111,7 @@ export default async function({graphql, rest}) {
|
||||
|
||||
//Search for mocked request
|
||||
for (const service of Object.keys(mocks.axios.get)) {
|
||||
const mocked = mocks.axios.get[service]({faker, url, options})
|
||||
const mocked = mocks.axios.get[service]({ faker, url, options })
|
||||
if (mocked)
|
||||
return mocked
|
||||
}
|
||||
@@ -131,20 +131,20 @@ export default async function({graphql, rest}) {
|
||||
rss.prototype.parseURL = function(url) {
|
||||
console.debug(`metrics/compute/mocks > mocking rss feed result > ${url}`)
|
||||
return ({
|
||||
items:new Array(30).fill(null).map(_ => ({
|
||||
title:faker.lorem.sentence(),
|
||||
link:faker.internet.url(),
|
||||
content:faker.lorem.paragraphs(),
|
||||
contentSnippet:faker.lorem.paragraph(),
|
||||
isoDate:faker.date.recent(),
|
||||
items: new Array(30).fill(null).map(_ => ({
|
||||
title: faker.lorem.sentence(),
|
||||
link: faker.internet.url(),
|
||||
content: faker.lorem.paragraphs(),
|
||||
contentSnippet: faker.lorem.paragraph(),
|
||||
isoDate: faker.date.recent(),
|
||||
})),
|
||||
title:faker.lorem.words(),
|
||||
description:faker.lorem.paragraph(),
|
||||
link:url,
|
||||
title: faker.lorem.words(),
|
||||
description: faker.lorem.paragraph(),
|
||||
link: url,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//Return mocked elements
|
||||
return {graphql, rest}
|
||||
return { graphql, rest }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user