Skip to content

Instantly share code, notes, and snippets.

@tkellen
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkellen/246058f6d999de7b06c3 to your computer and use it in GitHub Desktop.
Save tkellen/246058f6d999de7b06c3 to your computer and use it in GitHub Desktop.
const _ = require('lodash');
const depMap = require('./depmap');
function depMapper (table) {
var deps = depMap[table].reverse();
return _.uniq(_.chain(deps).reduce(function (result, dep) {
result.push(depMapper(dep));
return result;
}, []).flatten().value().concat(deps));
};
var table = 'utilization';
console.log(table+' needs '+depMapper(table));
{
"applicant_comment": [
"applicant",
"employee"
],
"applicant_state": [],
"applicant": [
"position",
"applicant_state"
],
"bill_method": [],
"bills": [
"project",
"bill_method"
],
"board": [],
"deployment": [
"service"
],
"employee": [
"position"
],
"event_type": [
"event_event_type"
],
"event": [],
"hr_task_group": [],
"hr_task_type": [],
"hr_task": [
"hr_task_type",
"hr_task_group"
],
"leave_request_activity": [
"leave_request",
"leave_request_state"
],
"leave_request_state": [],
"leave_request": [
"employee",
"utilization_type"
],
"organization": [],
"position": [],
"project_phase": [
"project"
],
"project_phase_review": [
"project_phase"
],
"project_sow_state": [],
"project_sow": [
"project",
"project_sow_state"
],
"project_type": [],
"project": [
"employee",
"organization",
"position",
"utilization_type"
],
"service": [
"employee"
],
"sketch_calendar": [],
"team": [],
"utilization_type": [],
"utilization": [
"utilization_type",
"employee",
"position",
"project_phase",
"sketch_calendar"
],
"venue": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment