Skip to content

Commit

Permalink
Remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVelezLl committed Jan 9, 2025
1 parent f298787 commit 5e677f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 50 deletions.
55 changes: 8 additions & 47 deletions .github/GithubAPI.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
const axios = require("axios");

module.exports = class GithubAPI {
constructor(owner, github) {
this.owner = owner;
this.github = github;
}

async query(query, variables) {
try {
const response = await this.github.graphql(
query,
variables
);

console.log("Response", response);

if (response.data.errors) {
throw new Error(JSON.stringify(response.data.errors, null, 2));
}

return response.data;
} catch (error) {
console.error(error);
throw error;
}
}

async getSourceAndTargetProjects({ sourceNumber, targetNumber }) {
const projectSubquery = `
id
Expand All @@ -45,7 +23,7 @@ module.exports = class GithubAPI {
`;
const query = `
query getSourceAndTargetProjectsIds($owner: String!, $source: Int!, $target: Int!) {
user (login: $owner) {
organization (login: $owner) {
source: projectV2(number: $source) {
${projectSubquery}
}
Expand All @@ -56,13 +34,13 @@ module.exports = class GithubAPI {
}
`;

const response = await this.query(query, {
const response = await this.github.graphql(query, {
owner: this.owner,
source: sourceNumber,
target: targetNumber,
});

const { source, target } = response.data.organization;
const { source, target } = response.organization;

if (!source) {
throw new Error(`Source project not found: ${sourceNumber}`);
Expand Down Expand Up @@ -133,24 +111,7 @@ module.exports = class GithubAPI {
}
`;

const _getProjectItems = async (cursor = null, items = []) => {
const response = await this.query(query, {
projectId,
cursor
});

const { nodes, pageInfo } = response.data.node.items;

items.push(...nodes);

if (pageInfo.hasNextPage) {
return _getProjectItems(pageInfo.endCursor, items);
}

return items;
};

return _getProjectItems();
return this.github.graphql.paginate(query, { projectId });
}

async updateProjectItemsFields(items) {
Expand All @@ -173,14 +134,14 @@ module.exports = class GithubAPI {
for (let i = 0; i < items.length; i += BATCH_SIZE) {
const batch = items.slice(i, i + BATCH_SIZE);

await Promise.all(batch.map(async item => {
await this.query(query, {
await Promise.all(batch.map(item => (
this.github.graphql(query, {
projectId: item.projectId,
itemId: item.projectItemId,
fieldId: item.fieldId,
newValue: item.newValue
});
}));
})
)));
}
}
}
1 change: 1 addition & 0 deletions .github/githubUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const synchronizeProjectsStatuses = async (context, github) => {
const targetStatusField = targetProject.fields.nodes.find((field) => field.name === "Status");

const targetProjectItems = await githubAPI.getProjectItems(targetProject.id);
console.log("targetProjectItems", targetProjectItems.length)
const itemsToUpdate = targetProjectItems.filter((item) => {
const statusToByPass = "RELEASED";
const currentTargetStatusName = item.status?.value;
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/sync_kds_roadmap_statuses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
with:
node-version: '18'

- name: Install axios
run: npm install axios

- uses: tibdex/github-app-token@v1
id: generate-token
with:
Expand Down

0 comments on commit 5e677f1

Please sign in to comment.