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

DAG fails to render if operation exists #248

Merged
merged 5 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## dbt-core 1.0.1 (TBD)
## dbt-core 1.0.4 (TBD)

- Add operations to nodes so the parents/child map can be resolved. ([#229](https://github.com/dbt-labs/dbt-docs/issues/229), [#248](https://github.com/dbt-labs/dbt-docs/pull/248))

## dbt-core 1.0.1 (January 03, 2022)

- Fix bug with missing exposure details. ([docs#228](https://github.com/dbt-labs/dbt-docs/pull/228))

Expand Down
2 changes: 2 additions & 0 deletions src/app/components/references/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ angular
return 'Exposures';
} else if (type == 'metric') {
return 'Metrics';
} else if (type == 'operation') {
emmyoop marked this conversation as resolved.
Show resolved Hide resolved
return 'Operations';
} else {
return 'Nodes';
}
Expand Down
1 change: 1 addition & 0 deletions src/app/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ require('./macro');
require('./analysis');
require('./exposure');
require('./metric');
require('./operation');
67 changes: 67 additions & 0 deletions src/app/docs/operation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<style>
/* TODO */
.section-target {
top: -8em;
}

.noflex {
flex: 0 0 160px !important;
}

.highlight {
color: #24292e;
background-color: white;
}

</style>

<div class='app-scroll'>
<div class="app-links app-sticky">
<div class="app-title">
<div class="app-frame app-pad app-flush-bottom">
<h1>
<span class="break">{{ model.name }}</span>
<small>operation</small>
</h1>
</div>
</div>
<div class="app-frame app-pad-h">
<ul class="nav nav-tabs">
<li ui-sref-active='active'><a ui-sref="dbt.operation({'#': 'description'})">Description</a></li>
<li ui-sref-active='active' ng-show = "parentsLength != 0"><a ui-sref="dbt.operation({'#': 'depends_on'})">Depends On</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.operation({'#': 'code'})">SQL</a></li>
</ul>
</div>
</div>
<div class="app-details">
<div class="app-frame app-pad">
<section class="section">
<div class="section-target" id="description"></div>
<div class="section-content">
<h6>Description</h6>
<div class="panel">
<div class="panel-body">
<div ng-if="model.description" class="model-markdown" marked="model.description"></div>
<div ng-if="!model.description">This {{ model.resource_type }} is not currently documented</div>
</div>
</div>
</div>
</section>

<section class="section" ng-show = "parentsLength != 0">
<div class="section-target" id="depends_on"></div>
<div class="section-content">
<h6>Depends On</h6>
<reference-list references="parents" node="model" />
</div>
</section>

<section class="section">
<div class="section-target" id="code"></div>
<div class="section-content">
<code-block versions="versions" default="default_version"></code-block>
</div>
</section>
</div>
</div>
</div>
38 changes: 38 additions & 0 deletions src/app/docs/operation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';

const angular = require('angular');
const dag_utils = require('./dag_utils')
require("./styles.css");

angular
.module('dbt')
.controller('OperationCtrl', ['$scope', '$state', 'project', 'code', '$anchorScroll', '$location',
function($scope, $state, projectService, codeService, $anchorScroll, $location) {

$scope.model_uid = $state.params.unique_id;
$scope.tab = $state.params.tab;
$scope.project = projectService;
$scope.codeService = codeService;

$scope.versions = {}

$scope.model = {};
projectService.ready(function(project) {
let mod = project.nodes[$scope.model_uid];
$scope.model = mod;
$scope.references = dag_utils.getReferences(project, mod);
$scope.referencesLength = Object.keys($scope.references).length;
$scope.parents = dag_utils.getParents(project, mod);
$scope.parentsLength = Object.keys($scope.parents).length;

var default_compiled = '\n-- compiled SQL not found for this model\n';
$scope.versions = {
'Source': $scope.model.raw_sql,
'Compiled': $scope.model.compiled_sql || default_compiled
}

setTimeout(function() {
$anchorScroll();
}, 0);
})
}]);
9 changes: 9 additions & 0 deletions src/app/index.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const templates = {
macro: require('./docs/macro.html'),
exposure: require('./docs/exposure.html'),
metric: require('./docs/metric.html'),
operation: require('./docs/operation.html'),
}

angular
Expand Down Expand Up @@ -132,4 +133,12 @@ angular
unique_id: {type: 'string'}
},
})
.state('dbt.operation', {
url: 'operation/:unique_id?section&' + graph_params,
controller: 'OperationCtrl',
templateUrl: templates.operation,
params: {
unique_id: {type: 'string'}
},
})
}])
3 changes: 2 additions & 1 deletion src/app/services/graph.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ angular


_.each(_.filter(service.manifest.nodes, function(node) {
var is_graph_type = _.includes(['model', 'seed', 'source', 'snapshot', 'analysis', 'exposure', 'metric'], node.resource_type);
// operation needs to be a graph type so that the parent/child mpa can be resolved even though we won't be displaying it
var is_graph_type = _.includes(['model', 'seed', 'source', 'snapshot', 'analysis', 'exposure', 'metric', 'operation'], node.resource_type);
var is_singular_test = node.resource_type == 'test' && !node.hasOwnProperty('test_metadata');
return is_graph_type || is_singular_test;
}), function(node) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/node_selection_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ angular
'test',
'analysis',
'exposure',
'metric',
'metric'
],
depth: 1,
};
Expand Down