could you please help me to group by the following json and return a hashMap in kotlin based on date with RxKotlin? is so easy with just kotlin but really stuck for Rxkotlin. thanks
val groupedTransactions = accountTransactions.transactions
?.groupBy { it.effectiveDate }
"transactions": [{
"id": "44e5b2bc484331ea24afd85ecfb212c8",
"effectiveDate": "20/07/2017",
"description": "Kaching TFR from JOHN CITIZEN<br/>xmas donation",
"amount": 12.00
}, {
"id": "1506aeeb8c3a699b1e3c87db03156428",
"effectiveDate": "20/07/2017",
"description": "Wdl ATM CBA ATM CIRCULAR QUAY STATION NSW 221092 AUS",
"amount": -200.00,
"atmId": "129382"
}, {
"id": "9a899bfd978511e9605774e1d5222b67",
"description": "Savings",
"effectiveDate": "19/07/2017",
"amount": 10.00
}, {
"id": "1a6c48627cecaa2388b702fa33d751ff",
"description": "PTAG COCA COLA AMATI",
"effectiveDate": "12/07/2017",
"amount": -2.20
}, {
"id": "7ecc19e1a0be36ba2c6f05d06b5d3058",
"description": "Wdl ATM CBA ATM TOWN HALL SQUARE NSW 253432 AUS",
"effectiveDate": "04/07/2017",
"amount": -50.00,
"atmId": "137483"
}, {
"id": "b71bf065b640217dad602f86ac047722",
"description": "BPAY - Telstra mobile",
"effectiveDate": "04/07/2017",
"amount": -49.00
},{
"id": "ef087651eb482bae4624478696f4ad4f",
"description": "Transfer from REBECCA SHAW<br/>Lorem ipsum",
"effectiveDate": "03/07/2017",
"amount": 150.00
}, {
"id": "8cd283d8b7bacc277f2bae5e26ce6d1e",
"description": "Savings",
"effectiveDate": "01/07/2017",
"amount": 200.00
}, {
"id": "04117d2d74f5331f3ee4955da27cca7a",
"effectiveDate": "28/06/2017",
"description": "Transfer - Saturday drinks",
"amount": -100.00
}, {
"id": "821ae63dbe0c573eff8b69d451fb21bc",
"effectiveDate": "21/06/2017",
"description": "Wdl ATM CBA ATM CIRCULAR QUAY STATION NSW 221092 AUS",
"amount": -200.00,
"atmId": "129382"
}]
this looks lik the rxkotlin issue. I've done it through coroutine kotlin like:
doAsync { val groupedTransactions = accountTransactions.transactions ?.groupBy { it.effectiveDate } ....
Related
I would like to put my rules in the database so that some tables can only be written by the admin. I'm having trouble with this :( could someone help me?
Inside my user table I have an "admin" field: true.
I would like the "users" and "Vinyls" tables to be modified only by the admin.
At the moment I have set the following rules, but doing so I cannot modify the vinyls table.
{
"rules": {
"users": {
".read":"root.child('users').child('uid').val()===auth.id",
".write":"root.child('users').child('uid').val()===auth.id"
},
"Vinyls":{
".read":"root.child('users').child('uid').val()===auth.id",
".write":"root.child('users').child(auth.id).child('admin').val()=='true'"
},
"WishList":{
".read":"root.child('users').child('uid').val()===auth.id",
".write":"root.child('users').child('uid').val()===auth.id"
},
"RatingUsersVinyls":{
".read":"root.child('users').child('uid').val()===auth.id",
".write":"root.child('users').child('uid').val()===auth.id"
}
}
}
users table:
{
"users": {
"Qi8HU8YFMLhKhvoiHLkR6ooqnOp2": {
"admin": true,
"email": "admin#gmail.com",
"name": "Admin",
"password": "admin123",
"surname": "Admin Surname"
},
"rTEp7K1cE8W4pZF9diB09ZxWfC72": {
"admin": false,
"email": "testUser#hotmail.it",
"name": "User",
"password": "test123",
"surname": "Test"
}
}
}
Vinyls table:
"Vinyls": {
"v1": {
"author": "Pink Floyd",
"description": "A1 In The Flesh? , A2 The Thin Ice, A3 Another Brick In The Wall Part 1, A4 The Happiest Days Of Our Lives, A5 Another Brick In The Wall Part 2, A6\tMother, B1 Goodbye Blue Sky, B2 Empty Spaces, B3 Young Lust, B4\tOne Of My Turns, B5 Don't Leave Me Now, B6 Another Brick In The Wall Part 3,B7\t Goodbye Cruel World, C1\tHey You,C2\tIs There Anybody Out There?, C3 Nobody Home,C4 Vera,C5 Bring The Boys Back Home,C6 Comfortably Numb,D1 The Show Must Go On,D2 In The Flesh,D3\tRun Like Hell,D4 Waiting For The Worms,D5\tStop,D6\tThe Trial,D7\tOutside The Wall",
"genre": "rock",
"imgSrc": "https://i.discogs.com/L_VyYyJq5qz9dKeMRuRSGg3ftbl-sadWu4oaJotdn-M/rs:fit/g:sm/q:90/h:600/w:588/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTIwNDE2/MTgtMTM5MDY3OTAy/NS0yMzcyLmpwZWc.jpeg",
"name": "The Wall",
"price": "20",
"youtubeLink": "https://www.youtube.com/playlist?list=OLAK5uy_nE3dmeYl_9Jgv2CT0aqufkDcyB6BBMcGM"
},
"v2": {
"author": "Tresor",
"description": "E1 –Joey Beltram Ball Park (DJ Rush First Bass Mix), E2 –Joey Beltram Game Form (Mike Dearborn Remix),F1 –3 Phase Feat. Dr.,F2 –Ingator Skyscratch (Mano Mano),G1 –K.Hand* Mystery,G2 –Marshall Jefferson Floating,H1 –3MB Feat. Juan Atkins Die Kosmischen Kuriere,H2 –Eddie Flashin' Fowlkes* & Blake Baxter Wisdom",
"genre": "TechnoX",
"imgSrc": "https://i.discogs.com/gpDw1iNqHNRbzb3M_z6unHWMc_T2nnx4SoiymIuu02Y/rs:fit/g:sm/q:40/h:300/w:300/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTMyMjk0/LTEyNTUzMDEwNjgu/anBlZw.jpeg",
"name": "Various – True Spirit. Part II",
"price": "25",
"youtubeLink": "https://youtu.be/kyYOk-irg_Y"
},
"v3": {
"author": "The Hacker",
"description": "A1 Propagande, A2 Still ,B1 La Marine ,B2 Propagande V2",
"genre": "Electro, House, Techno",
"imgSrc": "https://i.discogs.com/IltPMOL6d_JFSF4mT-U9SkZ5WyJ2WERAfp4UXAq4lLU/rs:fit/g:sm/q:40/h:300/w:300/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTEwNDAz/Nzk0LTE0OTY3NTg5/NDMtNDQ5Ny5wbmc.jpeg",
"name": "Propagande EP",
"price": "67",
"youtubeLink": "https://youtu.be/QQRBdMQEMDM"
},
"v4": {
"author": "Dettmann* | Klock*",
"description": "A1 Phantom Studies ,B1 No One Around ,B2 The Room ,C1 Prophet Man ,C2 Bad Boy ,D1 The World Tonight ,D2 The Tenant",
"genre": "Techno",
"imgSrc": "https://i.discogs.com/jPsplJDJJjZ0U1ZANW-1DFiyorKAjzy01cS7QFqgo9I/rs:fit/g:sm/q:90/h:600/w:600/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTk2NDE4/NjUtMTQ4NDA3NjM1/OS00MDIwLmpwZWc.jpeg",
"name": "Phantom Studies",
"price": "55",
"youtubeLink": "https://youtu.be/dsiZO6oAekE"
},
"v5": {
"author": "Adiel",
"description": "A1 Method ,A2 Mad ,B1 Time Is Out ,B2 In Your Power",
"genre": "Techno",
"imgSrc": "https://i.discogs.com/9gKf_bXz5gLn4peUqdeQi3WS9Vmie82tM7cAUB1o-ks/rs:fit/g:sm/q:40/h:300/w:300/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTE4OTE0/NTM2LTE2MjIxOTA1/NDMtMTk3NS5qcGVn.jpeg",
"name": "Method EP",
"price": "20",
"youtubeLink": "https://youtu.be/-Hgk_LgZ5lw"
},
"v6": {
"author": "Fadi Mohem",
"description": "A1 Moving On ,A2 Reinforced ,B1 RS-290 ,B2 Horus",
"genre": "Techno",
"imgSrc": "https://i.discogs.com/O5BE45prwmh1Xm3KBeJEizPLQeLqjI2MR6tAc-hANCU/rs:fit/g:sm/q:40/h:300/w:300/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTEyMjgx/NDg5LTE2MzU0MzEy/NTItMTUwNC5qcGVn.jpeg",
"name": "Reinforced",
"price": "35",
"youtubeLink": "https://youtu.be/Se2lDHsffUk"
},
"v7": {
"author": "PSYK",
"description": "A1 Distane ,A2 Isolate ,B1 Rdmn ,B2 Main",
"genre": "Techno",
"imgSrc": "https://i.discogs.com/z8ORhybojMioq2zuApKcQw64BOj1NZYy5BRp61o3HxE/rs:fit/g:sm/q:40/h:300/w:300/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTM4NjIx/MjItMTM2MDUwNjM5/MC02MjIzLmpwZWc.jpeg",
"name": "Distane E.P.",
"price": "15",
"youtubeLink": "https://youtu.be/2qDCoLvBaVo"
},
"v8": {
"author": "Sterac Electronics ",
"description": "A Keep On Running ,B1 Destination Reached ,B2 Next Destination (Dub)",
"genre": "Techno",
"imgSrc": "https://i.discogs.com/VQ0Q_PEJLllfK5tga85qnHeCx7KyqOOdcqIvstt6_ss/rs:fit/g:sm/q:90/h:600/w:600/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTIxNjE4/OC0xMjAwMzIwMjE4/LmpwZWc.jpeg",
"name": "Keep On Running",
"price": "42",
"youtubeLink": "https://youtu.be/7RHqlCwz2jU"
}
}
WishList table:
"WishList": {
"-N5nJXczFMxIzVdOUtMc": {
"author": "Pink Floyd",
"imgSrc": "https://i.discogs.com/L_VyYyJq5qz9dKeMRuRSGg3ftbl-sadWu4oaJotdn-M/rs:fit/g:sm/q:90/h:600/w:588/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTIwNDE2/MTgtMTM5MDY3OTAy/NS0yMzcyLmpwZWc.jpeg",
"name": "The Wall",
"price": "20$",
"userId": "Qi8HU8YFMLhKhvoiHLkR6ooqnOp2",
"vinylId": "v1"
},
"-N5p9QJucK2kGs0EMhBO": {
"author": "Pink Floyd",
"imgSrc": "https://i.discogs.com/L_VyYyJq5qz9dKeMRuRSGg3ftbl-sadWu4oaJotdn-M/rs:fit/g:sm/q:90/h:600/w:588/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTIwNDE2/MTgtMTM5MDY3OTAy/NS0yMzcyLmpwZWc.jpeg",
"name": "The Wall",
"price": "20$",
"userId": "rTEp7K1cE8W4pZF9diB09ZxWfC72",
"vinylId": "v1"
}
},
Rating table:
"RatingUsersVinyls": {
"-N5fUpaXS_kKk_AtIPs1": {
"rating": "4",
"userId": "DiL1JNTc4RO7Eyr2tczv84Q3FII3",
"vinylId": "v1"
}
},
I'm trying to add padding to my adaptive card view so that it's contents are inset from the edge of the card. I'd like to not adjust the padding of any of the internal card elements. I'm trying to use the following host config, which parses without error but seems to have no effect on the card.
Host config JSON:
{
"spacing": {
"small": 3,
"default": 8,
"medium": 20,
"large": 30,
"extraLarge": 40,
"padding": 100
},
"adaptiveCard": {
"allowCustomStyle": true,
"spacing": {
"padding": 100
}
}
}
Resulting card:
As you can see, there is certainly not 100px of padding being added to the card. I've used sample host configs and tweak other settings like colors so I know the config is being applied, but nothing I do seems to affect the card padding. Thanks in advance!
Card JSON:
{
"type": "AdaptiveCard",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Publish Adaptive Card schema"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "Image",
"style": "Person",
"url": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
"size": "Small"
}
],
"width": "auto"
},
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"weight": "Bolder",
"text": "Matt Hidinger",
"wrap": true
},
{
"type": "TextBlock",
"spacing": "None",
"text": "Created {{DATE(2017-02-14T06:08:39Z,SHORT)}}",
"isSubtle": true,
"wrap": true
}
],
"width": "stretch"
}
]
}
]
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Now that we have defined the main rules and features of the format, we need to produce a schema and publish it to GitHub. The schema will be the starting point of our reference documentation.",
"wrap": true
},
{
"type": "FactSet",
"facts": [
{
"title": "Board:",
"value": "Adaptive Card"
},
{
"title": "List:",
"value": "Backlog"
},
{
"title": "Assigned to:",
"value": "Matt Hidinger"
},
{
"title": "Due date:",
"value": "Not set"
}
]
}
]
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Set due date",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Date",
"id": "dueDate"
},
{
"type": "Input.Text",
"id": "comment",
"placeholder": "Add a comment",
"isMultiline": true
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "OK",
"url": "http://adaptivecards.io"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
},
{
"type": "Action.OpenUrl",
"title": "View",
"url": "http://adaptivecards.io"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
I am creating an avro schema for a JSON payload that appear to have an array of multiple objects. I'm not sure exactly how to represent this in the schema. The key in question is content:
{
"id": "channel-id",
"name": "My Channel with a New Title",
"description": "Herpy me derpy merpus herpsum ner berp berps derp ter tee",
"privacyLevel": "<private|org>",
"planId": "some-plan-id",
"owner": "a-user-handle",
"curators": [
"user-handle-1",
"user-handle-2"
],
"members": 5,
"content": [
{
"id": "docker",
"slug": "docker",
"index": 1,
"type": "path"
},
{
"id": "such-linkage",
"slug": "such-linkage",
"index": 2,
"type": "external-link",
"details": {
"url": "http://some-dank-link.com",
"title": "My Dank Link",
"contentType": "External Link",
"level": "Beginner",
"duration": "PT34293H33M9S"
}
},
{
"id": "21f1e812-b10a-40df-8b52-3a1d05fc215c",
"slug": "windows-azure-storage-in-depth",
"index": 3,
"type": "course"
},
{
"id": "7c346c05-6416-42dd-80b2-d5e758de7926",
"slug": "7c346c05-6416-42dd-80b2-d5e758de7926",
"index": 4,
"type": "project"
}
],
"imageUrls": ["https://url/to/an/image", "https://url/to/another/image"],
"analyticsEnabled": true,
"orgDiscoverable": false,
"createdDate": "2015-12-31T01:23:45+00:00",
"archiveDate": "2015-12-31T01:23:45+00:00",
"messagePublishedAt": "2015-12-31T01:23:45+00:00"
}
If you are asking if it is possible create an array with different kind of records, it is. Avro support this through union. it would looks like .
{
"name": "myRecord",
"type":"record",
"fields":[
{
"name":"myArrayWithMultiplesTypes",
"type":{
"type": "array",
"items":[
{
"name":"typeOne",
"type":"record",
"fields":[
{"name":"name", "type":"string"}
]
},
{
"name":"typeTwo",
"type":"record",
"fields":[
{"name":"id", "type":"int"}
]
}
]
}
}
]
}
If you already have the records defined previously, then it could look like this:
{
"name": "mulitplePossibleTypes",
"type": [
"null",
{
"type": "array",
"items": [
"com.xyz.kola.cloud.events.itemmanager.Part",
"com.xyz.kola.cloud.events.itemmanager.Document",
"com.xyz.kola.cloud.events.itemmanager.DigitalModel",
"com.xyz.kola.cloud.events.itemmanager.Interface"
]
}
]
},
I created a bill through the QuickBooks Online (QBO) web UI. Then I queried using the API (v3, documented here). The response:
{
"SyncToken": "16",
"domain": "QBO",
"VendorRef": {
"name": "MyVendor",
"value": "237"
},
"TxnDate": "2014-12-07",
"TotalAmt": 1.83,
"CurrencyRef": {
"name": "United States Dollar",
"value": "USD"
},
"PayType": "Check",
"PrivateNote": "test billpayment description (mod)",
"sparse": false,
"Line": [
{
"Amount": 1.22,
"LinkedTxn": [
{
"TxnId": "1412",
"TxnType": "Bill"
}
]
}
],
"Id": "1413",
"CheckPayment": {
"PrintStatus": "NeedToPrint",
"BankAccountRef": {
"name": "MyBankAcct#1234",
"value": "137"
}
},
"MetaData": {
"CreateTime": "2014-12-07T18:44:51-08:00",
"LastUpdatedTime": "2014-12-10T20:20:28-08:00"
}
}
As you can see, it has $0.61 of the TotalAmt unapplied to any Bills. (The other $1.22 is applied to Bill 1412.) Now, when I try to update this bill to change JUST the amount applied to the linked transaction, I get unexpected results.
Here's the update request body:
{
"SyncToken": "16",
"domain": "QBO",
"VendorRef": {
"name": "MyVendor",
"value": "237"
},
"TxnDate": "2014-12-07",
"TotalAmt": 1.83,
"CurrencyRef": {
"name": "United States Dollar",
"value": "USD"
},
"PayType": "Check",
"PrivateNote": "test billpayment description (mod)",
"sparse": false,
"Line": [
{
"Amount": 1.21,
"LinkedTxn": [
{
"TxnId": "1412",
"TxnType": "Bill"
}
]
}
],
"Id": "1413",
"CheckPayment": {
"PrintStatus": "NeedToPrint",
"BankAccountRef": {
"name": "MyBankAcct#1234",
"value": "137"
}
},
"MetaData": {
"CreateTime": "2014-12-07T18:44:51-08:00",
"LastUpdatedTime": "2014-12-10T20:20:28-08:00"
}
}
In the response, it appears that the API just basically can't handle the situation (even though it clearly existed when I created it in the web UI). Look what happens to the TotalAmt attribute! It's reduced to whatever the payment was in the LinkedTxn:
{
"BillPayment": {
"VendorRef": {
"value": "237",
"name": "MyVendor"
},
"PayType": "Check",
"CheckPayment": {
"BankAccountRef": {
"value": "137",
"name": "MyBankAcct#1234"
},
"PrintStatus": "NeedToPrint"
},
"TotalAmt": 1.21,
"domain": "QBO",
"sparse": false,
"Id": "1413",
"SyncToken": "17",
"MetaData": {
"CreateTime": "2014-12-07T18:44:51-08:00",
"LastUpdatedTime": "2014-12-10T20:25:02-08:00"
},
"TxnDate": "2014-12-07",
"CurrencyRef": {
"value": "USD",
"name": "United States Dollar"
},
"PrivateNote": "test billpayment description (mod)",
"Line": [
{
"Amount": 1.21,
"LinkedTxn": [
{
"TxnId": "1412",
"TxnType": "Bill"
}
]
}
]
},
"time": "2014-12-10T20:25:01.91-08:00"
}
I don't see discussion of this on the known issues page, so I'm pretty confused.
If you have any suggestions as to how to get this to do what I want it to, I thank you for your thoughts!
Is there a way to use geokit in rails to get the estimated travel time between two locations? Right now, I'm simply showing the distance away but I think a better approach would be to show '15 minutes away' -- gives it a more practical approach to distance (sometimes 2 miles is 10 minutes and sometimes its 3)
A better solution would be to use the Google Maps Directions API using the API is as simple as calling the following URL http://maps.googleapis.com/maps/api/directions/json?origin=Chicago,IL&destination=Los+Angeles,CA&waypoints=Joplin,MO|Oklahoma+City,OK&sensor=false.
Which returns this JSON:
{
"status": "OK",
"routes": [ {
"summary": "I-40 W",
"legs": [ {
"steps": [ {
"travel_mode": "DRIVING",
"start_location": {
"lat": 41.8507300,
"lng": -87.6512600
},
"end_location": {
"lat": 41.8525800,
"lng": -87.6514100
},
"polyline": {
"points": "a~l~Fjk~uOwHJy#P",
"levels": "B?B"
},
"duration": {
"value": 19,
"text": "1 min"
},
"html_instructions": "Head \u003cb\u003enorth\u003c/b\u003e on \u003cb\u003eS Morgan St\u003c/b\u003e toward \u003cb\u003eW Cermak Rd\u003c/b\u003e",
"distance": {
"value": 207,
"text": "0.1 mi"
}
},
...
... additional steps of this leg
...
... additional legs of this route
"duration": {
"value": 74384,
"text": "20 hours 40 mins"
},
"distance": {
"value": 2137146,
"text": "1,328 mi"
},
"start_location": {
"lat": 35.4675602,
"lng": -97.5164276
},
"end_location": {
"lat": 34.0522342,
"lng": -118.2436849
},
"start_address": "Oklahoma City, OK, USA",
"end_address": "Los Angeles, CA, USA"
} ],
"copyrights": "Map data ©2010 Google, Sanborn",
"overview_polyline": {
"points": "a~l~Fjk~uOnzh#vlbBtc~#tsE`vnApw{A`dw#~w\\|tNtqf#l{Yd_Fblh#rxo#b}#xxSfytAblk#xxaBeJxlcBb~t#zbh#jc|Bx}C`rv#rw|#rlhA~dVzeo#vrSnc}Axf]fjz#xfFbw~#dz{A~d{A|zOxbrBbdUvpo#`cFp~xBc`Hk#nurDznmFfwMbwz#bbl#lq~#loPpxq#bw_#v|{CbtY~jGqeMb{iF|n\\~mbDzeVh_Wr|Efc\\x`Ij{kE}mAb~uF{cNd}xBjp]fulBiwJpgg#|kHntyArpb#bijCk_Kv~eGyqTj_|#`uV`k|DcsNdwxAott#r}q#_gc#nu`CnvHx`k#dse#j|p#zpiAp|gEicy#`omFvaErfo#igQxnlApqGze~AsyRzrjAb__#ftyB}pIlo_BflmA~yQftNboWzoAlzp#mz`#|}_#fda#jakEitAn{fB_a]lexClshBtmqAdmY_hLxiZd~XtaBndgC",
"levels": "BBBAAAAABAABAAAAAABBAAABBAAAABBAAABABAAABABBAABAABAAAABABABABBABAABB"
},
"warnings": [ ],
"waypoint_order": [ 0, 1 ],
"bounds": {
"southwest": {
"lat": 34.0523600,
"lng": -118.2435600
},
"northeast": {
"lat": 41.8781100,
"lng": -87.6297900
}
}
} ]
}
Then parse the JSON returned to grab the duration.text and display it on your page.
You may have to comply with terms of service in order to use this API so make sure you read up on googles requirements and how they affect the use of the service.