Two different nodes giving same call to same MYSQL Database giving different responses - mysql

I have my first NodeJS API running. I have two API's now running (TEST and PROD).
These files are DIRECT copies of each other and running via App Manager in Cpanel.
Weirdly, one of the calls (Prod) is giving incorrect information on some of the calls... like it is giving 'old' data.
eg. a record was changed for an 'order' and a locationID was added to the database.
I have checked the database and it was added.
The test call:
https://www.myAPI.com.au/TEST/orders/myOrders/1709
Response:
{
"Result": true,
"order": {
"orderID": 1709,
"chemOrderID": 1243,
"firstName": "test",
"lastName": "test",
"phone": "04123456",
"email": null,
"prefContact": 1,
"itemName": "KN95 Box Of 30 ",
"itemQuantity": 1,
"plu": null,
"modelNumber": null,
"colour": null,
"itemDetails": null,
"supplier": "avacare",
"itemSize": null,
"amountPaid": 0,
"receiptNumber": "00",
"quotedPrice": 69.99,
"orderComments": null,
"reorder": 0,
"isNDIS": 0,
"isNDISPaid": 0,
"onHold": 0,
"requestedBy": 35,
"orderedBy": 35,
"receivedBy": 35,
"finalisedBy": 0,
"overdueBy": 0,
"NDISBy": 0,
"deletedBy": 0,
"requestedByName": "Jac",
"orderedByName": "Jac",
"receivedByName": "Jac",
"finalisedByName": null,
"overdueByName": null,
"deletedByName": null,
"requestedDateShort": "18 Jan",
"orderedDateShort": "18 Jan",
"receivedDateShort": "18 Jan",
"finalisedDateShort": null,
"overdueDateShort": null,
"deletedDateShort": null,
"requestedDate": "2022-01-18T09:40:21",
"orderedDate": "2022-01-18T09:50:33",
"receivedDate": "2022-01-18T12:21:41",
"finalisedDate": null,
"overdueDate": null,
"deletedDate": null,
"etaMaxDateShort": "Thu, 20 Jan",
"etaCode": 2,
"locationID": 199,
"supplierRef": null,
"locationOther": null,
"categoryID": 5,
"categoryName": "GENERAL SHOP"
}
}
Now this is correct. The locationID is updated, the receivedDate, recivedByName and receivedBy are all correct and updated.
The same call on copied API: (same mysql user login. literally a duplicate of the api)
Call:
https://www.myAPI.com.au/prod/orders/myOrders/1709
Response:
{
"Result": true,
"order": {
"orderID": 1709,
"chemOrderID": 1243,
"firstName": "test",
"lastName": "test",
"phone": "04123456",
"email": null,
"prefContact": 1,
"itemName": "KN95 Box Of 30 ",
"itemQuantity": 1,
"plu": null,
"modelNumber": null,
"colour": null,
"itemDetails": null,
"supplier": "avacare",
"itemSize": null,
"amountPaid": 0,
"receiptNumber": "00",
"quotedPrice": 69.99,
"orderComments": null,
"reorder": 0,
"isNDIS": 0,
"isNDISPaid": 0,
"onHold": 0,
"requestedBy": 35,
"orderedBy": 35,
"receivedBy": 0,
"finalisedBy": 0,
"overdueBy": 0,
"NDISBy": 0,
"deletedBy": 0,
"requestedByName": "Jac",
"orderedByName": "Jac",
"receivedByName": null,
"finalisedByName": null,
"overdueByName": null,
"deletedByName": null,
"requestedDateShort": "18 Jan",
"orderedDateShort": "18 Jan",
"receivedDateShort": null,
"finalisedDateShort": null,
"overdueDateShort": null,
"deletedDateShort": null,
"requestedDate": "2022-01-18T09:40:21",
"orderedDate": "2022-01-18T09:50:33",
"receivedDate": null,
"finalisedDate": null,
"overdueDate": null,
"deletedDate": null,
"etaMaxDateShort": "Thu, 20 Jan",
"etaCode": 2,
"locationID": null,
"supplierRef": null,
"locationOther": null,
"categoryID": 5,
"categoryName": "GENERAL SHOP"
}
}
As can be seen, the aforementioned fields aren't filled!?
It's like the call is getting an old version of the database or something...
I can't understand this at all.
There is only one DB, i haven't created a test db, in reality this whole thing is testing (even the prod version), as I am learning and trying to understand how I will go about everything once it is actually live.

Related

How to solve Cannot cast object '0.0' with class 'java.lang.Double' to class 'org.json.JSONObject'

This is some part of my input json :-
"orderLine": {
"agreementHeaderId": [
null
],
"agreementNumber": [
null
],
"customerProductId": null,
"displayLineNumber": "2",
"estimateFulfillmentCost": 9.97,
"extendedAmount": null,
"fulfilledQuantity": null,
"fulfillToleranceAbove": null,
"inventoryOrganizationCode": "107",
"inventoryOrganizationId": "107",
"jobName": null,
"orderedQuantity": 1.0,
"orderedUom": null,
"origSystemDocumentLineReference": "2",
"paymentTerms": "CASH ON DEMAND",
"paymentTermsCode": "COD",
"productId": "4065412*107",
"productNumber": "4065412",
"productDescription": "20 DFU AAV W/ 1-1/2-2 PVC ADPT",
"purchasingUom": null,
"quantityPerModel": 0.0,
"requestedShipDate": "2022-12-19T05:00:00.000Z",
"requestedSupplierNumber": null,
"requisitionInventoryOrganizationId": "107",
"rmaDeliveredQuantity": null,
"scheduleShipDate": null,
"shippedQuantity": 1.0,
"shippingCarrier": "OT",
"shippingInstructions": null,
"shippingMode": "OUR TRUCK",
"shippingModeCode": "OT",
"subInventory": null,
"transactionLineTypeCode": null,
"transactionCategoryCode": null,
"transactionLineType": "MP",
"unitListPrice": 33.23,
"unitQuantity": 1.0,
"unitSellingPrice": 44.0,
Few values are double type not string
So, while giving this JSONObject oldQty = (JSONObject) orderLine.get("orderedQuantity")
I'm getting Cannot cast object '0.0' with class 'java.lang.Double' to class 'org.json.JSONObject' this error

NestJs TypeOrm loadRelationCountAndMap apply order by operation on it

I am new in NestJs TypeORM and I tried to get the count only from the relation table using loadRelationCountAndMap method and now I need a fetuare to change the order of that count ASC or DESC but when I tried the orderBy method it will return me unknow colunm name.
Here is my query
await this.userRepository
.createQueryBuilder('user')
.leftJoinAndSelect('user.roles', 'roles')
.loadRelationCountAndMap('user.postCount', 'user.post', 'post', qb =>
qb.where('post.type =:type', { type: 'post' }),)
.loadRelationCountAndMap('user.userSpotCount', 'user.spot', 'spot')
.loadRelationCountAndMap(
'user.itineraryCount',
'user.post',
'post',
qb => qb.where('post.type =:type', { type: 'itinerary' }),)
.where('roles.name = :name', { name: request.user_type })
.orderBy('userSpotCount', 'ASC');
and the output is without orderBy method
[{
"id": xxxxx,
"name": "xxxx xxxx",
"email": "xxxx.xxxx#xxxx.xxx",
"facebook_id": null,
"google_id": null,
"apple_id": null,
"is_email_verifie": null,
"is_phone_verifie": null,
"created_at": "2022-06-06T23:38:04.000Z",
"updated_at": "2022-06-06T23:38:04.000Z",
"phone": "1234567890",
"token": null,
"profile_pic": "",
"status": "pending",
"email_token": null,
"deleted_at": null,
"latitude": "26.78965",
"longitude": "93.78965",
"is_public": null,
"basedIn": null,
"visit_place": null,
"visit_place_lat": null,
"visit_place_long": null,
"notification_flag": "on",
"location": "abc, xyz, pqr",
"country_code": null,
"home_key": 1,
"postCount": 0,
"userSpotCount": 5,
"itineraryCount": 0
},
{
"id": xxxxx,
"name": "xxxx xxxx",
"email": "xxxx.xxxx#xxxx.xxx",
"facebook_id": null,
"google_id": null,
"apple_id": null,
"is_email_verifie": null,
"is_phone_verifie": null,
"created_at": "2022-06-06T23:38:04.000Z",
"updated_at": "2022-06-06T23:38:04.000Z",
"phone": "1234567890",
"token": null,
"profile_pic": "",
"status": "pending",
"email_token": null,
"deleted_at": null,
"latitude": "26.78965",
"longitude": "93.78965",
"is_public": null,
"basedIn": null,
"visit_place": null,
"visit_place_lat": null,
"visit_place_long": null,
"notification_flag": "on",
"location": "abc, xyz, pqr",
"country_code": null,
"home_key": 1,
"postCount": 0,
"userSpotCount": 1,
"itineraryCount": 0
}
]
I need this output as per the order by ASC/DESC

How to filter array of elements in JMESPath with Azure CLI

I am total newbie in JMESPath parsing.
az network lb inbound-nat-rule list --resource-group MYRG --lb-name MYLB is returning below output and I would like filter only backendIpConfiguration.id and backendPort in the response.
Below response in have array of elements.
[
{
"backendIpConfiguration": {
"applicationGatewayBackendAddressPools": null,
"applicationSecurityGroups": null,
"etag": null,
"gatewayLoadBalancer": null,
"id": "/subscriptions/XXXX/XXX/XXX/providers/Microsoft.Network/networkInterfaces/XXX/ipConfigurations/XXXX",
"loadBalancerBackendAddressPools": null,
"loadBalancerInboundNatRules": null,
"name": null,
"primary": null,
"privateIpAddress": null,
"privateIpAddressVersion": null,
"privateIpAllocationMethod": null,
"privateLinkConnectionProperties": null,
"provisioningState": null,
"publicIpAddress": null,
"resourceGroup": "MYRG01",
"subnet": null,
"type": null,
"virtualNetworkTaps": null
},
"backendPort": 1367,
"enableFloatingIp": false,
"enableTcpReset": false,
"etag": "W/\"XXXXX-1173-49ad-8d1f-40347c00d88a\"",
"frontendIpConfiguration": {
"id": "/subscriptions/XXXX/XXX/XXX/providers/Microsoft.Network/networkInterfaces/XXX/ipConfigurations/XXXX",
"resourceGroup": "MYRG01"
},
"frontendPort": 1367,
"id": "/subscriptions/XXXX/XXX/XXX/providers/Microsoft.Network/networkInterfaces/XXX/ipConfigurations/XXXX",
"idleTimeoutInMinutes": 5,
"name": "rule1",
"protocol": "Tcp",
"provisioningState": "Succeeded",
"resourceGroup": "MYRG01",
"type": "Microsoft.Network/loadBalancers/inboundNatRules"
},
{
"backendIpConfiguration": {
"applicationGatewayBackendAddressPools": null,
"applicationSecurityGroups": null,
"etag": null,
"gatewayLoadBalancer": null,
"id": "/subscriptions/XXXX/XXX/XXX/providers/Microsoft.Network/networkInterfaces/XXX/ipConfigurations/XXXX",
"loadBalancerBackendAddressPools": null,
"loadBalancerInboundNatRules": null,
"name": null,
"primary": null,
"privateIpAddress": null,
"privateIpAddressVersion": null,
"privateIpAllocationMethod": null,
"privateLinkConnectionProperties": null,
"provisioningState": null,
"publicIpAddress": null,
"resourceGroup": "MYRG02",
"subnet": null,
"type": null,
"virtualNetworkTaps": null
},
"backendPort": 3006,
"enableFloatingIp": false,
"enableTcpReset": false,
"etag": "W/\"XXXX-1173-49ad-8d1f-40347c00d88a\"",
"frontendIpConfiguration": {
"id": "/subscriptions/XXXX/XXX/XXX/providers/Microsoft.Network/networkInterfaces/XXX/ipConfigurations/XXXX",
"resourceGroup": "MYRG02"
},
"frontendPort": 3006,
"id": "/subscriptions/XXXX/XXX/XXX/providers/Microsoft.Network/networkInterfaces/XXX/ipConfigurations/XXXX",
"idleTimeoutInMinutes": 5,
"name": "rule2",
"protocol": "Tcp",
"provisioningState": "Succeeded",
"resourceGroup": "MYRG02",
"type": "Microsoft.Network/loadBalancers/inboundNatRules"
}
]
Filtering in JMESPath is quite simple, and the documentation is pretty straight forward for filters and multiselect hashes.
In here, a simple query like:
[].{backendIpConfigurationId: backendIpConfiguration.id, backendPort: backendPort}
Will give you the filtered JSON:
[
{
"backendIpConfigurationId": "/subscriptions/XXXX/XXX/XXX/providers/Microsoft.Network/networkInterfaces/XXX/ipConfigurations/XXXX",
"backendPort": 1367
},
{
"backendIpConfigurationId": "/subscriptions/XXXX/XXX/XXX/providers/Microsoft.Network/networkInterfaces/XXX/ipConfigurations/XXXX",
"backendPort": 3006
}
]
Containing only the informations you are looking for.

Get N number of values from object with jq

I'm trying to retrieve a given number of values from the following json object (just used 2 for brevity):
[
{
"content": null,
"deleted": false,
"metadata": null,
"name": "name/windows-2016-osDisk.170b8936-d66d-4139-a409-26f4e9d354fe.vhd",
"properties": {
"appendBlobCommittedBlockCount": null,
"blobTier": "P10",
"blobTierChangeTime": null,
"blobTierInferred": true,
"blobType": "PageBlob",
"contentLength": 136367309312,
"contentRange": null,
"contentSettings": {
"cacheControl": null,
"contentDisposition": null,
"contentEncoding": null,
"contentLanguage": null,
"contentMd5": "-0q970378r08==",
"contentType": "application/octet-stream"
},
"copy": {
"completionTime": null,
"id": null,
"progress": null,
"source": null,
"status": null,
"statusDescription": null
},
"creationTime": "2019-11-21T08:34:33+00:00",
"deletedTime": null,
"etag": "0237502375",
"lastModified": "2019-11-21T08:34:33+00:00",
"lease": {
"duration": null,
"state": "available",
"status": "unlocked"
},
"pageBlobSequenceNumber": null,
"remainingRetentionDays": null,
"sequenceNumber": 1,
"serverEncrypted": true
},
"snapshot": null
},
{
"content": null,
"deleted": false,
"metadata": null,
"name": "name/windows-2019-osDisk.f122fb3c-0edb-42a8-b98c-56657b447f15.vhd",
"properties": {
"appendBlobCommittedBlockCount": null,
"blobTier": "P10",
"blobTierChangeTime": null,
"blobTierInferred": true,
"blobType": "PageBlob",
"contentLength": 136367309312,
"contentRange": null,
"contentSettings": {
"cacheControl": null,
"contentDisposition": null,
"contentEncoding": null,
"contentLanguage": null,
"contentMd5": "0237502375/hKOg==",
"contentType": "application/octet-stream"
},
"copy": {
"completionTime": null,
"id": null,
"progress": null,
"source": null,
"status": null,
"statusDescription": null
},
"creationTime": "2019-11-21T08:35:03+00:00",
"deletedTime": null,
"etag": "20397520i3h523",
"lastModified": "2019-11-21T08:35:03+00:00",
"lease": {
"duration": null,
"state": "available",
"status": "unlocked"
},
"pageBlobSequenceNumber": null,
"remainingRetentionDays": null,
"sequenceNumber": 1,
"serverEncrypted": true
},
"snapshot": null
}
]
I sort this on creationTime in jq like so: jq 'sort_by(.properties.creationTime)' When I pipe this through | .[].name making jq 'sort_by(.properties.creationTime) | .[].name I get a sorted list of the names.
My question is: How can I pass an integer to this command and remove these many names, starting from the most recent created (bottom)?
following
https://stedolan.github.io/jq/manual/v1.6/#Builtinoperatorsandfunctions
slicing should work:
jq 'sort_by(.properties.creationTime) | .[-1:]'
The answer I've used is the following:
jq 'sort_by(.properties.creationTime) | .[-4:] | .[].name'
Where -4 is the amount of names to display starting from the bottom.

How to compare rows from JSON file in angular?

I have this items in a JSON file that I need to compare wherever I have Curr or Prev values and compare if they are equals. this algorithm is with angular 5 but I'm being unable to do this, I did the load function with httpClient
Example :
[{
"id": 1,
"comparisonDate": "2017-06-22",
"milestone": "CURR_PREV",
"udDomain": "BASIS",
"udIdentifier": "332A251000.01",
"rpt": "D70",
"approvedCurr": true,
"approvedPrev": null,
"commercialReferenceCurr": "BASIS - 01.01.2007",
"commercialReferencePrev": null,
"customizationImpactCurr": null,
"customizationImpactPrev": null,
"deliveryTypeCurr": null,
"deliveryTypePrev": null,
"aircraftId": 184,
"aircraftSapId": "580652",
"aircraftName": "BUL 011",
"aircraftSerialNumber": "02713",
"quantityCurr": "1",
"quantityPrev": null,
"statusCurr": "O",
"statusPrev": null,
"typeModification": "CREATION",
"validityCurr": "V",
"validityPrev": null
}, {
"id": 2,
"comparisonDate": "2017-06-22",
"milestone": "CURR_PREV",
"udDomain": "BASIS",
"udIdentifier": "332A270028.01",
"rpt": "E15",
"approvedCurr": true,
"approvedPrev": null,
"commercialReferenceCurr": "BASIS - 01.01.2007",
"commercialReferencePrev": null,
"customizationImpactCurr": null,
"customizationImpactPrev": null,
"deliveryTypeCurr": null,
"deliveryTypePrev": null,
"aircraftId": 184,
"aircraftSapId": "580652",
"aircraftName": "BUL 011",
"aircraftSerialNumber": "02713",
"quantityCurr": "1",
"quantityPrev": null,
"statusCurr": "O",
"statusPrev": null,
"typeModification": "CREATION",
"validityCurr": "V",
"validityPrev": null
}]
this should be with using lodash.
i assume your want something like this
for each object in your array
filter keys that end with "Curr"
for each get Prev property
compare it with curr property
let obj = [{
"id": 1,
"comparisonDate": "2017-06-22",
"milestone": "CURR_PREV",
"udDomain": "BASIS",
"udIdentifier": "332A251000.01",
"rpt": "D70",
"approvedCurr": true,
"approvedPrev": null,
"commercialReferenceCurr": "BASIS - 01.01.2007",
"commercialReferencePrev": null,
"customizationImpactCurr": null,
"customizationImpactPrev": null,
"deliveryTypeCurr": null,
"deliveryTypePrev": null,
"aircraftId": 184,
"aircraftSapId": "580652",
"aircraftName": "BUL 011",
"aircraftSerialNumber": "02713",
"quantityCurr": "1",
"quantityPrev": null,
"statusCurr": "O",
"statusPrev": null,
"typeModification": "CREATION",
"validityCurr": "V",
"validityPrev": null
}, {
"id": 2,
"comparisonDate": "2017-06-22",
"milestone": "CURR_PREV",
"udDomain": "BASIS",
"udIdentifier": "332A270028.01",
"rpt": "E15",
"approvedCurr": true,
"approvedPrev": null,
"commercialReferenceCurr": "BASIS - 01.01.2007",
"commercialReferencePrev": null,
"customizationImpactCurr": null,
"customizationImpactPrev": null,
"deliveryTypeCurr": null,
"deliveryTypePrev": null,
"aircraftId": 184,
"aircraftSapId": "580652",
"aircraftName": "BUL 011",
"aircraftSerialNumber": "02713",
"quantityCurr": "1",
"quantityPrev": null,
"statusCurr": "O",
"statusPrev": null,
"typeModification": "CREATION",
"validityCurr": "V",
"validityPrev": null
}];
obj.forEach(x=>{
Object.keys(x)
.filter(y=>y.endsWith("Curr"))
.forEach(y=>{
let prevProp = y.replace("Curr", "Prev")
console.log(y, x[y]);
console.log(prevProp ,x[prevProp ]);
if(x[y]===x[prevProp ]){
//equal
}else{
//not equal
}
})
})
you could use lodash's _.forEach, _.Keys, _.filter but i think there is not much point on this.