Skip to content

Commit

Permalink
finish registry function
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyaoi committed Nov 21, 2018
1 parent c9588f2 commit 2244ffb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion discovery/src/controller/system.ts
Expand Up @@ -32,7 +32,7 @@ export default class SystemController {
ctx.status = 200;
ctx.body = {
'code': 200,
'request': await updateCount(+body.users, +body.registries, +body.models)
'request': await updateCount(+body.user, +body.registry, +body.model)
};
}
}
19 changes: 15 additions & 4 deletions discovery/src/parse/entity.ts
@@ -1,9 +1,20 @@
interface CountResult {
users: number;
registries: number;
models: number;
user: number;
registry: number;
model: number;
updatedAt: string;
}

interface PojoResult {
user: number;
registry: number;
model: number;
createdAt: string;
updatedAt: string;
objectId: string;
}

export {
CountResult
CountResult,
PojoResult
};
14 changes: 10 additions & 4 deletions discovery/src/parse/index.ts
@@ -1,6 +1,6 @@
const Parse = require('parse/node').Parse;

import { CountResult } from './entity';
import { CountResult, PojoResult } from './entity';

function initParse() {
Parse.initialize(process.env.PARSE_ID, process.env.PARSE_TOKEN, process.env.PARSE_MASTER_KEY);
Expand All @@ -25,10 +25,16 @@ async function getCount(limit: number) {
const results: any[] = await query.find();
const result: CountResult[] = [];
for (let i = 0; i < results.length; i++) {
result[i].models = results[i]['models'];
result[i].registries = results[i]['registries'];
result[i].users = results[i]['users'];
let pojo_result:PojoResult = results[i].toJSON()
let each_result: CountResult = {
user: pojo_result.user,
model: pojo_result.model,
registry: pojo_result.registry,
updatedAt: pojo_result.updatedAt,
}
result.push(each_result)
}
console.log(result)
return result;
}

Expand Down

0 comments on commit 2244ffb

Please sign in to comment.