mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 12:25:22 +00:00
fix build errors and add index concurrency env var
This commit is contained in:
parent
54d14ea98e
commit
e17331a672
3 changed files with 19 additions and 15 deletions
|
|
@ -33,4 +33,6 @@ export const POSTHOG_HOST = getEnv(process.env.POSTHOG_HOST);
|
|||
|
||||
export const FALLBACK_GITHUB_TOKEN = getEnv(process.env.FALLBACK_GITHUB_TOKEN);
|
||||
export const FALLBACK_GITLAB_TOKEN = getEnv(process.env.FALLBACK_GITLAB_TOKEN);
|
||||
export const FALLBACK_GITEA_TOKEN = getEnv(process.env.FALLBACK_GITEA_TOKEN);
|
||||
export const FALLBACK_GITEA_TOKEN = getEnv(process.env.FALLBACK_GITEA_TOKEN);
|
||||
|
||||
export const INDEX_CONCURRENCY_MULTIPLE = getEnv(process.env.INDEX_CONCURRENCY_MULTIPLE);
|
||||
|
|
@ -5,6 +5,7 @@ import { DEFAULT_SETTINGS } from './constants.js';
|
|||
import { Redis } from 'ioredis';
|
||||
import { ConnectionManager } from './connectionManager.js';
|
||||
import { RepoManager } from './repoManager.js';
|
||||
import { INDEX_CONCURRENCY_MULTIPLE } from './environment.js';
|
||||
|
||||
const logger = createLogger('main');
|
||||
|
||||
|
|
@ -22,9 +23,14 @@ export const main = async (db: PrismaClient, context: AppContext) => {
|
|||
process.exit(1);
|
||||
});
|
||||
|
||||
const connectionManager = new ConnectionManager(db, DEFAULT_SETTINGS, redis);
|
||||
const settings = DEFAULT_SETTINGS;
|
||||
if (INDEX_CONCURRENCY_MULTIPLE) {
|
||||
settings.indexConcurrencyMultiple = parseInt(INDEX_CONCURRENCY_MULTIPLE);
|
||||
}
|
||||
|
||||
const connectionManager = new ConnectionManager(db, settings, redis);
|
||||
connectionManager.registerPollingCallback();
|
||||
|
||||
const repoManager = new RepoManager(db, DEFAULT_SETTINGS, redis, context);
|
||||
const repoManager = new RepoManager(db, settings, redis, context);
|
||||
await repoManager.blockingPollLoop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -502,14 +502,6 @@ export const makeOwner = async (newOwnerId: string, domain: string): Promise<{ s
|
|||
withAuth((session) =>
|
||||
withOwner(session, domain, async (orgId) => {
|
||||
const currentUserId = session.user.id;
|
||||
const currentUserRole = await prisma.userToOrg.findUnique({
|
||||
where: {
|
||||
orgId_userId: {
|
||||
userId: currentUserId,
|
||||
orgId,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (newOwnerId === currentUserId) {
|
||||
return {
|
||||
|
|
@ -602,30 +594,34 @@ const parseConnectionConfig = (connectionType: string, config: string) => {
|
|||
|
||||
const { numRepos, hasToken } = (() => {
|
||||
switch (connectionType) {
|
||||
case "github":
|
||||
case "github": {
|
||||
const githubConfig = parsedConfig as GithubConnectionConfig;
|
||||
return {
|
||||
numRepos: githubConfig.repos?.length,
|
||||
hasToken: !!githubConfig.token,
|
||||
}
|
||||
case "gitlab":
|
||||
}
|
||||
case "gitlab": {
|
||||
const gitlabConfig = parsedConfig as GitlabConnectionConfig;
|
||||
return {
|
||||
numRepos: gitlabConfig.projects?.length,
|
||||
hasToken: !!gitlabConfig.token,
|
||||
}
|
||||
case "gitea":
|
||||
}
|
||||
case "gitea": {
|
||||
const giteaConfig = parsedConfig as GiteaConnectionConfig;
|
||||
return {
|
||||
numRepos: giteaConfig.repos?.length,
|
||||
hasToken: !!giteaConfig.token,
|
||||
}
|
||||
case "gerrit":
|
||||
}
|
||||
case "gerrit": {
|
||||
const gerritConfig = parsedConfig as GerritConnectionConfig;
|
||||
return {
|
||||
numRepos: gerritConfig.projects?.length,
|
||||
hasToken: true, // gerrit doesn't use a token atm
|
||||
}
|
||||
}
|
||||
default:
|
||||
return {
|
||||
numRepos: undefined,
|
||||
|
|
|
|||
Loading…
Reference in a new issue