Skip to content

Commit

Permalink
fix: show proper message when a new model is created in pr
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaagrav committed May 11, 2023
1 parent 6adc56f commit f720486
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/main/print-downstream-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@ import {
import {
renderDownstreamAssetsComment,
getChangedFiles,
getAssetName, createIssueComment, checkCommentExists, deleteComment, getImageURL
getAssetName, createIssueComment, checkCommentExists, deleteComment, getImageURL, getConnectorImage
} from "../utils/index.js";

export default async function printDownstreamAssets({octokit, context}) {
const changedFiles = await getChangedFiles(octokit, context);
let comments = ``;
let totalChangedFiles = 0;

for (const {fileName, filePath} of changedFiles) {
for (const {fileName, filePath, status} of changedFiles) {
const assetName = await getAssetName({octokit, context, fileName, filePath});
const asset = await getAsset({name: assetName});

if (totalChangedFiles !== 0)
comments += '\n\n---\n\n';

if (status === "added") {
comments += `### ${getConnectorImage('dbt')} <b>${fileName}</b> 🆕
Its a new model and not present in Atlan yet, you'll see the downstream impact for it after its present in Atlan.`
totalChangedFiles++
continue;
}

if (asset.error) {
comments += asset.error;
totalChangedFiles++
Expand Down
3 changes: 2 additions & 1 deletion src/utils/file-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ export async function getChangedFiles(octokit, context) {
);

var changedFiles = res.data
.map(({filename}) => {
.map(({filename, status}) => {
try {
const [modelName] = filename.match(/.*models\/(.*)\.sql/)[1].split('/').reverse()[0].split('.');

if (modelName) {
return {
fileName: modelName,
filePath: filename,
status
};
}
} catch (e) {
Expand Down

0 comments on commit f720486

Please sign in to comment.