Closed SoptikHa2 closed 6 years ago
As an fyi, for the website, I transform the returned JSON on the server into this for the frontend. Many of it is sightly excessive and will not be useful to you, however, I do think that it may be easier to do things with.
I would also add that both are valid — in that if you parse only using members, you will end up having some members who are also no longer present, and that each time series have different lengths, as seen above. Here I have truncated most of them. And in fact, for some of my own application, I truncate the series and just leave the stats.
Basically, you will need to then map current member in the clan later on to figure out who you should look at and not — but for completeness, I output everything. Also because I am doing some calculation over the entire family, it makes sense for me to turn everyone into member instances as people move in and out of all our clans all the time.
{
"stats": {
"min_time": "2018-01-02 04:00",
"max_time": "2018-01-09 16:00",
"time_delta": {
"total_seconds": 648000,
"total_hours": 180,
"total_days": 7.5
},
"human": "1 week and 12 hours"
},
"members": {
"GQYU2PJ": {
"tag": "GQYU2PJ",
"name": "Dragneel",
"clanRank": {
"series": {
"2018-01-07 20:00": 23
},
"max": 23,
"min": 23,
"delta": {
"min_max": 0,
"period": 0
},
"changed": false
},
"donations": {
"series": {
"2018-01-07 20:00": 0
},
"max": 0,
"min": 0,
"delta": {
"min_max": 0,
"period": 0
},
"changed": false
},
"crowns": {
"series": {
"2018-01-07 20:00": 0
},
"max": 0,
"min": 0,
"delta": {
"min_max": 0,
"period": 0
},
"changed": false
},
"trophies": {
"series": {
"2018-01-07 20:00": 4714
},
"max": 4714,
"min": 4714,
"delta": {
"min_max": 0,
"period": 0
},
"changed": false
},
"stats": {
"min_time": "2018-01-07 20:00",
"max_time": "2018-01-07 20:00",
"time_delta": {
"total_seconds": 0,
"total_hours": 0,
"total_days": 0
},
"human": "0 seconds",
"changed": false
}
},
"QVYVU0JP": {
"tag": "QVYVU0JP",
"name": "Nasty Nate",
"clanRank": {
"series": {
"2018-01-02 04:00": 15,
"2018-01-02 08:00": 22,
"2018-01-02 12:00": 20,
"2018-01-02 16:00": 17,
"2018-01-02 20:00": 19,
"2018-01-03 00:00": 32,
"2018-01-03 04:00": 32,
"2018-01-03 08:00": 14,
"2018-01-03 12:00": 17,
"2018-01-03 16:00": 22,
"2018-01-03 20:00": 6,
"2018-01-04 00:00": 8,
"2018-01-04 04:00": 14,
"2018-01-04 08:00": 15,
"2018-01-04 12:00": 15,
"2018-01-04 16:00": 15,
"2018-01-04 20:00": 16,
"2018-01-05 00:00": 17,
"2018-01-05 04:00": 17,
"2018-01-05 08:00": 20,
"2018-01-05 12:00": 19,
"2018-01-05 16:00": 23,
"2018-01-05 20:00": 22,
"2018-01-06 00:00": 16,
"2018-01-06 04:00": 10,
"2018-01-06 08:00": 11,
"2018-01-06 12:00": 12,
"2018-01-06 16:00": 11,
"2018-01-06 20:00": 9,
"2018-01-07 00:00": 12,
"2018-01-07 04:00": 12,
"2018-01-07 08:00": 14,
"2018-01-07 12:00": 18,
"2018-01-07 16:00": 20,
"2018-01-07 20:00": 21,
"2018-01-08 00:00": 22,
"2018-01-08 04:00": 26,
"2018-01-08 08:00": 26,
"2018-01-08 16:00": 30,
"2018-01-08 20:00": 25,
"2018-01-09 00:00": 27,
"2018-01-09 12:00": 30,
"2018-01-09 16:00": 30
},
"max": 32,
"min": 6,
"delta": {
"min_max": 26,
"period": 15
},
"changed": true
},
"donations": {
"series": {
"2018-01-02 04:00": 162,
"2018-01-02 08:00": 232,
"2018-01-02 12:00": 350,
"2018-01-02 16:00": 350,
"2018-01-02 20:00": 360,
"2018-01-03 00:00": 370,
"2018-01-03 04:00": 370,
"2018-01-03 08:00": 448,
"2018-01-03 12:00": 468,
"2018-01-03 16:00": 468,
"2018-01-03 20:00": 549,
"2018-01-04 00:00": 549,
"2018-01-04 04:00": 549,
"2018-01-04 08:00": 549,
"2018-01-04 12:00": 597,
"2018-01-04 16:00": 597,
"2018-01-04 20:00": 597,
"2018-01-05 00:00": 597,
"2018-01-05 04:00": 717,
"2018-01-05 08:00": 767,
"2018-01-05 12:00": 767,
"2018-01-05 16:00": 767,
"2018-01-05 20:00": 767,
"2018-01-06 00:00": 897,
"2018-01-06 04:00": 927,
"2018-01-06 08:00": 997,
"2018-01-06 12:00": 0,
"2018-01-06 16:00": 0,
"2018-01-06 20:00": 0,
"2018-01-07 00:00": 20,
"2018-01-07 04:00": 40,
"2018-01-07 08:00": 40,
"2018-01-07 12:00": 40,
"2018-01-07 16:00": 40,
"2018-01-07 20:00": 40,
"2018-01-08 00:00": 40,
"2018-01-08 04:00": 0,
"2018-01-08 08:00": 0,
"2018-01-08 16:00": 0,
"2018-01-08 20:00": 0,
"2018-01-09 00:00": 0,
"2018-01-09 12:00": 0,
"2018-01-09 16:00": 0
},
"max": 997,
"min": 0,
"delta": {
"min_max": 997,
"period": -162
},
"changed": true
},
"crowns": {
"series": {
"2018-01-02 04:00": 0,
"2018-01-02 08:00": 0,
"2018-01-02 12:00": 0,
"2018-01-02 16:00": 0,
"2018-01-02 20:00": 0,
"2018-01-03 00:00": 0,
"2018-01-03 04:00": 0,
"2018-01-03 08:00": 0,
"2018-01-03 12:00": 0,
"2018-01-03 16:00": 0,
"2018-01-03 20:00": 0,
"2018-01-04 00:00": 0,
"2018-01-04 04:00": 0,
"2018-01-04 08:00": 0,
"2018-01-04 12:00": 0,
"2018-01-04 16:00": 0,
"2018-01-04 20:00": 0,
"2018-01-05 00:00": 0,
"2018-01-05 04:00": 0,
"2018-01-05 08:00": 0,
"2018-01-05 12:00": 0,
"2018-01-05 16:00": 0,
"2018-01-05 20:00": 0,
"2018-01-06 00:00": 17,
"2018-01-06 04:00": 44,
"2018-01-06 08:00": 44,
"2018-01-06 12:00": 0,
"2018-01-06 16:00": 0,
"2018-01-06 20:00": 0,
"2018-01-07 00:00": 0,
"2018-01-07 04:00": 0,
"2018-01-07 08:00": 0,
"2018-01-07 12:00": 0,
"2018-01-07 16:00": 0,
"2018-01-07 20:00": 0,
"2018-01-08 00:00": 0,
"2018-01-08 04:00": 0,
"2018-01-08 08:00": 0,
"2018-01-08 16:00": 0,
"2018-01-08 20:00": 0,
"2018-01-09 00:00": 0,
"2018-01-09 12:00": 0,
"2018-01-09 16:00": 0
},
"max": 44,
"min": 0,
"delta": {
"min_max": 44,
"period": 0
},
"changed": true
},
"trophies": {
"series": {
"2018-01-02 04:00": 4489,
"2018-01-02 08:00": 4447,
"2018-01-02 12:00": 4476,
"2018-01-02 16:00": 4476,
"2018-01-02 20:00": 4474,
"2018-01-03 00:00": 4443,
"2018-01-03 04:00": 4443,
"2018-01-03 08:00": 4554,
"2018-01-03 12:00": 4544,
"2018-01-03 16:00": 4544,
"2018-01-03 20:00": 4630,
"2018-01-04 00:00": 4630,
"2018-01-04 04:00": 4630,
"2018-01-04 08:00": 4630,
"2018-01-04 12:00": 4630,
"2018-01-04 16:00": 4630,
"2018-01-04 20:00": 4630,
"2018-01-05 00:00": 4630,
"2018-01-05 04:00": 4630,
"2018-01-05 08:00": 4630,
"2018-01-05 12:00": 4630,
"2018-01-05 16:00": 4630,
"2018-01-05 20:00": 4630,
"2018-01-06 00:00": 4659,
"2018-01-06 04:00": 4717,
"2018-01-06 08:00": 4717,
"2018-01-06 12:00": 4717,
"2018-01-06 16:00": 4717,
"2018-01-06 20:00": 4717,
"2018-01-07 00:00": 4717,
"2018-01-07 04:00": 4717,
"2018-01-07 08:00": 4717,
"2018-01-07 12:00": 4717,
"2018-01-07 16:00": 4717,
"2018-01-07 20:00": 4717,
"2018-01-08 00:00": 4717,
"2018-01-08 04:00": 4717,
"2018-01-08 08:00": 4717,
"2018-01-08 16:00": 4717,
"2018-01-08 20:00": 4717,
"2018-01-09 00:00": 4717,
"2018-01-09 12:00": 4717,
"2018-01-09 16:00": 4717
},
"max": 4717,
"min": 4443,
"delta": {
"min_max": 274,
"period": 228
},
"changed": true
},
"stats": {
"min_time": "2018-01-02 04:00",
"max_time": "2018-01-09 16:00",
"time_delta": {
"total_seconds": 648000,
"total_hours": 180,
"total_days": 7.5
},
"human": "1 week and 12 hours",
"changed": true
}
},
I would request that even if @selfish agree to transform into a different format, that he keep the one he has right now as well — maybe a different endpoint or toggle the formats using params. As I said, both are valid for different reasons and I need them both.
Or rather — that since I have already done the work on one, I don’t want to rewrite everything to get the format I need…
Thanks!
So here's the deal. Since every community member asks their own changes, I'm not going to implement any of those. If you wish to create a translator for your needs in javascript I am willing to include it in the API.
Not worth the dev time, as I can create tens of different formats.
At this moment, the format is:
This is hard to use and parse, it'd be much better, if you used something like this:
This format is much better for reading, it allows developers to directly parse JSON into array of objects. So we will end up with something like this
If we would use the format that is there now, we would have to invent some difficult parsing to achieve this:
This is much more difficult to develop, use, and it's almost impossible to, for example, search inside results and return something, for example results from last month.
Let's just use much more simple array. Members in clans are array, so why not this?
Thanks, Peter