Skip to content

Commit

Permalink
feat(schema): updated to match new database schema
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherpickering committed Jul 26, 2022
1 parent abd0d98 commit 829f5d4
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 58 deletions.
16 changes: 8 additions & 8 deletions atlas_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,26 @@ def build_doc(collection: SimpleNamespace) -> Dict:

cursor.execute(
"""select
p.DataProjectID as collection_id
p.collectionid as collection_id
, p.name as name
, p.Purpose as search_summary
, p.Description as description
, p.LastUpdateDate as modified_at
, updater.Fullname_calc as modified_by
, case when isnull((select Value from app.GlobalSiteSettings where Name = 'collections_search_visibility'),'N') = 'N' or Hidden='Y' then 'N' else 'Y' end as visible
, STUFF((select '~|~' + i.name from app.Initiative i where i.DataInitiativeID=p.datainitiativeid and isnull(i.Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') initiative_name
, STUFF((select '~|~' + i.description from app.Initiative i where i.DataInitiativeID=p.datainitiativeid and isnull(i.Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') initiative_description
, STUFF((select '~|~' + i.name from app.Initiative i where i.InitiativeID=p.initiativeid and isnull(i.Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') initiative_name
, STUFF((select '~|~' + i.description from app.Initiative i where i.InitiativeID=p.initiativeid and isnull(i.Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') initiative_description
, STUFF((select '~|~' + t.name from app.CollectionTerm a inner join app.term t on a.TermId = t.termid where a.DataProjectId=p.DataProjectID FOR XML PATH('')), 1, 3, '') term_name
, STUFF((select '~|~' + t.Summary + '~|~' + t.TechnicalDefinition from app.CollectionTerm a inner join app.term t on a.termid = t.termid where a.DataProjectId=p.DataProjectID FOR XML PATH('')), 1, 3, '')term_description
, STUFF((select '~|~' + t.name from app.CollectionTerm a inner join app.term t on a.TermId = t.termid where a.collectionid=p.collectionid FOR XML PATH('')), 1, 3, '') term_name
, STUFF((select '~|~' + t.Summary + '~|~' + t.TechnicalDefinition from app.CollectionTerm a inner join app.term t on a.termid = t.termid where a.collectionid=p.collectionid FOR XML PATH('')), 1, 3, '')term_description
, STUFF((select '~|~' + r.name from app.CollectionReport a inner join dbo.ReportObject r on a.ReportId = r.ReportObjectID left outer join app.reportobject_doc d on r.reportobjectid = d.reportobjectid where a.DataProjectId=p.DataProjectID and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') report_name
, STUFF((select '~|~' + r.DisplayTitle from app.CollectionReport a inner join dbo.ReportObject r on a.ReportId = r.ReportObjectID left outer join app.reportobject_doc d on r.reportobjectid = d.reportobjectid where a.DataProjectId=p.DataProjectID and r.DisplayTitle <> NULL and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') linked_name
, STUFF((select '~|~' + r.Description + '~|~' + r.DetailedDescription + '~|~' + r.RepositoryDescription + '~|~' + d.DeveloperDescription + '~|~' + d.KeyAssumptions from app.CollectionReport a inner join dbo.ReportObject r on a.ReportId = r.ReportObjectID left outer join app.ReportObject_doc d on r.ReportObjectID = d.ReportObjectID where a.DataProjectId=p.DataProjectID and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') linked_description
, STUFF((select '~|~' + r.name from app.CollectionReport a inner join dbo.ReportObject r on a.ReportId = r.ReportObjectID left outer join app.reportobject_doc d on r.reportobjectid = d.reportobjectid where a.collectionid=p.collectionid and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') report_name
, STUFF((select '~|~' + r.DisplayTitle from app.CollectionReport a inner join dbo.ReportObject r on a.ReportId = r.ReportObjectID left outer join app.reportobject_doc d on r.reportobjectid = d.reportobjectid where a.collectionid=p.collectionid and r.DisplayTitle <> NULL and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') linked_name
, STUFF((select '~|~' + r.Description + '~|~' + r.DetailedDescription + '~|~' + r.RepositoryDescription + '~|~' + d.DeveloperDescription + '~|~' + d.KeyAssumptions from app.CollectionReport a inner join dbo.ReportObject r on a.ReportId = r.ReportObjectID left outer join app.ReportObject_doc d on r.ReportObjectID = d.ReportObjectID where a.collectionid=p.collectionid and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') linked_description
from app.Collection p
Expand Down
20 changes: 10 additions & 10 deletions atlas_initiatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def build_doc(initiative: SimpleNamespace) -> Dict:

cursor.execute(
"""select
i.DataInitiativeID as initiative_id
i.InitiativeID as initiative_id
, i.name as name
, ops_owner.Fullname_calc as ops_owner
, description as description
Expand All @@ -103,21 +103,21 @@ def build_doc(initiative: SimpleNamespace) -> Dict:
, i.LastUpdateDate as modified_at
, updater.Fullname_calc as modified_by
, case when isnull((select Value from app.GlobalSiteSettings where Name = 'initiatives_search_visibility'),'N') = 'N' or i.Hidden='Y' then 'N' else 'Y' end as visible
, STUFF((select '~|~' + p.name from app.Collection p where i.DataInitiativeID=p.datainitiativeid and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') collection_name
, STUFF((select '~|~' + p.Purpose + '~|~' + p.description from app.Collection p where i.DataInitiativeID=p.datainitiativeid and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') collection_description
, STUFF((select '~|~' + p.name from app.Collection p where i.InitiativeID=p.initiativeid and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') collection_name
, STUFF((select '~|~' + p.Purpose + '~|~' + p.description from app.Collection p where i.InitiativeID=p.initiativeid and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') collection_description
, STUFF((select '~|~' + t.name from app.Collection p inner join app.CollectionTerm a on p.DataProjectID = a.DataProjectId inner join app.term t on a.TermId=t.TermId where i.DataInitiativeID=p.datainitiativeid and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') term_name
, STUFF((select '~|~' + t.Summary + '~|~' + t.TechnicalDefinition from app.Collection p inner join app.CollectionTerm a on p.DataProjectID = a.DataProjectId inner join app.term t on a.TermId=t.TermId where i.DataInitiativeID=p.datainitiativeid and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') term_description
, STUFF((select '~|~' + t.name from app.Collection p inner join app.CollectionTerm a on p.collectionid = a.collectionid inner join app.term t on a.TermId=t.TermId where i.InitiativeID=p.initiativeid and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') term_name
, STUFF((select '~|~' + t.Summary + '~|~' + t.TechnicalDefinition from app.Collection p inner join app.CollectionTerm a on p.collectionid = a.collectionid inner join app.term t on a.TermId=t.TermId where i.InitiativeID=p.initiativeid and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') term_description
, STUFF((select '~|~' + t.name from app.Collection p inner join app.CollectionReport a on p.DataProjectID = a.DataProjectId inner join dbo.ReportObject t on a.ReportId = t.ReportObjectID left outer join app.reportobject_doc d on t.reportobjectid = d.reportobjectid where i.DataInitiativeID=p.datainitiativeid and isnull(p.Hidden,'N')='N' and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') report_name
, STUFF((select '~|~' + t.DisplayTitle from app.Collection p inner join app.CollectionReport a on p.DataProjectID = a.DataProjectId inner join dbo.ReportObject t on a.ReportId = t.ReportObjectID left outer join app.reportobject_doc d on d.reportobjectid = t.reportobjectid where i.DataInitiativeID=p.datainitiativeid and isnull(p.Hidden,'N')='N' and displaytitle <> NULL and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') linked_name
, STUFF((select '~|~' + r.Description + '~|~' + r.DetailedDescription + '~|~' + r.RepositoryDescription + '~|~' + d.DeveloperDescription + '~|~' + d.KeyAssumptions from app.Collection p inner join app.CollectionReport a on p.DataProjectID = a.DataProjectId inner join dbo.ReportObject r on r.ReportObjectID = a.ReportId left outer join app.ReportObject_doc d on r.ReportObjectID = d.ReportObjectID where i.DataInitiativeID=p.datainitiativeid and isnull(p.Hidden,'N')='N' and r.DefaultVisibilityYN = 'Y' and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') report_description
, STUFF((select '~|~' + t.name from app.Collection p inner join app.CollectionReport a on p.collectionid = a.collectionid inner join dbo.ReportObject t on a.ReportId = t.ReportObjectID left outer join app.reportobject_doc d on t.reportobjectid = d.reportobjectid where i.InitiativeID=p.initiativeid and isnull(p.Hidden,'N')='N' and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') report_name
, STUFF((select '~|~' + t.DisplayTitle from app.Collection p inner join app.CollectionReport a on p.collectionid = a.collectionid inner join dbo.ReportObject t on a.ReportId = t.ReportObjectID left outer join app.reportobject_doc d on d.reportobjectid = t.reportobjectid where i.InitiativeID=p.initiativeid and isnull(p.Hidden,'N')='N' and displaytitle <> NULL and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') linked_name
, STUFF((select '~|~' + r.Description + '~|~' + r.DetailedDescription + '~|~' + r.RepositoryDescription + '~|~' + d.DeveloperDescription + '~|~' + d.KeyAssumptions from app.Collection p inner join app.CollectionReport a on p.collectionid = a.collectionid inner join dbo.ReportObject r on r.ReportObjectID = a.ReportId left outer join app.ReportObject_doc d on r.ReportObjectID = d.ReportObjectID where i.InitiativeID=p.initiativeid and isnull(p.Hidden,'N')='N' and r.DefaultVisibilityYN = 'Y' and isnull(d.Hidden,'N') = 'N' FOR XML PATH('')), 1, 3, '') report_description
from app.Initiative i
left outer join dbo.[User] ops_owner on i.OperationOwnerID = ops_owner.UserId
left outer join dbo.[User] exec_owner on i.OperationOwnerID = exec_owner.UserId
left outer join app.FinancialImpact f on i.FinancialImpact = f.FinancialImpactId
left outer join app.StrategicImportance s on s.StrategicImportanceId = i.StrategicImportance
left outer join app.FinancialImpact f on i.FinancialImpact = f.id
left outer join app.StrategicImportance s on s.id = i.StrategicImportance
left outer join dbo.[User] updater on updater.UserId = i.LastUpdateUser
"""
)
Expand Down
44 changes: 22 additions & 22 deletions atlas_lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,73 +32,73 @@ def build_doc(lookup: SimpleNamespace) -> Dict:
cursor.execute(
"""
select
concat('financial_impact_', cast(FinancialImpactId as nvarchar)) as id,
concat('financial_impact_', cast(id as nvarchar)) as id,
'financial_impact' as item_type,
Name as 'item_name',
FinancialImpactId as 'atlas_id'
id as 'atlas_id'
from app.FinancialImpact
union all
select
concat('fragility_', cast(FragilityID as nvarchar)) as id,
concat('fragility_', cast(id as nvarchar)) as id,
'fragility' as item_type,
FragilityName as 'item_name',
FragilityID as 'atlas_id'
name as 'item_name',
id as 'atlas_id'
from app.Fragility
union all
select
concat('fragility_tag_', cast(FragilityTagID as nvarchar)) as id,
concat('fragility_tag_', cast(id as nvarchar)) as id,
'fragility_tag' as item_type,
FragilityTagName as 'item_name',
FragilityTagID as 'atlas_id'
name as 'item_name',
id as 'atlas_id'
from app.FragilityTag
union all
select
concat('maintenance_log_status_', cast(MaintenanceLogStatusID as nvarchar)) as id,
concat('maintenance_log_status_', cast(id as nvarchar)) as id,
'maintenance_log_status' as item_type,
MaintenanceLogStatusName as 'item_name',
MaintenanceLogStatusID as 'atlas_id'
name as 'item_name',
id as 'atlas_id'
from app.MaintenanceLogStatus
union all
select
concat('maintenance_schedule_', cast(MaintenanceScheduleID as nvarchar)) as id,
concat('maintenance_schedule_', cast(id as nvarchar)) as id,
'maintenance_schedule' as item_type,
MaintenanceScheduleName as 'item_name',
MaintenanceScheduleID as 'atlas_id'
name as 'item_name',
id as 'atlas_id'
from app.MaintenanceSchedule
union all
select
concat('organizational_value_', cast(OrganizationalValueId as nvarchar)) as id,
concat('organizational_value_', cast(id as nvarchar)) as id,
'organizational_value' as item_type,
OrganizationalValueName as 'item_name',
OrganizationalValueId as 'atlas_id'
name as 'item_name',
id as 'atlas_id'
from app.OrganizationalValue
union all
select
concat('run_frequency_', cast(EstimatedRunFrequencyId as nvarchar)) as id,
concat('run_frequency_', cast(id as nvarchar)) as id,
'run_frequency' as item_type,
EstimatedRunFrequencyName as 'item_name',
EstimatedRunFrequencyId as 'atlas_id'
name as 'item_name',
id as 'atlas_id'
from app.EstimatedRunFrequency
union all
select
concat('strategic_importance_', cast(StrategicImportanceId as nvarchar)) as id,
concat('strategic_importance_', cast(id as nvarchar)) as id,
'strategic_importance' as item_type,
Name as 'item_name',
StrategicImportanceId as 'atlas_id'
id as 'atlas_id'
from app.StrategicImportance
union all
Expand Down
28 changes: 14 additions & 14 deletions atlas_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def build_doc(report: SimpleNamespace) -> Dict:
, r.description as description
, r.DetailedDescription as detailed_description
, r.RepositoryDescription as system_description
, STUFF((select '~|~' + t.name from app.ReportTagLinks l inner join app.Tags t on l.tagid = t.tagid where l.reportid = r.ReportObjectID FOR XML PATH('')), 1, 3, '') as certification_tag
, STUFF((select '~|~' + t.name from dbo.ReportTagLinks l inner join dbo.Tags t on l.tagid = t.tagid where l.reportid = r.ReportObjectID FOR XML PATH('')), 1, 3, '') as certification_tag
, isnull(report_type.ShortName, report_type.name) as report_type
, r.reportobjecttypeid as report_type_id
, author.Fullname_calc as created_by
Expand All @@ -147,7 +147,7 @@ def build_doc(report: SimpleNamespace) -> Dict:
, r.LastLoadDate as etl_date
, r.ReportObjectUrl as run_url
, STUFF((select '~|~' + q.Query from dbo.ReportObjectQuery q where q.ReportObjectId = r.ReportObjectID FOR XML PATH('')), 1, 3, '') query
, STUFF((select '~|~' + f.FragilityTagName from app.ReportObjectDocFragilityTags t inner join app.FragilityTag f on t.FragilityTagID = f.FragilityTagID where t.ReportObjectId = r.ReportObjectID FOR XML PATH('')), 1, 3, '') tag
, STUFF((select '~|~' + f.name from app.ReportObjectDocFragilityTags t inner join app.FragilityTag f on t.FragilityTagID = f.id where t.ReportObjectId = r.ReportObjectID FOR XML PATH('')), 1, 3, '') tag
, case when isnull(cast(d.ReportObjectID as nvarchar),'N') = 'N' then 'N' else 'Y' end as documented
Expand All @@ -156,11 +156,11 @@ def build_doc(report: SimpleNamespace) -> Dict:
, doc_updater.Fullname_calc as updated_by
, doc_creator.Fullname_calc as created_by
, d.LastUpdateDateTime as last_updated
, ms.MaintenanceScheduleName as maintenance_schedule
, ms.name as maintenance_schedule
, isnull(d.ExecutiveVisibilityYN, 'N') as executive_visibility
, fr.FragilityName as fragility
, rf.EstimatedRunFrequencyName as estimated_run_frequency
, ov.OrganizationalValueName as organizational_value
, fr.name as fragility
, rf.name as estimated_run_frequency
, ov.name as organizational_value
, d.CreatedDateTime as created
, requester.Fullname_calc as requester
, ops_owner.Fullname_calc as ops_owner
Expand All @@ -170,11 +170,11 @@ def build_doc(report: SimpleNamespace) -> Dict:
, STUFF((select '~|~' + t.name from app.ReportObjectDocTerms dt inner join app.Term t on dt.TermId = t.termid where dt.reportobjectid = r.ReportObjectID FOR XML PATH('')), 1, 3, '') term_name
, STUFF((select '~|~' + t.Summary + '~|~' + t.TechnicalDefinition from app.ReportObjectDocTerms dt inner join app.Term t on dt.TermId = t.termid where dt.reportobjectid = r.ReportObjectID FOR XML PATH('')), 1, 3, '') term_description
, STUFF((select '~|~' + p.name from app.CollectionReport a inner join app.Collection p on a.DataProjectId = p.DataProjectID where a.ReportId = r.ReportObjectID and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') collection_name
, STUFF((select '~|~' + p.Description + '~|~' + p.Purpose from app.CollectionReport a inner join app.Collection p on a.DataProjectId = p.DataProjectID where a.ReportId = r.ReportObjectID and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') collection_description
, STUFF((select '~|~' + p.name from app.CollectionReport a inner join app.Collection p on a.collectionid = p.collectionid where a.ReportId = r.ReportObjectID and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') collection_name
, STUFF((select '~|~' + p.Description + '~|~' + p.Purpose from app.CollectionReport a inner join app.Collection p on a.collectionid = p.collectionid where a.ReportId = r.ReportObjectID and isnull(Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') collection_description
, STUFF((select '~|~' + i.name from app.CollectionReport a inner join app.Collection p on a.DataProjectId = p.DataProjectID inner join app.Initiative i on i.DataInitiativeID=p.DataInitiativeID where a.ReportId = r.ReportObjectID and isnull(p.Hidden,'N')='N' and isnull(i.Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') initiative_name
, STUFF((select '~|~' + i.Description + '~|~' + p.Purpose from app.CollectionReport a inner join app.Collection p on a.DataProjectId = p.DataProjectID inner join app.Initiative i on i.DataInitiativeID=p.DataInitiativeID where a.ReportId = r.ReportObjectID and isnull(p.Hidden,'N')='N' and isnull(i.Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') initiative_description
, STUFF((select '~|~' + i.name from app.CollectionReport a inner join app.Collection p on a.collectionid = p.collectionid inner join app.Initiative i on i.InitiativeID=p.InitiativeID where a.ReportId = r.ReportObjectID and isnull(p.Hidden,'N')='N' and isnull(i.Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') initiative_name
, STUFF((select '~|~' + i.Description + '~|~' + p.Purpose from app.CollectionReport a inner join app.Collection p on a.collectionid = p.collectionid inner join app.Initiative i on i.InitiativeID=p.InitiativeID where a.ReportId = r.ReportObjectID and isnull(p.Hidden,'N')='N' and isnull(i.Hidden,'N')='N' FOR XML PATH('')), 1, 3, '') initiative_description
Expand All @@ -185,10 +185,10 @@ def build_doc(report: SimpleNamespace) -> Dict:
left outer join #user_temp as updater on r.LastModifiedByUserID = updater.UserId
left outer join #user_temp as doc_updater on d.UpdatedBy = doc_updater.UserId
left outer join #user_temp as doc_creator on d.UpdatedBy = doc_creator.UserId
left outer join app.MaintenanceSchedule ms on ms.MaintenanceScheduleID = d.MaintenanceScheduleID
left outer join app.Fragility fr on fr.FragilityID = d.FragilityID
left outer join app.EstimatedRunFrequency rf on rf.EstimatedRunFrequencyID = d.EstimatedRunFrequencyID
left outer join app.OrganizationalValue ov on ov.OrganizationalValueID = d.OrganizationalValueID
left outer join app.MaintenanceSchedule ms on ms.id = d.MaintenanceScheduleID
left outer join app.Fragility fr on fr.id = d.FragilityID
left outer join app.EstimatedRunFrequency rf on rf.id = d.EstimatedRunFrequencyID
left outer join app.OrganizationalValue ov on ov.id = d.OrganizationalValueID
left outer join #user_temp as requester on requester.UserId = d.Requester
left outer join #user_temp as ops_owner on ops_owner.UserId = d.OperationalOwnerUserID
Expand Down
Loading

0 comments on commit 829f5d4

Please sign in to comment.