cosmos cannot delete the duplicate uuid - azure

Hello I post this little message to know if it is possible to delete
The model is as below:
Create Log data
{
"publisherID": "",
"managerID": "",
"mediaID": "",
"type": "",
"ip": "",
"userAgent": "",
"playerRes": "",
"title": "",
"playerName": "",
"videoTimeCode": 0,
"geo": {
"country": "",
"region": "",
"city": "",
"ll": []
},
"date": "",
"uuid": "",
"id": ""
}
Select all log data: SELECT * FROM a
[
{
"publisherID": "{ID}",
"mediaID": "{ID}",
"type": "Load",
"ip": "67.69.69.41",
"userAgent": "Mozilla/5.0 (Android 11; Mobile; rv:91.0) Gecko/91.0 Firefox/91.0",
"parentReferrer": "link.com",
"title": "title here",
"playerName": "page",
"videoTimeCode": 0,
"geo": {
"country": "CA",
"region": "Ontario",
"city": "Guelph",
"ll": [
43.5588,
-80.3004
]
}
}
]
[SQL-QUERY]: 01 - does not work because there are always duplicate uuids
I want to have all the requests of type progress type: 'Progress'
Organize progress type data by minute according to the date
SELECT COUNT(c.uuid) as total,
left(c.date,16) as time
FROM c
WHERE c.mediaID = '{ID}'
AND (c.date BETWEEN '2021-08-02T14:48:00.000Z' AND '2021-09-03T14:48:00.000Z')
GROUP BY c.uuid, left(c.date, 16)
[
{
"total": 9,
"time": "2021-09-03T14:07"
},
{
"total": 40,
"time": "2021-09-02T12:51"
},
{
"total": 51,
"time": "2021-09-02T12:50"
}
]
[SQL-QUERY]: 02 - cosmos error !
Syntax error, incorrect syntax near 'DISTINCT'.
SELECT COUNT(DISTINCT c.uuid) as total, left(c.date,16) as time
FROM c
WHERE c.mediaID = 'ckpwphqbj10852aav7ib0713o8'
AND (c.date BETWEEN '2021-08-02T14:48:00.000Z' AND '2021-09-03T14:48:00.000Z')
GROUP BY c.uuid, left(c.date, 16)
I want to delete duplicate uuids and then group unique uuids by date

are you looking for this?
counting distinct uuid:
SELECT COUNT(distinct c.uuid) as total, left(c.date,16) as time
FROM c
WHERE c.postID = '155478'
AND (c.date BETWEEN '2021-08-02T14:48:00.000Z' AND '2021-09-03T14:48:00.000Z')
GROUP BY left(c.date, 16)

Related

Parse a json data out from a tag

The text below is part of a string I parsed from html (pre). Since I can not place tags <> in this box I have replace the beginning and end tags as (pre) (/pre).
(pre)(b)Below are the details for server SomeServerName from NetSystem.(Data Length - 1)(/b)
[
{
"askId": "Value1",
"billingCode": "99999999",
"clusterId": null,
"createdBy": "Mike",
"createdFromLegacy": null,
"createdOn": "2021-08-06T17:54:28.220Z",
"description": "Windows 2019",
"environment": "devops",
"hostId": null,
"id": "acd16582-b009-4667-aa95-5977603772sa",
"infrastructure": {
"apiId": "App2019_SA_1_v8-w2019_mike3_cc8f7e02-d426-423d-addb-b29bc7e163be",
"capacityId": "ODI",
"catalogManagementGroup": "Sales Marketing"
},
"legacyId": "XL143036181",
"location": {
"availabilityZone": "ny",
"code": "mx31",
"description": "uhg : mn053",
"region": "west",
"vendor": "apple"
},
"maintenance": {
"group": "3",
"status": "steady_state",
"window": {
"days": "Sunday",
"endTime": "06:00:00.000Z",
"startTime": "02:00:00.000Z"
}
},
"name": "SomeServer",
"network": {
"fqdn": "SomeServer.dom.tes.contoso.com",
"ipAddress": "xx.xx.xx.xx"
},
"os": {
"description": "Microsoft windows 2019",
"type": "windows",
"vendor": "Microsoft",
"version": "2019"
},
"owner": {
"id": "000111111",
"msid": "jtest"
},
"provision": {
"id": "ba424e42-a925-49a5-a4b7-5dcf41b69d4e",
"requestingApi": "mars Hub",
"system": "vRealize"
},
"specs": {
"cpuCount": 4,
"description": "Virtual Hardware",
"ram": 64384,
"serialNumber": null
},
"status": "ACTIVE",
"support": {
"group": "Support group"
},
"tags": {
"appTag": "minitab"
},
"updatedBy": "snir_agent",
"updatedOn": "2021-08-06T17:54:31.525Z"
}
](/pre)
As you can see this is almost json data but I can not parse it as such because of the (b) (/b) tag that exists inside my (pre) (/pre) tag. How can I parse out this (b) tag with its content so I am left with the json data and can treat it as such enabling me to more easily select values with json functions.
If your JSON always has [] brackets you can extract the content inside it and then parse it:
Python example:
import re
import json
text = '<b>asd</b>[{"a": "b", "c": "d"}] pre' # your content
json_content = re.findall('\[[^\]]*\]', text)[0] # '[{"a": "b", "c": "d"}]'
result = json.loads(json_content) # [{'a': 'b', 'c': 'd'}]
You can do this either by using re as indicated here or using split:
cleaned = data.split("(b)")[0] + data.split("(/b)")[1]
Above line will concatenate the content before (b) and after (/b) cleaning the b tag and its content.

Azure API Set-body JSON to JSON covert

The response i am getting is below Which i need to convert the input JSON Format to other JSON structure and send the response back. I am struck how to get the data from the JSOn and construct the new JSON format
{
"totalSize": 1,
"done": true,
"records": [{
"attributes": {
"type": "test123",
"url": "/services/data/testapp"
},
"Id": "8373837",
"Name": "6294",
"Application": "9932932932",
"contact": {
"attributes": {
"type": "testcon",
"url": "/services/data/testappsss"
},
"Name": "testName",
"FirstName": "test",
"LastName": "name",
"MailingStreet": null,
"MailingCity": null,
"unemail": "testname#test,.co",
"MailingState": null,
"MailingCountry": null,
"MailingPostalCode": null,
"stuId": "328237832"
},
"currentusbss": "83277832873278",
"currentsu": {
"attributes": {
"type": "testsub",
"url": "/services/data/v44.0jsjsj"
},
"price": 2,
"Name": "SUB-20426"
},
"bal": 234,
"startdate": "2020-02-03",
"enddate": "2020-05-03"
}]
}
I need to convert above JSON format to below JSON format and send it using set-body method in out-bond policies
{
"info": {
"studentName": "testName",
"studentFirstName": "test",
"studentMiddleName": "",
"studentLastName": "Name",
"studentEmail": "testname#test,.co",
"role": "STUDENT",
"billingCountryCode": "US",
"systemId": "XX",
"stuId": "328237832"
},
"address": {
"address1": "1234 Grove St",
"address2": "",
"city": "Tempe",
"countryCode": "US",
"countryDescription": "UNITED STATES",
"stateCode": "AZ",
"stateDescription": "Arizona",
"postalCode": "45235",
"foreignState": "Arizona",
"region": "Domestic",
"phoneNumber": ""
},
"account": {
"institutionId": "1",
"paymentPlan": "N",
"currencyDesc": "United States Dollars",
"currencyType": "USD",
"bal": 234,
"daysLate":"18",
"opportunityId": "9932932932",
"studentParameterName": null,
"studentParameterValue": null
},
"studentTerms": [
{
"startdate": "2020-02-03",
"enddate": "2020-05-03",
"Name": "SUB-20426",
"description": "XQYember 03, 2020 "
}
]
}
You can use Liquid Template for this case:
Using Liquid Templates in Azure API Management
Using Liquid templates with set body
Or you create a new body in the outbound-section with a new JObject

How can I get init_point or sandbox_init_point after calling payment.create API with mercadopago?

I have implemented the preference API and I am getting the response which I have attached. Now I am confused about how to get refund with this response or is it possible or not. Can you please suggest some API related to the refund policy?
Thanks for the cooperation in advance.
The response which I am getting:
{
"processing_modes": [],
"metadata": {},
"binary_mode": false,
"payment_methods": {
"excluded_payment_methods": [
{
"id": ""
}
],
"excluded_payment_types": [
{
"id": ""
}
],
"installments": null,
"default_payment_method_id": null,
"default_installments": null
},
"collector_id": 472389951,
"operation_type": "regular_payment",
"items": [
{
"id": "",
"picture_url": "",
"title": "Mojito",
"description": "Cheesy 8",
"category_id": "Blah Blah",
"currency_id": "ARS",
"quantity": 11,
"unit_price": 456
}
],
"payer": {
"name": "",
"surname": "",
"email": "pappu#testuser.com",
"date_created": "",
"phone": {
"area_code": "",
"number": ""
},
"identification": {
"type": "",
"number": ""
},
"address": {
"street_name": "",
"street_number": null,
"zip_code": ""
}
},
"back_urls": {
"success": "http://eb7b02b9.ngrok.io/notification/ipn",
"pending": "http://eb7b02b9.ngrok.io/notification/ipn",
"failure": "http://eb7b02b9.ngrok.io/notification/ipn"
},
"auto_return": "",
"client_id": "3767495422255439",
"marketplace": "NONE",
"marketplace_fee": 0,
"shipments": {
"receiver_address": {
"zip_code": "",
"street_number": null,
"street_name": "",
"floor": "",
"apartment": ""
}
},
"notification_url": "http://fd7842f1.ngrok.io/notification/ipn",
"external_reference": "",
"additional_info": "",
"expires": false,
"expiration_date_from": null,
"expiration_date_to": null,
"date_created": "2019-10-03T03:35:03.228-04:00",
"id": "472389951-fdfcf414-18b7-44b3-afd5-5d3cd73fbfc2",
"init_point": "https://www.mercadopago.com.ar/checkout/v1/redirect?pref_id=472389951-fdfcf414-18b7-44b3-afd5-5d3cd73fbfc2",
"sandbox_init_point": "https://sandbox.mercadopago.com.ar/checkout/v1/redirect?pref_id=472389951-fdfcf414-18b7-44b3-afd5-5d3cd73fbfc2"
}

Column data to nested json object in Spark structured streaming

In our application we obtain the field values as columns using Spark sql. Im' trying to figure out how to put the columns values to nested json object and push to Elasticsearch. Also is there a way to parameterise values in selectExpr to pass to the regex?
We are currently using the Spark Java API.
Dataset<Row> data = rowExtracted.selectExpr("split(value,\"[|]\")[0] as channelId",
"split(value,\"[|]\")[1] as country",
"split(value,\"[|]\")[2] as product",
"split(value,\"[|]\")[3] as sourceId",
"split(value,\"[|]\")[4] as systemId",
"split(value,\"[|]\")[5] as destinationId",
"split(value,\"[|]\")[6] as batchId",
"split(value,\"[|]\")[7] as orgId",
"split(value,\"[|]\")[8] as businessId",
"split(value,\"[|]\")[9] as orgAccountId",
"split(value,\"[|]\")[10] as orgBankCode",
"split(value,\"[|]\")[11] as beneAccountId",
"split(value,\"[|]\")[12] as beneBankId",
"split(value,\"[|]\")[13] as currencyCode",
"split(value,\"[|]\")[14] as amount",
"split(value,\"[|]\")[15] as processingDate",
"split(value,\"[|]\")[16] as status",
"split(value,\"[|]\")[17] as rejectCode",
"split(value,\"[|]\")[18] as stageId",
"split(value,\"[|]\")[19] as stageStatus",
"split(value,\"[|]\")[20] as stageUpdatedTime",
"split(value,\"[|]\")[21] as receivedTime",
"split(value,\"[|]\")[22] as sendTime"
);
StreamingQuery query = data.writeStream()
.outputMode(OutputMode.Append()).format("es").option("checkpointLocation", "C:\\checkpoint")
.start("spark_index/doc")
Actual output:
{
"_index": "spark_index",
"_type": "doc",
"_id": "test123",
"_version": 1,
"_score": 1,
"_source": {
"channelId": "test",
"country": "SG",
"product": "test",
"sourceId": "",
"systemId": "test123",
"destinationId": "",
"batchId": "",
"orgId": "test",
"businessId": "test",
"orgAccountId": "test",
"orgBankCode": "",
"beneAccountId": "test",
"beneBankId": "test",
"currencyCode": "SGD",
"amount": "53.0000",
"processingDate": "",
"status": "Pending",
"rejectCode": "test",
"stageId": "123",
"stageStatus": "Comment",
"stageUpdatedTime": "2019-08-05 18:11:05.999000",
"receivedTime": "2019-08-05 18:10:12.701000",
"sendTime": "2019-08-05 18:11:06.003000"
}
}
We need the above columns under a node "txn_summary" such as the below json:
Expected output:
{
"_index": "spark_index",
"_type": "doc",
"_id": "test123",
"_version": 1,
"_score": 1,
"_source": {
"txn_summary": {
"channelId": "test",
"country": "SG",
"product": "test",
"sourceId": "",
"systemId": "test123",
"destinationId": "",
"batchId": "",
"orgId": "test",
"businessId": "test",
"orgAccountId": "test",
"orgBankCode": "",
"beneAccountId": "test",
"beneBankId": "test",
"currencyCode": "SGD",
"amount": "53.0000",
"processingDate": "",
"status": "Pending",
"rejectCode": "test",
"stageId": "123",
"stageStatus": "Comment",
"stageUpdatedTime": "2019-08-05 18:11:05.999000",
"receivedTime": "2019-08-05 18:10:12.701000",
"sendTime": "2019-08-05 18:11:06.003000"
}
}
}
Adding all columns to a top level struct should give the expected output. In Scala:
import org.apache.spark.sql.functions._
data.select(struct(data.columns:_*).as("txn_summary"))
In Java I would suspect it it would be:
import org.apache.spark.sql.functions.struct;
data.select(struct(data.columns()).as("txn_summary"));

can we modifiy the transaction record in hyperledger composer

I have a transacton called updatewarranty.In that updatewarranty transaction i am updating a asset called warranty.
This is my json
{
"$class": "org.network.warranty.Transfer",
"TransferId": "9427",
"AuthKey": "",
"TransferDate": "2018-06-30T05:50:32.767Z",
"customer": {
"$class": "org.network.warranty.Customer",
"CustomerId": "2599",
"Address1": "",
"Address2": "",
"Authkey": "",
"City": "",
"Country": "",
"Email": "",
"Mobile": "",
"State": "",
"UserType": 0
},
"retailer": {
"$class": "org.network.warranty.Retailer",
"RetailerId": "8389",
"Address1": "",
"Address2": "",
"Authkey": "",
"City": "",
"Country": "",
"Email": "",
"Mobile": "",
"State": "",
"UserType": 0
},
"warranty": {
"$class": "org.network.warranty.Warranty",
"WarrentyId": "0766",
"End_Date": "2018-06-30T05:50:32.767Z",
"Start_Date": "2018-06-30T05:50:32.767Z",
"IS_Internationaly_Valid": "",
"Item_QRCode": ""
}
}
I have a transaction named getwarranty which takes the warranty id as input.
this is my json
{
"$class": "org.network.warranty.getWarranty",
"warranty": "resource:org.network.warranty.Warranty#0766"
}
When i see the transaction record for getwarranty i dont have the entire transfer record. I have only this information
{
"$class": "org.network.warranty.getWarranty",
"warranty": "resource:org.network.warranty.Warranty#0766",
"transactionId": "6e35c9cb-d3a6-41d8-8c95-fa22c7681824",
"timestamp": "2018-06-30T05:50:54.851Z"
}
how can i get the warranty asset?

Resources