Skip to content

Commit

Permalink
fix: add back commitInfo actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Silberman committed Jun 22, 2019
1 parent d357d03 commit 4fa4254
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/@best/frontend/server/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Router } from 'express'
import { loadDbFromConfig } from '@best/api-db'
import { GithubApplicationFactory } from '@best/github-integration'
import { ApiDatabaseConfig, FrontendConfig } from '@best/types';
import { FrontendConfig } from '@best/types';

export default (config: FrontendConfig): Router => {
const db = loadDbFromConfig(config);
Expand Down
31 changes: 31 additions & 0 deletions packages/@best/frontend/src/modules/store/actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,35 @@ export function selectProject(project, shouldResetView) {
dispatch(fetchBenchmarks(project));
dispatch({ type: PROJECT_SELECTED, id: project.id });
};
}

/*
* COMMIT INFO
*/

function normalizeCommit(commit) {
return commit.slice(0, 7);
}

function shouldFetchCommitInfo(state, commit) {
return !state.commitInfo.hasOwnProperty(normalizeCommit(commit));
}

function commitInfoReceived(commit, commitInfo) {
return { type: COMMIT_INFO_RECEIVED, commit: normalizeCommit(commit), commitInfo };
}

function fetchCommitInfo(commit) {
return async (dispatch) => {
const commitInfo = await api.fetchCommitInfo(commit);
dispatch(commitInfoReceived(commit, commitInfo));
}
}

export function fetchCommitInfoIfNeeded(commit) {
return (dispatch, getState) => {
if (shouldFetchCommitInfo(getState(), commit)) {
dispatch(fetchCommitInfo(commit));
}
}
}
4 changes: 4 additions & 0 deletions packages/@best/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export interface ApiDatabaseConfig {

export interface FrontendConfig {
apiDatabase: ApiDatabaseConfig;
githubConfig?: {
repo: string;
owner: string;
}
}

export interface CliConfig {
Expand Down
2 changes: 1 addition & 1 deletion packages/best-benchmarks/best.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ module.exports = {
"remoteRunner": "@best/runner-headless"
}
}
],
]
};

0 comments on commit 4fa4254

Please sign in to comment.