Skip to content

Commit 8c67624

Browse files
authored
cache repo issues
1 parent 2da8088 commit 8c67624

File tree

6 files changed

+58
-21
lines changed

6 files changed

+58
-21
lines changed

Diff for: dist/index.js

+21-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: sprint178Config.json

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
"performance"
2020
],
2121
"priorityLabels": ["p0", "p1"],
22+
"developers": [
23+
"legomushroom",
24+
"plisy",
25+
"GideonCheruiyot",
26+
"VincentDondain",
27+
"wachaudh",
28+
"klvnraju"
29+
],
2230
"isCheckListItems": true
2331
},
2432
{

Diff for: src/main.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,19 @@ const processConfigRecord = async (
8080
return;
8181
}
8282

83-
console.log(`Config schema validation passed.`);
83+
console.log(`- Config schema validation passed.`);
8484

8585
const repoProjects = await projectKit.getAllProjects(config.repos);
8686

87+
const projectsWithData = [];
8788
for (let { repo, projects } of repoProjects) {
88-
const projectsWithData = await Promise.all(
89-
projects.map(async (project) => {
90-
const data = await getProjectData(projectKit, config, project);
91-
return {
89+
for (let project of projects) {
90+
console.log(`- Getting Project data for ${project.project.name}.`);
91+
projectsWithData.push({
9292
project,
93-
data,
94-
};
95-
}),
96-
);
93+
data: await getProjectData(projectKit, config, project),
94+
});
95+
}
9796

9897
const result = projectsWithData.map(({ project, data }) => {
9998
return renderProject(data, project, config);

Diff for: src/octokit/ProjectsOctoKit.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { IParsedRepo } from '../interfaces/IParsedRepo';
1717
import { ICardWithIssue } from '../interfaces/ICardWithIssue';
1818
import { IConfig } from '../interfaces/IConfig';
1919
import { isNewCard } from '../utils/isNewCard';
20+
import { measure } from '../utils/measure';
2021

2122
interface IColumnWithCards {
2223
column: TProjectColumn;
@@ -174,12 +175,28 @@ export class ProjectsOctoKit extends OctoKitBase {
174175
return issues;
175176
};
176177

178+
private reposCache: Record<string, TRepoIssue[] | undefined> = {};
179+
177180
public getReposIssues = async (
178181
repos: IParsedRepo[],
179182
): Promise<TRepoIssue[]> => {
180183

181184
const resultPromises: Promise<TRepoIssue[]>[] = repos.map(async (repo) => {
182-
return await this.getRepoIssues(repo);
185+
const repoKey = `${repo.owner}/${repo.repo}`;
186+
187+
return await measure(
188+
`Getting new isues for "${repoKey}"`,
189+
async () => {
190+
const cachedIssues = this.reposCache[repoKey];
191+
if (cachedIssues) {
192+
return cachedIssues;
193+
}
194+
195+
const result = await this.getRepoIssues(repo);
196+
this.reposCache[repoKey] = result;
197+
198+
return result;
199+
});
183200
});
184201

185202
return flattenArray(await Promise.all(resultPromises));

Diff for: src/utils/getProjectData.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export const getProjectData = async (
2323
const repos = await measure('Fetching Repos', async () => {
2424
return await projectKit.getCardRepos(cards);
2525
});
26-
console.log('Repos: ', repos);
26+
27+
console.log('- Repos: ', repos);
2728

2829
const issues = await measure('Fetching Issues', async () => {
2930
return await projectKit.getReposIssues(repos);

0 commit comments

Comments
 (0)