MCPcopy Create free account
hub / github.com/lightdash/lightdash / stepDbtRepoCheck

Function stepDbtRepoCheck

scripts/dev-github-reconcile.cjs:182–197  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

180}
181
182async function stepDbtRepoCheck(client) {
183 const secret = need('RUNNING_SECRET');
184 const org = await orgUuid(client);
185 const r = await client.query(
186 `SELECT project_uuid, encode(dbt_connection,'hex') AS hex
187 FROM projects WHERE organization_id=(SELECT organization_id FROM organizations WHERE organization_uuid=$1)
188 ORDER BY project_id LIMIT 1`, [org]);
189 if (!r.rows.length) { console.log('OK: no project to check'); return; }
190 let type = '?';
191 try { type = (JSON.parse(decrypt(Buffer.from(r.rows[0].hex, 'hex'), secret)).type) || '?'; } catch (_) {}
192 if (type === 'github' || type === 'gitlab') {
193 console.log(`OK: project ${r.rows[0].project_uuid} dbt_connection is '${type}' (writeback-capable)`);
194 } else {
195 console.log(`NEED: project ${r.rows[0].project_uuid} dbt_connection is '${type}', not github/gitlab — repoint it (guided: see the GitHub Integration section) for writeback to open PRs`);
196 }
197}
198
199async function installationToken(client) {
200 const secret = need('RUNNING_SECRET');

Callers 1

Calls 5

needFunction · 0.85
orgUuidFunction · 0.85
fromMethod · 0.80
decryptFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected