Postgres GROUP BY, SUBSTRING and SUM Query Issue - sql

I am trying to write a GROUP BY query but I am struggling to achieve the desired result. I am including
A JSON object that represent the DB table with some data.
SELECT * FROM tb_transaction
"tb_transaction": [
{
"id": "121",
"profile_id": "57",
"event_id": "45",
"activity_id": "67",
"payment_type": "EFT",
"transaction_type": "activity_registration",
"gl_code": "1234-56-102-020",
"description": "Golf",
"amount": "1500",
"paid": "f",
"invoice_number": "0006"
},
{
"id": "117",
"profile_id": "57",
"event_id": "45",
"activity_id": "65",
"payment_type": "EFT",
"transaction_type": "activity_registration",
"gl_code": "1234-56-102-056",
"description": "Cuppa",
"amount": "100",
"paid": "f",
"invoice_number": "0006"
},
{
"id": "120",
"profile_id": "57",
"event_id": "45",
"activity_id": "70",
"payment_type": "EFT",
"transaction_type": "activity_registration",
"gl_code": "1234-13-102-064",
"description": "Nutrition & Lifestyle",
"amount": "510",
"paid": "f",
"invoice_number": "0006"
},
{
"id": "125",
"profile_id": "207",
"event_id": "45",
"activity_id": "65",
"payment_type": "Cash",
"transaction_type": "activity_registration",
"gl_code": "1234-56-102-056",
"description": "Cuppa",
"amount": "100",
"paid": "f",
"invoice_number": "0007"
},
{
"id": "126",
"profile_id": "207",
"event_id": "45",
"activity_id": "65",
"payment_type": "Cash",
"transaction_type": "merchandise",
"gl_code": "3400-56-102-056",
"description": "Cap",
"amount": "20",
"paid": "f",
"invoice_number": "0007"
},
{
"id": "128",
"profile_id": "193",
"event_id": "45",
"activity_id": "70",
"payment_type": "SnapScan",
"transaction_type": "activity_registration",
"gl_code": "1234-13-102-064",
"description": "Nutrition & Lifestyle",
"amount": "510",
"paid": "f",
"invoice_number": "0008"
},
{
"id": "131",
"profile_id": "193",
"event_id": "45",
"activity_id": "65",
"payment_type": "SnapScan",
"transaction_type": "merchandise",
"gl_code": "3400-56-102-056",
"description": "Water Bottle",
"amount": "10",
"paid": "f",
"invoice_number": "0008"
},
{
"id": "130",
"profile_id": "193",
"event_id": "45",
"activity_id": "65",
"payment_type": "SnapScan",
"transaction_type": "activity_registration",
"gl_code": "1234-56-102-056",
"description": "Cuppa",
"amount": "100",
"paid": "f",
"invoice_number": "0008"
}
]
My current query and its result.
SELECT gl_code, transaction_type, activity_id, payment_type, description, SUM(amount) AS amount
FROM tb_transaction
WHERE event_id = 45 AND paid = false
GROUP BY gl_code, transaction_type, activity_id, payment_type, description
ORDER BY gl_code;
"RECORDS": [
{
"gl_code": "1234-13-102-064",
"transaction_type": "activity_registration",
"activity_id": "70",
"payment_type": "EFT",
"description": "Nutrition & Lifestyle",
"amount": "510"
},
{
"gl_code": "1234-13-102-064",
"transaction_type": "activity_registration",
"activity_id": "70",
"payment_type": "SnapScan",
"description": "Nutrition & Lifestyle",
"amount": "510"
},
{
"gl_code": "1234-56-102-056",
"transaction_type": "activity_registration",
"activity_id": "65",
"payment_type": "Cash",
"description": "Cuppa",
"amount": "100"
},
{
"gl_code": "1234-56-102-056",
"transaction_type": "activity_registration",
"activity_id": "65",
"payment_type": "EFT",
"description": "Cuppa",
"amount": "100"
},
{
"gl_code": "1234-56-102-056",
"transaction_type": "activity_registration",
"activity_id": "65",
"payment_type": "SnapScan",
"description": "Cuppa",
"amount": "100"
},
{
"gl_code": "1234-56-102-020",
"transaction_type": "activity_registration",
"activity_id": "67",
"payment_type": "EFT",
"description": "Golf",
"amount": "1500"
},
{
"gl_code": "3400-56-102-056",
"transaction_type": "merchandise",
"activity_id": "65",
"payment_type": "Cash",
"description": "Cap",
"amount": "20"
},
{
"gl_code": "3400-56-102-056",
"transaction_type": "merchandise",
"activity_id": "65",
"payment_type": "SnapScan",
"description": "Water Bottle",
"amount": "10"
}
]
The desired result.
`"RECORDS": [
{
"gl_code": "1234-13-102-064",
"transaction_type": "activity_registration",
"activity_id": "70",
"payment_type": "EFT",
"description": "Nutrition & Lifestyle",
"amount": "510"
},
{
"gl_code": "1234-13-102-064",
"transaction_type": "activity_registration",
"activity_id": "70",
"payment_type": "SnapScan",
"description": "Nutrition & Lifestyle",
"amount": "510"
},
{
"gl_code": "1234-56-102-056",
"transaction_type": "activity_registration",
"activity_id": "65",
"payment_type": "Cash",
"description": "Cuppa",
"amount": "120"
},
{
"gl_code": "1234-56-102-056",
"transaction_type": "activity_registration",
"activity_id": "65",
"payment_type": "EFT",
"description": "Cuppa",
"amount": "100"
},
{
"gl_code": "1234-56-102-056",
"transaction_type": "activity_registration",
"activity_id": "65",
"payment_type": "SnapScan",
"description": "Cuppa",
"amount": "110"
},
{
"gl_code": "1234-56-102-020",
"transaction_type": "activity_registration",
"activity_id": "67",
"payment_type": "EFT",
"description": "Golf",
"amount": "1500"
}
]'
The difference is very subtle. But you will see that I basically want to sum the records who's "payment_type" and last 3 digits of the "gl_code" are the same. For example "payment_type": "Cash" and "gl_code": "1234-56-102-056",
Any help will be immensely appreciated.

If you want to group by payment_type and last 3 digits of gl_code (and apparently some other columns), you can do
SELECT substring(gl_code, length(gl_code) - 3),
transaction_type,
activity_id,
payment_type,
description,
SUM(amount) AS amount
FROM tb_transaction
WHERE event_id = 45 AND paid = false
GROUP BY substring(gl_code, length(gl_code) - 3),
transaction_type,
activity_id,
payment_type,
description
ORDER BY gl_code;
Note however that this will only select the last 3 digits, and not an (arbitrary) gl_code from all those that share the same last 3 digits.

Related

I keep getting 400 error(travelerId not existing) on calling the CreateOrder API

I am on a test Account.
On printing the travelerPricings Object to console, I have this
[
{
travelerId: '1',
fareOption: 'STANDARD',
travelerType: 'ADULT',
price: {
currency: '',
total: '',
base: '',
taxes: [Array],
refundableTaxes: ''
},
fareDetailsBySegment: [ [Object], [Object], [Object], [Object] ]
},
{
travelerId: '2',
fareOption: 'STANDARD',
travelerType: 'CHILD',
price: {
currency: '',
total: '',
base: '',
taxes: [Array],
refundableTaxes: ''
},
fareDetailsBySegment: [ [Object], [Object], [Object], [Object] ]
}
]
Yet on the Api Response, I keep getting the error pointer as
/data/flightOffers[0]/travelerPricings[1]"
Which is not true. As seen in the log shared above,
travelerPricings[1].travelerId = '2'
Please Why could this error come up? Thanks
Based on the Request, Here is the sample payload
{"data":
{
"flightOffers": [
{
"type": "flight-offer",
"id": "1",
"source": "GDS",
"instantTicketingRequired": false,
"nonHomogeneous": false,
"paymentCardRequired": false,
"lastTicketingDate": "2022-08-01",
"itineraries": [
{
"segments": [
{
"departure": {
"iataCode": "SYD",
"terminal": "1",
"at": "2022-08-01T11:35:00"
},
"arrival": {
"iataCode": "MNL",
"terminal": "2",
"at": "2022-08-01T16:50:00"
},
"carrierCode": "PR",
"number": "212",
"aircraft": {
"code": "333"
},
"operating": {
"carrierCode": "PR"
},
"duration": "PT7H15M",
"id": "15",
"numberOfStops": 0,
"co2Emissions": [
{
"weight": 716,
"weightUnit": "KG",
"cabin": "BUSINESS"
}
]
},
{
"departure": {
"iataCode": "MNL",
"terminal": "1",
"at": "2022-08-01T19:20:00"
},
"arrival": {
"iataCode": "BKK",
"at": "2022-08-01T21:50:00"
},
"carrierCode": "PR",
"number": "732",
"aircraft": {
"code": "320"
},
"operating": {
"carrierCode": "PR"
},
"duration": "PT3H30M",
"id": "16",
"numberOfStops": 0,
"co2Emissions": [
{
"weight": 148,
"weightUnit": "KG",
"cabin": "BUSINESS"
}
]
}
]
},
{
"segments": [
{
"departure": {
"iataCode": "BKK",
"at": "2022-08-05T22:50:00"
},
"arrival": {
"iataCode": "MNL",
"terminal": "2",
"at": "2022-08-06T03:15:00"
},
"carrierCode": "PR",
"number": "733",
"aircraft": {
"code": "321"
},
"operating": {
"carrierCode": "PR"
},
"duration": "PT3H25M",
"id": "59",
"numberOfStops": 0,
"co2Emissions": [
{
"weight": 148,
"weightUnit": "KG",
"cabin": "ECONOMY"
}
]
},
{
"departure": {
"iataCode": "MNL",
"terminal": "1",
"at": "2022-08-06T22:10:00"
},
"arrival": {
"iataCode": "SYD",
"terminal": "1",
"at": "2022-08-07T09:45:00"
},
"carrierCode": "PR",
"number": "211",
"aircraft": {
"code": "333"
},
"operating": {
"carrierCode": "PR"
},
"duration": "PT9H35M",
"id": "60",
"numberOfStops": 0,
"co2Emissions": [
{
"weight": 358,
"weightUnit": "KG",
"cabin": "ECONOMY"
}
]
}
]
}
],
"price": {
"currency": "NGN",
"total": "1479460.00",
"base": "1298255.00",
"fees": [
{
"amount": "0.00",
"type": "SUPPLIER"
},
{
"amount": "0.00",
"type": "TICKETING"
},
{
"amount": "0.00",
"type": "FORM_OF_PAYMENT"
}
],
"grandTotal": "1479460.00",
"billingCurrency": "NGN"
},
"pricingOptions": {
"fareType": [
"PUBLISHED"
],
"includedCheckedBagsOnly": false
},
"validatingAirlineCodes": [
"PR"
],
"travelerPricings": [
{
"travelerId": "1",
"fareOption": "STANDARD",
"travelerType": "ADULT",
"price": {
"currency": "NGN",
"total": "840536",
"base": "740769",
"taxes": [
{
"amount": "384.00",
"code": "G8"
},
{
"amount": "19112.00",
"code": "WY"
},
{
"amount": "896.00",
"code": "E7"
},
{
"amount": "18329.00",
"code": "AU"
},
{
"amount": "42766.00",
"code": "YQ"
},
{
"amount": "9320.00",
"code": "LI"
},
{
"amount": "8960.00",
"code": "TS"
}
],
"refundableTaxes": "108123"
},
"fareDetailsBySegment": [
{
"segmentId": "15",
"cabin": "BUSINESS",
"fareBasis": "DBAU",
"class": "D",
"includedCheckedBags": {
"weight": 40,
"weightUnit": "KG"
}
},
{
"segmentId": "16",
"cabin": "BUSINESS",
"fareBasis": "DBAU",
"class": "D",
"includedCheckedBags": {
"weight": 40,
"weightUnit": "KG"
}
},
{
"segmentId": "59",
"cabin": "ECONOMY",
"fareBasis": "KBAU",
"class": "K",
"includedCheckedBags": {
"weight": 30,
"weightUnit": "KG"
}
},
{
"segmentId": "60",
"cabin": "ECONOMY",
"fareBasis": "KBAU",
"class": "K",
"includedCheckedBags": {
"weight": 30,
"weightUnit": "KG"
}
}
]
},
{
"travelerId": "2",
"fareOption": "STANDARD",
"travelerType": "CHILD",
"price": {
"currency": "NGN",
"total": "638924",
"base": "557486",
"taxes": [
{
"amount": "384.00",
"code": "G8"
},
{
"amount": "19112.00",
"code": "WY"
},
{
"amount": "896.00",
"code": "E7"
},
{
"amount": "42766.00",
"code": "YQ"
},
{
"amount": "9320.00",
"code": "LI"
},
{
"amount": "8960.00",
"code": "TS"
}
],
"refundableTaxes": "89794"
},
"fareDetailsBySegment": [
{
"segmentId": "15",
"cabin": "BUSINESS",
"fareBasis": "DBAU",
"class": "D",
"includedCheckedBags": {
"weight": 40,
"weightUnit": "KG"
}
},
{
"segmentId": "16",
"cabin": "BUSINESS",
"fareBasis": "DBAU",
"class": "D",
"includedCheckedBags": {
"weight": 40,
"weightUnit": "KG"
}
},
{
"segmentId": "59",
"cabin": "ECONOMY",
"fareBasis": "KBAU",
"class": "K",
"includedCheckedBags": {
"weight": 30,
"weightUnit": "KG"
}
},
{
"segmentId": "60",
"cabin": "ECONOMY",
"fareBasis": "KBAU",
"class": "K",
"includedCheckedBags": {
"weight": 30,
"weightUnit": "KG"
}
}
]
}
]
}
],
"travelers": [ {
"id": "1",
"dateOfBirth": "1982-01-16",
"name": {
"firstName": "JORGE",
"lastName": "GONZALES"
},
"gender": "MALE",
"contact": {
"emailAddress": "jorge.gonzales833#telefonica.es",
"phones": [ {
"deviceType": "MOBILE",
"countryCallingCode": "34",
"number": "480080076"
} ]
},
"documents": [ {
"documentType": "PASSPORT",
"birthPlace": "Madrid",
"issuanceLocation": "Madrid",
"issuanceDate": "2015-04-14",
"number": "00000000",
"expiryDate": "2025-04-14",
"issuanceCountry": "ES",
"validityCountry": "ES",
"nationality": "ES",
"holder": true
} ]
} ]
}
MY Request using the NodeSDK
const {data:{flightOffers}} = req.body;
const {result} = await Amadeus.booking.flightOrders.post(
JSON.stringify({
'data': {
'type': 'flight-order',
'flightOffers': [ flightOffers[ 0 ] ],
'travelers': travelers
}
})
);
This is quite lengthy, but I did this so it is easy to just re-create the exact Scenario in case the issue is somewhere in the payload I am sending.
When you request Flight Create Order API, you have only put 1 traveler's information at the end that's why the error comes. you are requesting for flight order for 2 persons (1 adult and 1 child) so both information should be attached at the end.
below is a node example for the entire flow from Flight offer search, pricing, and create order. you may get a different error if some segments are not available, but the issue that you faced regarding travelers is resolved.
amadeus.shopping.flightOffersSearch.get({
originLocationCode: 'SYD',
destinationLocationCode: 'BKK',
departureDate: '2022-08-01',
adults: '1',
children: '1'
}).then(function (flightOffersResponse) {
return amadeus.shopping.flightOffers.pricing.post(
JSON.stringify({
'data': {
'type': 'flight-offers-pricing',
'flightOffers': [flightOffersResponse.data[0]]
}
})
)
}).then(function (pricingResponse) {
return amadeus.booking.flightOrders.post(
JSON.stringify({
'data': {
'type': 'flight-order',
'flightOffers': [pricingResponse.data.flightOffers[0]],
'travelers': [{
"id": "1",
"dateOfBirth": "1982-01-16",
"name": {
"firstName": "JORGE",
"lastName": "GONZALES"
},
"gender": "MALE",
"contact": {
"emailAddress": "jorge.gonzales833#telefonica.es",
"phones": [{
"deviceType": "MOBILE",
"countryCallingCode": "34",
"number": "480080076"
}]
},
"documents": [{
"documentType": "PASSPORT",
"birthPlace": "Madrid",
"issuanceLocation": "Madrid",
"issuanceDate": "2015-04-14",
"number": "00000000",
"expiryDate": "2025-04-14",
"issuanceCountry": "ES",
"validityCountry": "ES",
"nationality": "ES",
"holder": true
}]
},
{
"id": "2",
"dateOfBirth": "2012-10-11",
"gender": "FEMALE",
"contact": {
"emailAddress": "jorge.gonzales833#telefonica.es",
"phones": [
{
"deviceType": "MOBILE",
"countryCallingCode": "34",
"number": "480080076"
}
]
},
"name": {
"firstName": "ADRIANA",
"lastName": "GONZALES"
}
}]
}
})
);
}).then(function (response) {
console.log(response);
}).catch(function (response) {
console.error(response);
});

Vega: x-axis bar ploted out of range

I'm just trying to draw a grouped bar chart with Vega. But the bar that drew on the x-axis out of the range.
I tried to check the code but with limited knowledge of Vega, I failed. :-(
Here is my code. What I'm trying to do is to draw a vertical bar chat of value grouped by the country code which variable name is "category":
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic grouped bar chart example.",
"width": 400,
"height": 500,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{"position": "0", "value": "0.017220172", "category": "ARG", "snapshots": "2020/10/21"},
{"position": "1", "value": "0.026153846", "category": "ARG", "snapshots": "2020/5/21"},
{"position": "2", "value": "0.031484258", "category": "ARG", "snapshots": "2020/6/3"},
{"position": "3", "value": "0.022488756", "category": "ARG", "snapshots": "2020/6/17"},
{"position": "4", "value": "0.024390244", "category": "ARG", "snapshots": "2020/7/2"},
{"position": "5", "value": "0.015130674", "category": "ARG", "snapshots": "2020/7/29"},
{"position": "6", "value": "0.017173052", "category": "ARG", "snapshots": "2020/8/26"},
{"position": "7", "value": "0.025510204", "category": "ARG", "snapshots": "2020/9/24"},
{"position": "0", "value": "0.002949853", "category": "BRA", "snapshots": "2020/10/21"},
{"position": "1", "value": "0.012944984", "category": "BRA", "snapshots": "2020/5/21"},
{"position": "2", "value": "0.018987342", "category": "BRA", "snapshots": "2020/6/3"},
{"position": "3", "value": "0.006309148", "category": "BRA", "snapshots": "2020/6/17"},
{"position": "4", "value": "0.003125", "category": "BRA", "snapshots": "2020/7/2"},
{"position": "5", "value": "0.009202454", "category": "BRA", "snapshots": "2020/7/29"},
{"position": "6", "value": "0.011976048", "category": "BRA", "snapshots": "2020/8/26"},
{"position": "7", "value": "0.00295858", "category": "BRA", "snapshots": "2020/9/24"},
{"position": "0", "value": "0", "category": "CAN", "snapshots": "2020/10/21"},
{"position": "1", "value": "0", "category": "CAN", "snapshots": "2020/5/21"},
{"position": "2", "value": "0", "category": "CAN", "snapshots": "2020/6/3"},
{"position": "3", "value": "0", "category": "CAN", "snapshots": "2020/6/17"},
{"position": "4", "value": "0", "category": "CAN", "snapshots": "2020/7/2"},
{"position": "5", "value": "0", "category": "CAN", "snapshots": "2020/7/29"},
{"position": "6", "value": "0", "category": "CAN", "snapshots": "2020/8/26"},
{"position": "7", "value": "0", "category": "CAN", "snapshots": "2020/9/24"},
{"position": "0", "value": "0.002159827", "category": "CHL", "snapshots": "2020/10/21"},
{"position": "1", "value": "0.0302267", "category": "CHL", "snapshots": "2020/5/21"},
{"position": "2", "value": "0.024813896", "category": "CHL", "snapshots": "2020/6/3"},
{"position": "3", "value": "0.009975062", "category": "CHL", "snapshots": "2020/6/17"},
{"position": "4", "value": "0.00486618", "category": "CHL", "snapshots": "2020/7/2"},
{"position": "5", "value": "0.01891253", "category": "CHL", "snapshots": "2020/7/29"},
{"position": "6", "value": "0.004555809", "category": "CHL", "snapshots": "2020/8/26"},
{"position": "7", "value": "0.013274336", "category": "CHL", "snapshots": "2020/9/24"},
{"position": "0", "value": "0.010989011", "category": "COL", "snapshots": "2020/10/21"},
{"position": "1", "value": "0.016393443", "category": "COL", "snapshots": "2020/5/21"},
{"position": "2", "value": "0", "category": "COL", "snapshots": "2020/6/3"},
{"position": "3", "value": "0", "category": "COL", "snapshots": "2020/6/17"},
{"position": "4", "value": "0.014492754", "category": "COL", "snapshots": "2020/7/2"},
{"position": "5", "value": "0", "category": "COL", "snapshots": "2020/7/29"},
{"position": "6", "value": "0.024096386", "category": "COL", "snapshots": "2020/8/26"},
{"position": "7", "value": "0.011494253", "category": "COL", "snapshots": "2020/9/24"}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "table", "field": "category"},
"range": "width",
"padding": 0.2
},
{
"name": "yscale",
"type": "linear",
"domain": {"data": "table", "field": "value"},
"range": "height",
"round": true,
"zero": true,
"nice": true
},
{
"name": "color",
"type": "ordinal",
"domain": {"data": "table", "field": "position"},
"range": {"scheme": "category20"}
}
],
"axes": [
{"orient": "left", "scale": "yscale"},
{"orient": "bottom", "scale": "xscale", "tickSize": 2, "labelPadding": 4, "zindex": 1}
],
"marks": [
{
"type": "group",
"from": {
"facet": {
"data": "table",
"name": "facet",
"groupby": "category"
}
},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "category"}
}
},
"scales": [
{
"name": "pos",
"type": "band",
"range": "width",
"domain": {"data": "facet", "field": "position"}
}
],
"marks": [
{
"name": "bars",
"from": {"data": "facet"},
"type": "rect",
"encode": {
"enter": {
"x": {"scale": "pos", "field": "position"},
"width": {"scale": "pos", "band": 1},
"y": {"scale": "yscale", "field": "value"},
"y2": {"scale": "yscale", "value": 0},
"fill": {"scale": "color", "field": "position"}
}
}
}
]
}
]
}
Here is the result that I got:
Thanks to this post:
https://gist.github.com/AlexAbes/c17703ce10f7f4a272324ea317e7afce;
The x-scale needs to be updated.
"signals": [
{"name": "width", "update": "bandwidth('xscale')"}
],

CosmosDB GeoSpatial Points Invalid

I'm using Azure's cosmos DB, and testing via the sqlquery in the Azure portal. Some points in my collection are valid, some are not. I am unable to tell from the GeoJSON spec if I am missing requirements. All my points pass the geojsonlint test: https://geojsonlint.com/
What could be causing invalid points? The locations are setup the same as far as I can tell.
My Query:
SELECT *
FROM events1 e
WHERE ST_ISVALID(e.location)
Running the query returns that these are valid:
[
{
"id": "b4b49b65-dfad-40f3-943b-753553507d2c",
"name": "OG Olympics",
"location": {
"type": "Point",
"coordinates": [
41.900697426935544,
12.480266913771628
]
},
"events": "Hockey",
"time": "00:00:00",
"recurring": null,
"date": null,
"difficulty": "Expert",
"ages": "Senior",
"admin": null,
"private": null,
"_rid": "Maw1AIaRiRoHAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoHAAAAAAAAAA==/",
"_etag": "\"11003fb9-0000-0700-0000-5f2f15cf0000\"",
"_attachments": "attachments/",
"_ts": 1596921295
},
{
"id": "f2d063e3-5654-475d-8e97-7412dc77fcfb",
"name": "Test Event DenverCC",
"location": {
"type": "Point",
"coordinates": [
100.2093,
-15.868
]
},
"events": "Basketball",
"time": "18:00:00",
"recurring": null,
"date": null,
"difficulty": "Intermediate",
"ages": "Senior",
"admin": null,
"private": null,
"_rid": "Maw1AIaRiRoJAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoJAAAAAAAAAA==/",
"_etag": "\"1300a79d-0000-0700-0000-5f304fc80000\"",
"_attachments": "attachments/",
"_ts": 1597001672
},
{
"id": "10000",
"name": "OG Olympics 2",
"location": {
"type": "Point",
"coordinates": [
41.000697426935545,
-12.080266913771627
]
},
"events": "Hockey",
"time": "00:00:00",
"recurring": null,
"date": null,
"difficulty": "Expert",
"ages": "Senior",
"admin": null,
"private": null,
"_rid": "Maw1AIaRiRoKAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoKAAAAAAAAAA==/",
"_etag": "\"13003499-0000-0700-0000-5f304d580000\"",
"_attachments": "attachments/",
"_ts": 1597001048
}
]
But it returns that these are invalid:
{
"id": "1000",
"name": "Sunday Morning Hockey",
"location": {
"type": "Point",
"coordinates": [
39,
-105
]
},
"events": "hockey",
"time": "09:00",
"recurring": "true",
"date": "2020-08-02",
"difficulty": "all levels",
"ages": "all ages",
"admin": "1000",
"private": "false",
"_rid": "Maw1AIaRiRoBAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoBAAAAAAAAAA==/",
"_etag": "\"13008c9f-0000-0700-0000-5f3050d70000\"",
"_attachments": "attachments/",
"_ts": 1597001943
}
{
"id": "9f373e04-0cfc-4121-927d-a6256dbe06c6",
"name": "test1",
"location": {
"type": "Point",
"coordinates": [
39.731441899363105,
-104.98381230980158
]
},
"events": "Basketball",
"time": "00:00:00",
"recurring": null,
"date": null,
"difficulty": "Expert",
"ages": "Adult",
"admin": null,
"private": null,
"_rid": "Maw1AIaRiRoLAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoLAAAAAAAAAA==/",
"_etag": "\"13005999-0000-0700-0000-5f304d760000\"",
"_attachments": "attachments/",
"_ts": 1597001078
}
{
"id": "be01bc12-d28e-4368-b6de-0f3e84dbe13c",
"name": "test2",
"location": {
"type": "Point",
"coordinates": [
39.72082849205111,
-104.98461395502092
]
},
"events": "Hockey",
"time": "00:00:00",
"recurring": null,
"date": null,
"difficulty": "Expert",
"ages": "Adult",
"admin": null,
"private": null,
"_rid": "Maw1AIaRiRoMAAAAAAAAAA==",
"_self": "dbs/Maw1AA==/colls/Maw1AIaRiRo=/docs/Maw1AIaRiRoMAAAAAAAAAA==/",
"_etag": "\"1300219a-0000-0700-0000-5f304de10000\"",
"_attachments": "attachments/",
"_ts": 1597001185
}
Took a while to realize, but GeoJSON expects flipped coordinates in the Point.
So while Maps return me a point type with [ latitude, longitude ]. GeoJSON expects [longitude, latitude]

Vega-lite difference between Firefox and Chrome

I have a vega-lite chart that shows up as expected in Chrome (72.0.3626.96), but not in Firefox (70.0.1). I have checked the spec in the Vega Editor. Does anyone know why this might be?
Here are the rendered charts:
Firefox:
Chrome:
Here is the spec:
Any help you might be able to give would be much appreciated.
Apologies, but I do not know how to collapse this code.
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.2.1.json",
"background": "white",
"config": {"mark": {"tooltip": null}, "view": {"height": 300, "width": 400}},
"datasets": {
"data-511198e25d4dbee99248144390684caa": [
{
"counts": 338,
"filter_method": "greater than",
"grade": "9",
"index": 3,
"perc": 0.2669826224328594,
"school_code": "Board",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 414,
"filter_method": "greater than",
"grade": "9",
"index": 4,
"perc": 0.30689399555226093,
"school_code": "Board",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
}
],
"data-72a083843a98847e44077116c495e448": [
{
"counts": 49,
"filter_method": "greater than",
"grade": "9",
"index": 0,
"perc": 0.3356164383561644,
"school_code": "KING",
"threshold": "8",
"year": 20142015,
"year_lab": "2014/15",
"year_lab_q": "2014"
},
{
"counts": 62,
"filter_method": "greater than",
"grade": "9",
"index": 5,
"perc": 0.3668639053254438,
"school_code": "MLTS",
"threshold": "8",
"year": 20162017,
"year_lab": "2016/17",
"year_lab_q": "2016"
},
{
"counts": 53,
"filter_method": "greater than",
"grade": "9",
"index": 6,
"perc": 0.29608938547486036,
"school_code": "KING",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 44,
"filter_method": "greater than",
"grade": "9",
"index": 7,
"perc": 0.25882352941176473,
"school_code": "MLTS",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 53,
"filter_method": "greater than",
"grade": "9",
"index": 8,
"perc": 0.3212121212121212,
"school_code": "KING",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
},
{
"counts": 61,
"filter_method": "greater than",
"grade": "9",
"index": 9,
"perc": 0.25206611570247933,
"school_code": "MLTS",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
}
]
},
"height": 400,
"layer": [
{
"data": {"name": "data-72a083843a98847e44077116c495e448"},
"encoding": {
"color": {
"field": "school_code",
"legend": {"labelFontSize": 15, "titleFontSize": 20},
"title": null,
"type": "nominal"
},
"tooltip": [
{
"field": "perc",
"format": ".2%",
"title": "percentage",
"type": "quantitative"
},
{
"field": "counts",
"title": "number",
"type": "quantitative"
},
{"field": "year_lab", "title": "school year", "type": "nominal"},
{"field": "school_code", "title": "level", "type": "nominal"},
{"field": "grade", "type": "nominal"},
{"field": "filter_method", "type": "nominal"},
{"field": "threshold", "type": "nominal"}
],
"x": {
"axis": {"format": "%Y", "tickCount": 5},
"field": "year_lab_q",
"scale": {"domain": ["2013.9", "2018.5"]},
"title": "School Year (beginning)",
"type": "temporal"
},
"y": {
"axis": {"format": ".0%"},
"field": "perc",
"title": "Percentage",
"type": "quantitative"
}
},
"mark": {"point": true, "type": "line"},
"selection": {
"selector001": {
"bind": "scales",
"encodings": ["x", "y"],
"type": "interval"
}
}
},
{
"data": {"name": "data-511198e25d4dbee99248144390684caa"},
"encoding": {
"color": {
"field": "school_code",
"legend": {"labelFontSize": 15, "titleFontSize": 20},
"scale": {"domain": ["Board"], "range": ["black"]},
"title": null,
"type": "nominal"
},
"tooltip": [
{
"field": "perc",
"format": ".2%",
"title": "percentage",
"type": "quantitative"
},
{
"field": "counts",
"title": "number",
"type": "quantitative"
},
{"field": "year_lab", "title": "school year", "type": "nominal"},
{"field": "school_code", "title": "level", "type": "nominal"},
{"field": "grade", "type": "nominal"},
{"field": "filter_method", "type": "nominal"},
{"field": "threshold", "type": "nominal"}
],
"x": {"field": "year_lab_q", "type": "temporal"},
"y": {"field": "perc", "type": "quantitative"}
},
"mark": {"point": true, "type": "line"}
}
],
"resolve": {"scale": {"color": "independent"}},
"title": "A title!",
"width": 700
}
It appears that your temporal values are not being parsed correctly in firefox (details of javascript date parsing behavior is often browser-dependent). You could try forcing the correct parsing by changing your data specification (in both places) to:
"data": {
"name": "data-72a083843a98847e44077116c495e448",
"format": {"parse": {"year_lab_q": "date:%Y"}}
}
This should ensure that the year string is parsed as a year, rather than e.g. a unix timestamp.
The other place date parsing is happening is in your domain specification. You might try changing those to a more standard time format, e.g.
"domain": ["2013-11-01", "2018-06-01"]

Docusign List Population with Rest Endpoint (Modify Existing Recipient Tabs)

We are trying to populate an existing empty list on a DocuSign Template with some contact methods. The list needs to be populated on the fly since the number and default selected contact method varies with each recipient.
Here is our JSON request we PUT to https://demo.docusign.net/restapi/v2/accounts/:accountId/envelopes/:envelopeId/recipients/:recipientId/tabs (we have confirmed at the necessary variables in the URL have been filled in).
{
"accountId":"163051",
"checkboxTabs":[],
"companyTabs":[],
"dateTabs":[],
"emailTabs":[],
"envelopeId":"048f9ee2-df6e-482d-9e04-abb5e630bf83",
"fullNameTabs":[],
"initialHereTabs":[],
"listTabs":[{
"documentId":"1",
"locked":"False",
"name":"Preferred Contact Method",
"pageNumber":"1",
"tabId":"661499f2-4dda-419d-82ad-f943871407e9",
"tabLabel":"Preferred Contact Method",
"value":"Any",
"listItems":[{
"selected":"True",
"text":"Any",
"value":"1"},{
"selected":"False",
"text":"E-mail",
"value":"2"},{
"selected":"False",
"text":"Phone",
"value":"3"},{
"selected":"False",
"text":"Fax",
"value":"4"},{
"selected":"False",
"text":"Mail",
"value":"5"},{
"selected":"False",
"text":"Home Phone",
"value":"6"},{
"selected":"False",
"text":"Mobile Phone",
"value":"7"},{
"selected":"False",
"text":"Text",
"value":"8"},{
"selected":"False",
"text":"Facebook",
"value":"9"}]
}],
"noteTabs":[],
"radioGroupTabs":[],
"recipientId":"1",
"signHereTabs":[],
"textTabs":[],
"titleTabs":[],
"zipTabs":[]
}
And the response we are getting back:
The remote server returned an error: (500) Internal Server Error.
{
"errorCode": "INVALID_TAB_OPERATION",
"message": "The Tab specified is not valid for the requested operation. Attempt to create 'text' tab from invalid tab type.
}
There are no text tabs in our request. There is a tab with ID 661499f2-4dda-419d-82ad-f943871407e9 of type List on the template.
We were able to get this working a few months ago but fear a new version may have broken this functionality.
In case it is needed here is the "Get Recipient Tabs" response for the same envelope we are trying to modify. The list tab in question is at the bottom.
{
"signHereTabs": [
{
"name": "Sign Here",
"tabLabel": "Signature 12",
"scaleValue": 1,
"optional": "false",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "106",
"yPosition": "270",
"tabId": "00de6704-729d-4726-b102-829f914fda56"
}
],
"dateSignedTabs": [
{
"name": "Date Signed",
"value": "",
"tabLabel": "Date Signed",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "385",
"yPosition": "303",
"tabId": "6236a6cc-2d13-452e-af9b-6fe9706ff500"
}
],
"textTabs": [
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Last Name",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "36",
"yPosition": "146",
"tabId": "5aaee6db-a26a-4102-b77e-2eb4fb6e0c5b"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "First Name",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "224",
"yPosition": "147",
"tabId": "999d3f04-99b5-4fae-b69f-bd3e6b27e30d"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"maxLength": 1,
"tabLabel": "Middle Initial",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "368",
"yPosition": "145",
"tabId": "fdb77bb3-bbe0-4a0c-bf66-ac9fbaa4bb26"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Maiden Name",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "427",
"yPosition": "145",
"tabId": "ae99f579-0016-4839-b179-444fae166f71"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Address Street",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "36",
"yPosition": "175",
"tabId": "506abe87-b144-4d93-8576-b33a2abc4d85"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Apt",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "367",
"yPosition": "173",
"tabId": "7eaa32ef-b9b3-40e5-a5d3-5975134fb90d"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "DOB",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "429",
"yPosition": "175",
"tabId": "8f895bec-4f7a-4040-be77-f17374b30765"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Address City",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "36",
"yPosition": "202",
"tabId": "af6cbd27-072f-494d-8cb0-f60578b5e6c9"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Address State",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "212",
"yPosition": "202",
"tabId": "1ecc4a85-5252-4f4f-97d8-22238f46aae5"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Address Zip",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "368",
"yPosition": "202",
"tabId": "0dfb3731-7ce4-4c10-81f2-784428427ee7"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 17",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "446",
"yPosition": "256",
"tabId": "cb9a86c5-6ecf-4593-8c54-4b7e7d08ffb8"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 18",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "497",
"yPosition": "270",
"tabId": "0fc2dc21-7916-431f-aa38-a3b4df6c7bcf"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 19",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "498",
"yPosition": "283",
"tabId": "e0f8676f-6f98-43ee-81db-63734bfe3155"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "I am willing to travel.",
"width": 162,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 49",
"documentId": "1",
"recipientId": "1",
"pageNumber": "5",
"xPosition": "55",
"yPosition": "15",
"tabId": "5c3ddd45-c36c-4214-8b80-d800e0fa5b61"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "I am NOT willing to travel.",
"width": 162,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 50",
"documentId": "1",
"recipientId": "1",
"pageNumber": "5",
"xPosition": "56",
"yPosition": "41",
"tabId": "47d7d2ff-2a4f-4de7-9f67-311cd0b172c8"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "Preferred Contact Method",
"width": 138,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 52",
"documentId": "1",
"recipientId": "1",
"pageNumber": "1",
"xPosition": "81",
"yPosition": "21",
"tabId": "75b83aa1-c906-4827-9fc2-6cc4177843c6"
}
],
"ssnTabs": [
{
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "SSNTOOLTIP",
"value": "",
"width": 48,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "SSN",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "429",
"yPosition": "204",
"tabId": "11b62284-7613-48df-8498-fa019f3a42a3"
}
],
"radioGroupTabs": [
{
"documentId": "1",
"recipientId": "1",
"groupName": "Radio Button 13",
"radios": [
{
"pageNumber": "4",
"xPosition": "297",
"yPosition": "229",
"value": "Radio",
"selected": "false",
"tabId": "2b2312d2-3ed6-469e-8aeb-8de588ae16d3"
},
{
"pageNumber": "4",
"xPosition": "297",
"yPosition": "243",
"value": "Radio",
"selected": "false",
"tabId": "1a997301-f5d8-4e86-8ead-9d706490faf2"
},
{
"pageNumber": "4",
"xPosition": "297",
"yPosition": "256",
"value": "Radio",
"selected": "false",
"tabId": "705df9df-9e1d-478b-b991-9b31e919c85c"
},
{
"pageNumber": "4",
"xPosition": "297",
"yPosition": "271",
"value": "Radio",
"selected": "false",
"tabId": "d74742c2-742e-43d5-b1c5-04854ec8a7c5"
}
]
},
{
"groupName": "Radio Button Group Test",
"radios": [
{
"pageNumber": "5",
"xPosition": "28",
"yPosition": "15",
"value": "TravelYes",
"selected": "false",
"tabId": "30962105-0337-4d98-b4dd-058ae736d6fb"
},
{
"pageNumber": "5",
"xPosition": "27",
"yPosition": "40",
"value": "TravelNo",
"selected": "false",
"tabId": "351ba656-80dd-43ea-936a-fd322d63c0c0"
}
]
}
],
"listTabs": [
{
"listItems": [
{
"text": "",
"value": "",
"selected": "true"
},
{
"text": "",
"value": "",
"selected": "true"
}
],
"value": "",
"width": 77,
"shared": "false",
"requireInitialOnSharedChange": "false",
"tabLabel": "Preferred Contact Method",
"documentId": "1",
"recipientId": "1",
"pageNumber": "1",
"xPosition": "220",
"yPosition": "20",
"tabId": "661499f2-4dda-419d-82ad-f943871407e9"
}
]
}
This is a confirmed bug with DocuSign. I'm hoping this will get fixed in the next release but can't confirm yet. Once fixed I will update this answer to include the elements of a proper api call to modify an existing listTab, which I believe you're currently doing.