You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Select("model_dbs.name as Key, COUNT(DISTINCT(relationship_definition_dbs.id)) as Count").
122
-
Group("model_dbs.name").
123
-
Scan(&rows).Error
124
-
iferr!=nil {
125
-
returnnil, err
126
-
}
127
-
summary.ByModel=rows
128
-
}
129
-
ifshouldCompute(RelationshipSummaryByKind) {
130
-
varrows []RelationshipGroupEntry
131
-
err:=base.Session(&gorm.Session{}).
132
-
Select("relationship_definition_dbs.kind as Key, COUNT(DISTINCT(relationship_definition_dbs.id)) as Count").
133
-
Group("relationship_definition_dbs.kind").
134
-
Scan(&rows).Error
135
-
iferr!=nil {
136
-
returnnil, err
137
-
}
138
-
summary.ByKind=rows
118
+
typedimensionInfostruct {
119
+
dimRelationshipSummaryDimension
120
+
selectExprstring
121
+
groupExprstring
122
+
receiver*[]RelationshipGroupEntry
139
123
}
140
-
ifshouldCompute(RelationshipSummaryByType) {
141
-
varrows []RelationshipGroupEntry
142
-
err:=base.Session(&gorm.Session{}).
143
-
Select("relationship_definition_dbs.type as Key, COUNT(DISTINCT(relationship_definition_dbs.id)) as Count").
144
-
Group("relationship_definition_dbs.type").
145
-
Scan(&rows).Error
146
-
iferr!=nil {
147
-
returnnil, err
148
-
}
149
-
summary.ByType=rows
124
+
125
+
dimensions:= []dimensionInfo{
126
+
{RelationshipSummaryByModel, "model_dbs.name as Key, COUNT(DISTINCT(relationship_definition_dbs.id)) as Count", "model_dbs.name", &summary.ByModel},
127
+
{RelationshipSummaryByKind, "relationship_definition_dbs.kind as Key, COUNT(DISTINCT(relationship_definition_dbs.id)) as Count", "relationship_definition_dbs.kind", &summary.ByKind},
128
+
{RelationshipSummaryByType, "relationship_definition_dbs.type as Key, COUNT(DISTINCT(relationship_definition_dbs.id)) as Count", "relationship_definition_dbs.type", &summary.ByType},
129
+
{RelationshipSummaryBySubType, "relationship_definition_dbs.sub_type as Key, COUNT(DISTINCT(relationship_definition_dbs.id)) as Count", "relationship_definition_dbs.sub_type", &summary.BySubType},
150
130
}
151
-
ifshouldCompute(RelationshipSummaryBySubType) {
152
-
varrows []RelationshipGroupEntry
153
-
err:=base.Session(&gorm.Session{}).
154
-
Select("relationship_definition_dbs.sub_type as Key, COUNT(DISTINCT(relationship_definition_dbs.id)) as Count").
// partial error is not tolerated so the populated summary should all be correct
110
-
ifshouldCompute(ComponentSummaryByModel) {
111
-
varrows []ComponentGroupEntry
112
-
err:=base.Session(&gorm.Session{}).
113
-
Select("model_dbs.name as key, COUNT(DISTINCT component_definition_dbs.id) as count").
114
-
Group("model_dbs.name").
115
-
Scan(&rows).Error
116
-
iferr!=nil {
117
-
returnnil, err
118
-
}
119
-
summary.ByModel=rows
109
+
typedimensionInfostruct {
110
+
dimComponentSummaryDimension
111
+
selectExprstring
112
+
groupExprstring
113
+
receiver*[]ComponentGroupEntry
120
114
}
121
-
ifshouldCompute(ComponentSummaryByCategory) {
122
-
varrows []ComponentGroupEntry
123
-
err:=base.Session(&gorm.Session{}).
124
-
Select("category_dbs.name as key, COUNT(DISTINCT component_definition_dbs.id) as count").
125
-
Group("category_dbs.name").
126
-
Scan(&rows).Error
127
-
iferr!=nil {
128
-
returnnil, err
129
-
}
130
-
summary.ByCategory=rows
115
+
116
+
dimensions:= []dimensionInfo{
117
+
{ComponentSummaryByModel, "model_dbs.name as Key, COUNT(DISTINCT(component_definition_dbs.id)) as Count", "model_dbs.name", &summary.ByModel},
118
+
{ComponentSummaryByCategory, "model_dbs.category_id as Key, COUNT(DISTINCT(component_definition_dbs.id)) as Count", "model_dbs.category_id", &summary.ByCategory},
119
+
{ComponentSummaryByRegistrant, "connections.name as Key, COUNT(DISTINCT(component_definition_dbs.id)) as Count", "connections.name", &summary.ByRegistrant},
131
120
}
132
-
ifshouldCompute(ComponentSummaryByRegistrant) {
133
-
varrows []ComponentGroupEntry
134
-
err:=base.Session(&gorm.Session{}).
135
-
Select("connections.name as key, COUNT(DISTINCT component_definition_dbs.id) as count").
136
-
Group("connections.name").
137
-
Scan(&rows).Error
138
-
iferr!=nil {
139
-
returnnil, err
121
+
122
+
// partial error is not tolerated so the populated summary should all be correct
0 commit comments