Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staging: show proper message when a new model is created in pr #96

Merged
merged 1 commit into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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