Skip to content

Commit

Permalink
feat: no archived
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Oct 18, 2024
1 parent 206e82b commit ce4b604
Show file tree
Hide file tree
Showing 8 changed files with 715 additions and 36 deletions.
11 changes: 0 additions & 11 deletions jest.config.js

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@types/twitter": "^1.7.4",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"cspell": "^8.15.3",
"esbuild": "^0.19.8",
"eslint": "^8.43.0",
"eslint-config-prettier": "^9.0.0",
Expand Down
13 changes: 0 additions & 13 deletions src/directory/get-all-issues.ts

This file was deleted.

24 changes: 24 additions & 0 deletions src/directory/get-repository-issues.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { GitHubIssue, octokit } from "./directory";

export async function getRepositoryIssues(ownerName: string, repoName: string) {
// Check if the repository is archived
const { data: repo } = await octokit.rest.repos.get({
owner: ownerName,
repo: repoName,
});

if (repo.archived) {
console.warn(`Warning: Repository ${ownerName}/${repoName} is archived. Skipping issue retrieval.`);
return [];
}

// get all project issues (opened and closed)
let issues: GitHubIssue[] = await octokit.paginate({
method: "GET",
url: `/repos/${ownerName}/${repoName}/issues?state=all`,
});
// remove PRs from the project issues
issues = issues.filter((issue) => !issue.pull_request);

return issues;
}
4 changes: 2 additions & 2 deletions src/directory/sync-partner-repo-issues.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TwitterMap } from "../twitter/initialize-twitter-map";
import { GitHubIssue } from "./directory";
import { getAllIssues } from "./get-all-issues";
import { getIssueByLabel } from "./get-issue-by-label";
import { getRepoCredentials } from "./get-repo-credentials";
import { getRepositoryIssues } from "./get-repository-issues";
import { newDirectoryIssue } from "./new-directory-issue";
import { syncIssueMetaData as syncDirectoryIssue } from "./sync-issue-meta-data";

Expand All @@ -16,7 +16,7 @@ export async function syncPartnerRepoIssues({
twitterMap: TwitterMap;
}): Promise<GitHubIssue[]> {
const [ownerName, repoName] = getRepoCredentials(partnerRepoUrl);
const partnerRepoIssues: GitHubIssue[] = await getAllIssues(ownerName, repoName);
const partnerRepoIssues: GitHubIssue[] = await getRepositoryIssues(ownerName, repoName);
const buffer: (GitHubIssue | null)[] = [];
for (const partnerIssue of partnerRepoIssues) {
// if the issue is open, then add it to the buffer
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { calculateStatistics } from "./directory/calculate-statistics";
import { DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME, GitHubIssue } from "./directory/directory";
import { getAllIssues } from "./directory/get-all-issues";
import { getPartnerUrls as getPartnerRepoUrls } from "./directory/get-partner-urls";
import { getRepositoryIssues } from "./directory/get-repository-issues";
import { Statistics } from "./directory/statistics";
import { syncPartnerRepoIssues } from "./directory/sync-partner-repo-issues";
import { commitStatistics, commitTasks } from "./git";
import { initializeTwitterMap, TwitterMap } from "./twitter/initialize-twitter-map";

export async function main() {
const twitterMap: TwitterMap = await initializeTwitterMap();
const directoryIssues: GitHubIssue[] = await getAllIssues(DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME);
const directoryIssues: GitHubIssue[] = await getRepositoryIssues(DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME);
const partnerRepoUrls = await getPartnerRepoUrls();
const taskList: GitHubIssue[] = [];

Expand All @@ -23,7 +23,7 @@ export async function main() {
await commitTasks(taskList);

// Calculate total rewards from devpool issues
const { rewards, tasks } = await calculateStatistics(await getAllIssues(DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME));
const { rewards, tasks } = await calculateStatistics(await getRepositoryIssues(DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME));
const statistics: Statistics = { rewards, tasks };

await commitStatistics(statistics);
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { db } from "../mocks/db";
import cfg from "../mocks/issue-devpool-template.json";
import { server } from "../mocks/node";
import { DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME, GitHubIssue } from "../src/directory/directory";
import { getAllIssues } from "../src/directory/get-all-issues";
import { getDirectoryIssueLabelsFromPartnerIssue } from "../src/directory/get-directory-issue-labels";
import { getIssueByLabel } from "../src/directory/get-issue-by-label";
import { getIssueLabelValue } from "../src/directory/get-issue-label-value";
import { getIssuePriceLabel } from "../src/directory/get-issue-price-label";
import { getRepoCredentials } from "../src/directory/get-repo-credentials";
import { getRepoUrls } from "../src/directory/get-repo-urls";
import { getRepositoryIssues } from "../src/directory/get-repository-issues";
import { getSocialMediaText } from "../src/directory/get-social-media-text";

beforeAll(() => server.listen());
Expand Down Expand Up @@ -104,7 +104,7 @@ describe("GitHub items", () => {

test("Get all issues", async () => {
db.issue.create({ ...githubDevpoolIssueTemplate, repo: DEVPOOL_REPO_NAME, owner: DEVPOOL_OWNER_NAME });
const issues = await getAllIssues(DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME);
const issues = await getRepositoryIssues(DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME);
expect(issues).toMatchObject([githubDevpoolIssueTemplate]);
});
});
Loading

0 comments on commit ce4b604

Please sign in to comment.