chore: code formatting
This commit is contained in:
@@ -7,7 +7,7 @@ export default async function({login, q, imports, graphql, queries, data, accoun
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//Load inputs
|
||||||
let {featured, pinned, starred, random, order, affiliations:_affiliations} = imports.metadata.plugins.repositories.inputs({data, account, q})
|
let {featured, pinned, starred, random, order, affiliations: _affiliations} = imports.metadata.plugins.repositories.inputs({data, account, q})
|
||||||
const affiliations = _affiliations?.length ? `ownerAffiliations: [${_affiliations.map(x => x.toLocaleUpperCase()).join(", ")}]` : ""
|
const affiliations = _affiliations?.length ? `ownerAffiliations: [${_affiliations.map(x => x.toLocaleUpperCase()).join(", ")}]` : ""
|
||||||
|
|
||||||
//Initialization
|
//Initialization
|
||||||
@@ -18,31 +18,33 @@ export default async function({login, q, imports, graphql, queries, data, accoun
|
|||||||
for (const repo of featured) {
|
for (const repo of featured) {
|
||||||
const {owner = login, name} = repo.match(/^(?:(?<owner>[\s\S]*)[/])?(?<name>[\s\S]+)$/)?.groups ?? {}
|
const {owner = login, name} = repo.match(/^(?:(?<owner>[\s\S]*)[/])?(?<name>[\s\S]+)$/)?.groups ?? {}
|
||||||
const {repository} = await graphql(queries.repositories.repository({owner, name}))
|
const {repository} = await graphql(queries.repositories.repository({owner, name}))
|
||||||
repositories.list.push(format(repository, {sorting:"featured"}))
|
repositories.list.push(format(repository, {sorting: "featured"}))
|
||||||
processed.add(repository.nameWithOwner)
|
processed.add(repository.nameWithOwner)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fetch pinned repositories
|
//Fetch pinned repositories
|
||||||
if (pinned) {
|
if (pinned) {
|
||||||
const {user: {pinnedItems: {edges}}} = await graphql(queries.repositories.pinned({login, limit: 6}))
|
const {user: {pinnedItems: {edges}}} = await graphql(queries.repositories.pinned({login, limit: 6}))
|
||||||
repositories.list.push(...edges.map(({node}) => {
|
repositories.list.push(
|
||||||
|
...edges.map(({node}) => {
|
||||||
if (processed.has(node.nameWithOwner))
|
if (processed.has(node.nameWithOwner))
|
||||||
return null
|
return null
|
||||||
processed.add(node.nameWithOwner)
|
processed.add(node.nameWithOwner)
|
||||||
return format(node, {sorting: "pinned"})
|
return format(node, {sorting: "pinned"})
|
||||||
}).filter(repository => repository).slice(0, pinned))
|
}).filter(repository => repository).slice(0, pinned),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fetch starred repositories
|
//Fetch starred repositories
|
||||||
if (starred) {
|
if (starred) {
|
||||||
const {user:{ repositories: {nodes}}} = await graphql(queries.repositories.starred({login, limit: Math.min(starred+10, 100), affiliations}))
|
const {user: {repositories: {nodes}}} = await graphql(queries.repositories.starred({login, limit: Math.min(starred + 10, 100), affiliations}))
|
||||||
let count = 0
|
let count = 0
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
if (processed.has(node.nameWithOwner))
|
if (processed.has(node.nameWithOwner))
|
||||||
continue
|
continue
|
||||||
const [owner, name] = node.nameWithOwner.split("/")
|
const [owner, name] = node.nameWithOwner.split("/")
|
||||||
const {repository} = await graphql(queries.repositories.repository({owner, name}))
|
const {repository} = await graphql(queries.repositories.repository({owner, name}))
|
||||||
repositories.list.push(format(repository, {sorting:"starred"}))
|
repositories.list.push(format(repository, {sorting: "starred"}))
|
||||||
processed.add(repository.nameWithOwner)
|
processed.add(repository.nameWithOwner)
|
||||||
if (++count >= starred)
|
if (++count >= starred)
|
||||||
break
|
break
|
||||||
@@ -51,14 +53,14 @@ export default async function({login, q, imports, graphql, queries, data, accoun
|
|||||||
|
|
||||||
//Fetch random repositories
|
//Fetch random repositories
|
||||||
if (random) {
|
if (random) {
|
||||||
const {user:{ repositories: {nodes}}} = await graphql(queries.repositories.random({login, affiliations}))
|
const {user: {repositories: {nodes}}} = await graphql(queries.repositories.random({login, affiliations}))
|
||||||
let count = 0
|
let count = 0
|
||||||
for (const node of imports.shuffle(nodes)) {
|
for (const node of imports.shuffle(nodes)) {
|
||||||
if (processed.has(node.nameWithOwner))
|
if (processed.has(node.nameWithOwner))
|
||||||
continue
|
continue
|
||||||
const [owner, name] = node.nameWithOwner.split("/")
|
const [owner, name] = node.nameWithOwner.split("/")
|
||||||
const {repository} = await graphql(queries.repositories.repository({owner, name}))
|
const {repository} = await graphql(queries.repositories.repository({owner, name}))
|
||||||
repositories.list.push(format(repository, {sorting:"random"}))
|
repositories.list.push(format(repository, {sorting: "random"}))
|
||||||
processed.add(repository.nameWithOwner)
|
processed.add(repository.nameWithOwner)
|
||||||
if (++count >= random)
|
if (++count >= random)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ export default function({faker, query, login = faker.internet.userName()}) {
|
|||||||
repositories: {
|
repositories: {
|
||||||
nodes: [
|
nodes: [
|
||||||
{nameWithOwner: "lowlighter/metrics"},
|
{nameWithOwner: "lowlighter/metrics"},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ export default function({faker, query, login = faker.internet.userName()}) {
|
|||||||
repositories: {
|
repositories: {
|
||||||
nodes: [
|
nodes: [
|
||||||
{nameWithOwner: "lowlighter/metrics"},
|
{nameWithOwner: "lowlighter/metrics"},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user