MCPcopy
hub / github.com/YMFE/yapi / groupDataStatis

Method groupDataStatis

exts/yapi-plugin-statistics/controller.js:132–165  ·  view source on GitHub ↗
(ctx)

Source from the content-addressed store, hash-verified

130 }
131
132 async groupDataStatis(ctx) {
133 try {
134 let groupData = await this.groupModel.list();
135 let result = [];
136 for (let i = 0; i < groupData.length; i++) {
137 let group = groupData[i];
138 let groupId = group._id;
139 const data = {
140 name: group.group_name,
141 interface: 0,
142 mock: 0,
143 project: 0
144 };
145 result.push(data);
146
147 let projectCount = await this.projectModel.listCount(groupId);
148 let projectData = await this.projectModel.list(groupId);
149 let interfaceCount = 0;
150 for (let j = 0; j < projectData.length; j++) {
151 let project = projectData[j];
152 interfaceCount += await this.interfaceModel.listCount({
153 project_id: project._id
154 });
155 }
156 let mockCount = await this.Model.countByGroupId(groupId);
157 data.interface = interfaceCount;
158 data.project = projectCount;
159 data.mock = mockCount;
160 }
161 return (ctx.body = yapi.commons.resReturn(result));
162 } catch (err) {
163 ctx.body = yapi.commons.resReturn(null, 400, err.message);
164 }
165 }
166
167 cupLoad() {
168 return new Promise((resolve, reject) => {

Callers

nothing calls this directly

Calls 3

listMethod · 0.45
listCountMethod · 0.45
countByGroupIdMethod · 0.45

Tested by

no test coverage detected