un-cli 0.0.67 → 0.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cmd.txt CHANGED
@@ -1,3 +1,2 @@
1
- trace --subnetwork D23630
2
- topsql --age 10
1
+ update subnetworks --all
3
2
  exit
package/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { AdminLog } from "./adminlog.mjs"
7
7
  import { logger } from "./logger.mjs"
8
8
  import fetch from "node-fetch"
9
9
  //update version
10
- let version = "0.0.67";
10
+ let version = "0.0.68";
11
11
  const GENERATE_TOKEN_TIME_MIN = 30;
12
12
 
13
13
  let rl = null;
@@ -387,7 +387,7 @@ const inputs = {
387
387
 
388
388
  "^update subnetworks --deleted$" : async () => {
389
389
  console.log("Querying all subnetworks that are dirty and deleted.");
390
- let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=1 and isdeleted=1");
390
+ let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=1 and isdeleted=1","domainnetworkname,tiername,subnetworkname");
391
391
  console.log(`Discovered ${subnetworks.features.length} dirty deleted subnetworks.`);
392
392
  for (let i = 0; i < subnetworks.features.length; i++) {
393
393
  const f = subnetworks.features[i]
@@ -411,7 +411,7 @@ const inputs = {
411
411
 
412
412
  "^update subnetworks --all$" : async () => {
413
413
  console.log("Querying all subnetworks that are dirty.");
414
- let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=1");
414
+ let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=1", "domainnetworkname,tiername,subnetworkname");
415
415
  console.log(`Discovered ${subnetworks.features.length} dirty subnetworks.`);
416
416
 
417
417
 
@@ -433,7 +433,7 @@ const inputs = {
433
433
  },
434
434
  "^update subnetworks --all --async$" : async () => {
435
435
  console.log("Querying all subnetworks that are dirty.");
436
- let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=1");
436
+ let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=1", "domainnetworkname,tiername,subnetworkname");
437
437
  console.log(`Discovered ${subnetworks.features.length} dirty subnetworks.`);
438
438
  for (let i = 0; i < subnetworks.features.length; i++) {
439
439
  const f = subnetworks.features[i]
@@ -455,7 +455,7 @@ const inputs = {
455
455
 
456
456
 
457
457
  console.log("Querying all subnetworks that are clean.");
458
- let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=0");
458
+ let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=0","domainnetworkname,tiername,subnetworkname");
459
459
  console.log(`Discovered ${subnetworks.features.length} subnetworks that can be exported.`);
460
460
  for (let i = 0; i < subnetworks.features.length; i++) {
461
461
  const f = subnetworks.features[i]
@@ -472,7 +472,12 @@ const inputs = {
472
472
  const toDate = new Date();
473
473
  const timeEnable = toDate.getTime() - fromDate.getTime();
474
474
  subnetworkResult.duration = numberWithCommas(timeEnable) + " ms"
475
-
475
+ //if undefined exit
476
+ if (!subnetworkResult.url)
477
+ {
478
+ console.log("Export subnetwork failed " + JSON.stringify(subnetworkResult))
479
+ continue;
480
+ }
476
481
 
477
482
  //fetch the json and write it to disk
478
483
  const subContent = await fetch(subnetworkResult.url);
@@ -501,7 +506,7 @@ const inputs = {
501
506
 
502
507
 
503
508
  console.log("Querying all subnetworks that are clean and not exported.");
504
- let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty = 0 and (LASTACKEXPORTSUBNETWORK is null or LASTACKEXPORTSUBNETWORK < LASTUPDATESUBNETWORK)");
509
+ let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty = 0 and (LASTACKEXPORTSUBNETWORK is null or LASTACKEXPORTSUBNETWORK < LASTUPDATESUBNETWORK)","domainnetworkname,tiername,subnetworkname");
505
510
  console.log(`Discovered ${subnetworks.features.length} subnetworks that can be exported.`);
506
511
  for (let i = 0; i < subnetworks.features.length; i++) {
507
512
  const f = subnetworks.features[i]
@@ -579,6 +584,14 @@ const inputs = {
579
584
  const subnetworkName = v(f.attributes,"subnetworkName")
580
585
  console.log(`Exporting subnetwork ${subnetworkName}` );
581
586
  const subnetworkResult = await un.exportSubnetworks(v(f.attributes,"domainNetworkName"), v(f.attributes,"tierName"), v(f.attributes,"subnetworkName"),false);
587
+
588
+ //if undefined exit
589
+ if (!subnetworkResult.url)
590
+ {
591
+ console.log("Export subnetwork failed " + JSON.stringify(subnetworkResult))
592
+ continue;
593
+ }
594
+
582
595
  //fetch the json and write it to disk
583
596
  const subContent = await fetch(subnetworkResult.url);
584
597
  const jsonExport = await subContent.text();
@@ -893,12 +906,12 @@ const inputs = {
893
906
  allMessages = allMessages
894
907
  .map( m=> {
895
908
  m.dataAccessElapsed = parseFloat(m.message.split(";")[1].split(" ")[1])
896
- m.ExecuteQueryElapsed = parseFloat(m.message.split(";")[2].split(" ")[1])
897
- m.totalTimeElapsed = m.dataAccessElapsed + m.ExecuteQueryElapsed
909
+ m.executeQueryElapsed = parseFloat(m.message.split(";")[2].split(" ")[1])
910
+ m.totalExecutionElapsed = m.dataAccessElapsed + m.executeQueryElapsed
898
911
  m.elapsed = parseFloat(m.elapsed); return m;
899
912
 
900
913
  })
901
- .sort( (m1,m2) => m2.totalTimeElapsed - m1.totalTimeElapsed)
914
+ .sort( (m1,m2) => m2.totalExecutionElapsed - m1.totalExecutionElapsed)
902
915
  .slice(0, 10) ;//first 10
903
916
 
904
917
 
@@ -908,11 +921,12 @@ const inputs = {
908
921
  {
909
922
 
910
923
  const x = m.message.split(";")
924
+ x.shift()
911
925
  console.log(`id: ${i++}`)
912
926
  console.log(`\tAt: ${new Date(m.time)} (${m.time})`)
913
927
  console.log(`\tUser: ${m.user}`)
914
- console.log(`\tElapsed: ${m.elapsed*1000} ms`)
915
- console.log(`\ttotalTimeElapsed: ${m.totalTimeElapsed} ms`)
928
+ console.log(`\tTotal Time: ${numberWithCommas(Math.round(m.elapsed*1000))} ms (Total time the cursor was opened)`)
929
+ console.log(`\tQuery Time: ${numberWithCommas(m.totalExecutionElapsed)} ms (includes search + data access nextRow)`)
916
930
  console.log(`\tQuery:`)
917
931
  x.forEach(a => console.log(`\t${a}`))
918
932
  console.log(`\n`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "un-cli",
3
- "version": "0.0.67",
3
+ "version": "0.0.68",
4
4
  "description": "Command line interface for working with ArcGIS Utility Network Extension",
5
5
  "main": "index.mjs",
6
6
  "bin": {
@@ -275,7 +275,7 @@ export class UtilityNetwork {
275
275
 
276
276
  }
277
277
 
278
- queryDistinct(layerId, field, where) {
278
+ queryDistinct(layerId, field, where, orderby) {
279
279
 
280
280
  let queryJson = {
281
281
  f: "json",
@@ -283,7 +283,9 @@ export class UtilityNetwork {
283
283
  outFields: field,
284
284
  where: where,
285
285
  gdbVersion:this.gdbVersion,
286
- returnDistinctValues: true
286
+ returnDistinctValues: true,
287
+ orderByFields: orderby,
288
+
287
289
  }
288
290
 
289
291
  queryJson.layerId = layerId