Skip to content

fix: drop support for projects classic #1715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ RUN chmod +x /metrics/source/app/action/index.mjs \
# Install latest chrome dev package, fonts to support major charsets and skip chromium download on puppeteer install
# Based on https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker
&& apt-get update \
&& apt-get install -y wget gnupg ca-certificates libgconf-2-4 \
&& apt-get install -y xz-utils wget gnupg ca-certificates libgconf-2-4 \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
2 changes: 1 addition & 1 deletion source/plugins/achievements/queries/achievements.graphql
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ query AchievementsDefault {
totalCount
}
}
projects(first: 1, orderBy: {field: CREATED_AT, direction: ASC}) {
projects: projectsV2(first: 1, orderBy: {field: CREATED_AT, direction: ASC}) {
totalCount
#nodes { This requires additional scopes :/
# name
2 changes: 1 addition & 1 deletion source/plugins/achievements/queries/organizations.graphql
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ query AchievementsOrganizations {
}
}
}
projects(first: 1, orderBy: {field: CREATED_AT, direction: ASC}) {
projects: projectsV2(first: 1, orderBy: {field: CREATED_AT, direction: ASC}) {
totalCount
}
packages(first: 1, orderBy: {direction: ASC, field: CREATED_AT}) {
25 changes: 6 additions & 19 deletions source/plugins/projects/index.mjs
Original file line number Diff line number Diff line change
@@ -15,10 +15,7 @@ export default async function({login, data, imports, graphql, q, queries, accoun

//Retrieve user owned projects from graphql api
console.debug(`metrics/compute/${login}/plugins > projects > querying api`)
const {[account]: {projects}} = await graphql(queries.projects["user.legacy"]({login, limit, account}))
const {[account]: {projectsV2}} = await graphql(queries.projects.user({login, limit, account}))
projects.nodes.unshift(...projectsV2.nodes)
projects.totalCount += projectsV2.totalCount

//Retrieve repositories projects from graphql api
for (const identifier of repositories) {
@@ -27,7 +24,7 @@ export default async function({login, data, imports, graphql, q, queries, accoun
const {user, repository, id} = identifier.match(/(?<user>[-\w]+)[/](?<repository>[-\w]+)[/]projects[/](?<id>\d+)/)?.groups ?? {}
let project = null
for (const account of ["user", "organization"]) {
//Try projects beta
//Projects classic has been sunset, so ProjectsV2 is the only option
try {
project = (await graphql(queries.projects.repository({user, repository, id, account})))[account].repository.projectV2
if (project)
@@ -36,30 +33,20 @@ export default async function({login, data, imports, graphql, q, queries, accoun
catch (error) {
console.debug(error)
}
//Try projects classic
try {
console.debug(`metrics/compute/${login}/plugins > projects > falling back to projects classic for ${identifier}`)
;({project} = (await graphql(queries.projects["repository.legacy"]({user, repository, id, account})))[account].repository)
if (project)
break
}
catch (error) {
console.debug(error)
}
}
if (!project)
throw new Error(`Could not load project ${user}/${repository}`)
//Adding it to projects list
console.debug(`metrics/compute/${login}/plugins > projects > registering ${identifier}`)
project.name = `${project.name} (${user}/${repository})`
projects.nodes.unshift(project)
projects.totalCount++
projectsV2.nodes.unshift(project)
projectsV2.totalCount++
}

//Iterate through projects and format them
console.debug(`metrics/compute/${login}/plugins > projects > processing ${projects.nodes.length} projects`)
console.debug(`metrics/compute/${login}/plugins > projects > processing ${projectsV2.nodes.length} projects`)
const list = []
for (const project of projects.nodes) {
for (const project of projectsV2.nodes) {
//Format date
const time = (Date.now() - new Date(project.updatedAt).getTime()) / (24 * 60 * 60 * 1000)
let updated = new Date(project.updatedAt).toDateString().substring(4)
@@ -85,7 +72,7 @@ export default async function({login, data, imports, graphql, q, queries, accoun
list.splice(limit)

//Results
return {list, totalCount: projects.totalCount, descriptions}
return {list, totalCount: projectsV2.totalCount, descriptions}
}
//Handle errors
catch (error) {
17 changes: 0 additions & 17 deletions source/plugins/projects/queries/repository.legacy.graphql

This file was deleted.

18 changes: 0 additions & 18 deletions source/plugins/projects/queries/user.legacy.graphql

This file was deleted.

21 changes: 0 additions & 21 deletions tests/mocks/api/github/graphql/projects.repository.legacy.mjs

This file was deleted.

24 changes: 0 additions & 24 deletions tests/mocks/api/github/graphql/projects.user.legacy.mjs

This file was deleted.

Loading
Oops, something went wrong.