fix(plugins/base): job availability status (#1081)

This commit is contained in:
Simon Lecoq
2022-05-29 03:44:21 +02:00
committed by GitHub
parent 965ab51f01
commit 509c83ce17
7 changed files with 14 additions and 10 deletions

View File

@@ -105,7 +105,7 @@
createdAt: `${faker.date.past(10)}`, createdAt: `${faker.date.past(10)}`,
avatarUrl: set.avatar, avatarUrl: set.avatar,
websiteUrl: options["pagespeed.url"] || "(attached website)", websiteUrl: options["pagespeed.url"] || "(attached website)",
isHireable: false, isHireable: options["base.hireable"],
twitterUsername: options["tweets.user"] || "(attached Twitter account)", twitterUsername: options["tweets.user"] || "(attached Twitter account)",
repositories: {totalCount: faker.datatype.number(100), totalDiskUsage: faker.datatype.number(100000), nodes: []}, repositories: {totalCount: faker.datatype.number(100), totalDiskUsage: faker.datatype.number(100000), nodes: []},
packages: {totalCount: faker.datatype.number(10)}, packages: {totalCount: faker.datatype.number(10)},

View File

@@ -7,7 +7,7 @@
export default async function({login, graphql, rest, data, q, queries, imports}, conf) { export default async function({login, graphql, rest, data, q, queries, imports}, conf) {
//Load inputs //Load inputs
console.debug(`metrics/compute/${login}/base > started`) console.debug(`metrics/compute/${login}/base > started`)
let {indepth, "repositories.forks": _forks, "repositories.affiliations": _affiliations, "repositories.batch": _batch} = imports.metadata.plugins.base.inputs({data, q, account: "bypass"}) let {indepth, hireable, "repositories.forks": _forks, "repositories.affiliations": _affiliations, "repositories.batch": _batch} = imports.metadata.plugins.base.inputs({data, q, account: "bypass"})
const extras = conf.settings.extras?.features ?? conf.settings.extras?.default const extras = conf.settings.extras?.features ?? conf.settings.extras?.default
const repositories = conf.settings.repositories || 100 const repositories = conf.settings.repositories || 100
const forks = _forks ? "" : ", isFork: false" const forks = _forks ? "" : ", isFork: false"
@@ -134,6 +134,11 @@ export default async function({login, graphql, rest, data, q, queries, imports},
console.debug(`metrics/compute/${login}/base > falling back to last year commits history`) console.debug(`metrics/compute/${login}/base > falling back to last year commits history`)
} }
} }
//Hireable status
if (hireable) {
console.debug(`metrics/compute/${login}/base > is hireable`)
data.user.isHireable = hireable
}
} }
//Query repositories from GitHub API //Query repositories from GitHub API
for (const type of ({user: ["repositories", "repositoriesContributedTo"], organization: ["repositories"]}[account] ?? [])) { for (const type of ({user: ["repositories", "repositoriesContributedTo"], organization: ["repositories"]}[account] ?? [])) {
@@ -213,6 +218,7 @@ const postprocess = {
console.debug(`metrics/compute/${login}/base > applying postprocessing`) console.debug(`metrics/compute/${login}/base > applying postprocessing`)
data.account = "user" data.account = "user"
Object.assign(data.user, { Object.assign(data.user, {
isHireable: false,
isVerified: false, isVerified: false,
repositories: {}, repositories: {},
contributionsCollection: {}, contributionsCollection: {},

View File

@@ -50,6 +50,12 @@ inputs:
type: boolean type: boolean
default: no default: no
base_hireable:
description: |
Display `Available for hire!` in header section
type: boolean
default: no
repositories: repositories:
description: | description: |
Repositories to fetch Repositories to fetch

View File

@@ -7,7 +7,6 @@ query BaseUser {
createdAt createdAt
avatarUrl avatarUrl
websiteUrl websiteUrl
isHireable
twitterUsername twitterUsername
} }
} }

View File

@@ -139,10 +139,6 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
console.debug(`metrics/compute/${login} > applying dflag --cakeday`) console.debug(`metrics/compute/${login} > applying dflag --cakeday`)
computed.cakeday = true computed.cakeday = true
} }
if (dflags.includes("--hireable")) {
console.debug(`metrics/compute/${login} > applying dflag --hireable`)
data.user.isHireable = true
}
if (dflags.includes("--halloween")) { if (dflags.includes("--halloween")) {
console.debug(`metrics/compute/${login} > applying dflag --halloween`) console.debug(`metrics/compute/${login} > applying dflag --halloween`)
//Haloween color replacer //Haloween color replacer

View File

@@ -467,7 +467,6 @@ inputs:
description: | description: |
Debug flags Debug flags
- `--cakeday`: simulate registration anniversary - `--cakeday`: simulate registration anniversary
- `--hireable`: simulate "Available for hire" account setting
- `--halloween`: enable halloween colors - `--halloween`: enable halloween colors
- `--error`: force render error - `--error`: force render error
type: array type: array
@@ -475,7 +474,6 @@ inputs:
default: "" default: ""
values: values:
- --cakeday - --cakeday
- --hireable
- --halloween - --halloween
- --error - --error
testing: yes testing: yes

View File

@@ -9,7 +9,6 @@ export default function({faker, query, login = faker.internet.userName()}) {
createdAt: `${faker.date.past(10)}`, createdAt: `${faker.date.past(10)}`,
avatarUrl: faker.image.people(), avatarUrl: faker.image.people(),
websiteUrl: faker.internet.url(), websiteUrl: faker.internet.url(),
isHireable: faker.datatype.boolean(),
twitterUsername: login, twitterUsername: login,
}, },
}) })