Skip to content

Commit

Permalink
Issue/215 (dxatscale#216)
Browse files Browse the repository at this point in the history
Fix Issue #215
  • Loading branch information
manisfdcsfdx authored Feb 26, 2020
1 parent c69ce0a commit 5177cc1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ OPTIONS
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for this command invocation

EXAMPLE
$ sfdx sfpowerkit:source:customlabel:reconcile -p path/to/customlabelfile.xml -d core
$ sfdx sfpowerkit:source:customlabel:reconcile -d path/to/customlabelfile.xml -p core
Package ::: core
Reconciled The Custom Labels, only to have core labels (labels with full name beginning with core_)
``
Expand Down
37 changes: 22 additions & 15 deletions src/commands/sfpowerkit/org/scratchorg/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,20 @@ export default class Usage extends SfdxCommand {

this.ux.log("");

const devhub_username = this.flags.targetdevhubusername;
// Split arguments to use spawn
const args = [];
args.push("force:data:soql:query");

//query
args.push("-q");
args.push(
`SELECT count(id) In_Use, SignupEmail FROM ActiveScratchOrg group by SignupEmail`
);

args.push("-u");
args.push(devhub_username);

await spawn("sfdx", args, { stdio: "inherit" });
if (limits.ActiveScratchOrgs.Remaining !== limits.ActiveScratchOrgs.Max) {
let scratchOrgs = await this.getScratchOrgInfo(conn);
//this.ux.log(scratchOrgs);
const output = [];
scratchOrgs.records.forEach(element => {
output.push({
In_Use: element.In_Use,
SignupEmail: element.SignupEmail
});
});
this.ux.table(output, ["In_Use", "SignupEmail"]);
} else {
this.ux.log(`No Scratch org used currently.`);
}

return 1;
}
Expand All @@ -81,4 +80,12 @@ export default class Usage extends SfdxCommand {

return limits;
}
private async getScratchOrgInfo(conn: core.Connection) {
let query =
"SELECT count(id) In_Use, SignupEmail FROM ActiveScratchOrg GROUP BY SignupEmail ORDER BY count(id) DESC";

const results = (await conn.query(query)) as any;

return results;
}
}

0 comments on commit 5177cc1

Please sign in to comment.