* feat: perform pending migrations in start command * feat: log error when DB connection is refused * feat: log error when Redis connection is refused * refactor: fix type errors * fix: correct server and copy graphql schema * fix: differentiate migrations by env * chore: remove dev executable * chore: fix typo in default postgresUsername * fix: copy json files into dist folder * chore(cli): add dev script * chore: pull non-dev logs to info level * feat(cli): run app in start command * fix(backend): remove default count in Connection * fix(cli): remove .eslintrc usage in lint script * refactor: remove disableMigrationsListValidation * refactor: make Step optional in ExecutionStep * refactor: make Flow optional in Step
43 lines
990 B
TypeScript
43 lines
990 B
TypeScript
import App from '../../models/app';
|
|
import Context from '../../types/express/context';
|
|
import { IApp, IConnection } from '@automatisch/types';
|
|
|
|
type Params = {
|
|
name: string;
|
|
};
|
|
|
|
const getConnectedApps = async (
|
|
_parent: unknown,
|
|
params: Params,
|
|
context: Context
|
|
) => {
|
|
let apps = App.findAll(params.name);
|
|
|
|
const connections = await context.currentUser
|
|
.$relatedQuery('connections')
|
|
.select('connections.key')
|
|
.count('connections.id as count')
|
|
.where({ verified: true })
|
|
.groupBy('connections.key');
|
|
|
|
const connectionKeys = connections.map((connection) => connection.key);
|
|
|
|
apps = apps
|
|
.filter((app: IApp) => connectionKeys.includes(app.key))
|
|
.map((app: IApp) => {
|
|
const connection = connections.find(
|
|
(connection) => (connection as IConnection).key === app.key
|
|
);
|
|
|
|
if (connection) {
|
|
app.connectionCount = connection.count;
|
|
}
|
|
|
|
return app;
|
|
});
|
|
|
|
return apps;
|
|
};
|
|
|
|
export default getConnectedApps;
|