Kender2 / swc-squadranking

SWC squad war ranking
http://squadsofdeath.com/squadranking
6 stars 8 forks source link

Create a Squad Stats feature #10

Open InsomniacEM opened 7 years ago

InsomniacEM commented 7 years ago

A few options for this...

1) Expose an API to retrieve squad stats in a machine readable format

2) Add a link to the Squad members page that generates a CSV file containing the squad data

3) Add a Stats History view which shows the squad's stats history on a given date. Allow the selection of a date range to show deltas between the two dates (i.e. Medals Gained/Lost, Attacks/Defenses Won, Donations, new/removed squad members, etc.)

Kender2 commented 7 years ago

I have implemented 1 & 2 with a3507c666f2ce95a8333fb7645ae340dda6c8cfd

InsomniacEM commented 7 years ago

Exciting. I don't know PHP well...Looks like you implemented an API that returns JSON?

Kender2 commented 7 years ago

Yes, make sure your client sends an Accept: application/json header and the normal requests will return JSON. Example request:

GET /squad/aea3f09d-b002-11e4-ae9f-06f0fe004efe/members HTTP/1.1
Host: squadsofdeath.com
Accept: application/json
Cache-Control: no-cache

Example reponse:

HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json
Date: Sun, 08 Jan 2017 19:37:59 GMT
Server: nginx
Transfer-Encoding: chunked
Vary: Accept-Encoding

[
    {
        "playerId": "03819625-410a-11e4-adf8-0649b8004f06",
        "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe",
        "name": "Bibi Koy Kenobi",
        "isOwner": 0,
        "isOfficer": 0,
        "joinDate": "2016-11-17 07:53:47",
        "troopsDonated": 838,
        "troopsReceived": 628,
        "hqLevel": 9,
        "reputationInvested": 153,
        "xp": 2487,
        "score": 1490,
        "attacksWon": 1271,
        "defensesWon": 228,
        "lastLoginTime": "2017-01-08 14:02:11",
        "lastUpdated": "2017-01-08 14:02:18",
        "faction": "empire",
        "planet": "Dandoran"
    },
    {
        "playerId": "6a63d9d3-48e4-11e5-8506-063d28004eb7",
        "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe",
        "name": "Romulus Espina",
        "isOwner": 0,
        "isOfficer": 0,
        "joinDate": "2016-12-20 00:40:12",
        "troopsDonated": 611,
        "troopsReceived": 690,
        "hqLevel": 9,
        "reputationInvested": 50,
        "xp": 2434,
        "score": 14836,
        "attacksWon": 2086,
        "defensesWon": 200,
        "lastLoginTime": "2017-01-08 05:18:58",
        "lastUpdated": "2017-01-08 05:21:41",
        "faction": "empire",
        "planet": "Tatooine"
    },
    {
        "playerId": "d7a4bea5-4d2e-11e4-8961-060dc0004f6f",
        "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe",
        "name": "Sgt Mclusky",
        "isOwner": 0,
        "isOfficer": 1,
        "joinDate": "2015-02-22 17:52:02",
        "troopsDonated": 4305,
        "troopsReceived": 3413,
        "hqLevel": 9,
        "reputationInvested": 640,
        "xp": 2416,
        "score": 5024,
        "attacksWon": 662,
        "defensesWon": 429,
        "lastLoginTime": "2017-01-07 06:50:32",
        "lastUpdated": "2017-01-07 23:41:42",
        "faction": "empire",
        "planet": "Tatooine"
    },
    {
        "playerId": "d0e636f5-2adb-11e4-9545-06896e004ed2",
        "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe",
        "name": "OkieTanker",
        "isOwner": 0,
        "isOfficer": 0,
        "joinDate": "2016-12-20 00:35:06",
        "troopsDonated": 51,
        "troopsReceived": 60,
        "hqLevel": 10,
        "reputationInvested": 6,
        "xp": 2376,
        "score": 6306,
        "attacksWon": 1996,
        "defensesWon": 300,
        "lastLoginTime": "2017-01-08 04:41:42",
        "lastUpdated": "2017-01-08 05:40:53",
        "faction": "empire",
        "planet": "Tatooine"
    },
    {
        "playerId": "49cc0114-cfc9-11e4-aafb-064e54004ec8",
        "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe",
        "name": "Insomniac",
        "isOwner": 1,
        "isOfficer": 1,
        "joinDate": "2015-03-24 19:13:36",
        "troopsDonated": 7094,
        "troopsReceived": 3282,
        "hqLevel": 9,
        "reputationInvested": 850,
        "xp": 2345,
        "score": 5892,
        "attacksWon": 595,
        "defensesWon": 364,
        "lastLoginTime": "2017-01-08 10:30:14",
        "lastUpdated": "2017-01-08 10:30:18",
        "faction": "empire",
        "planet": "Yavin 4"
    },
 ...
]
InsomniacEM commented 7 years ago

Oh it returns last updated too? Perfect. Time to dust off my coding skills!

Get Outlook for iOShttps://aka.ms/o0ukef

On Sun, Jan 8, 2017 at 2:45 PM -0500, "Kender2" notifications@github.com<mailto:notifications@github.com> wrote:

Yes, make sure your client sends an Accept: application/json header and the normal requests will return JSON. Example request:

GET /squad/aea3f09d-b002-11e4-ae9f-06f0fe004efe/members HTTP/1.1 Host: squadsofdeath.com Accept: application/json Cache-Control: no-cache

Example reponse:

HTTP/1.1 200 OK Cache-Control: no-cache Connection: keep-alive Content-Encoding: gzip Content-Type: application/json Date: Sun, 08 Jan 2017 19:37:59 GMT Server: nginx Transfer-Encoding: chunked Vary: Accept-Encoding

[ { "playerId": "03819625-410a-11e4-adf8-0649b8004f06", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Bibi Koy Kenobi", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-11-17 07:53:47", "troopsDonated": 838, "troopsReceived": 628, "hqLevel": 9, "reputationInvested": 153, "xp": 2487, "score": 1490, "attacksWon": 1271, "defensesWon": 228, "lastLoginTime": "2017-01-08 14:02:11", "lastUpdated": "2017-01-08 14:02:18", "faction": "empire", "planet": "Dandoran" }, { "playerId": "6a63d9d3-48e4-11e5-8506-063d28004eb7", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Romulus Espina", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-12-20 00:40:12", "troopsDonated": 611, "troopsReceived": 690, "hqLevel": 9, "reputationInvested": 50, "xp": 2434, "score": 14836, "attacksWon": 2086, "defensesWon": 200, "lastLoginTime": "2017-01-08 05:18:58", "lastUpdated": "2017-01-08 05:21:41", "faction": "empire", "planet": "Tatooine" }, { "playerId": "d7a4bea5-4d2e-11e4-8961-060dc0004f6f", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Sgt Mclusky", "isOwner": 0, "isOfficer": 1, "joinDate": "2015-02-22 17:52:02", "troopsDonated": 4305, "troopsReceived": 3413, "hqLevel": 9, "reputationInvested": 640, "xp": 2416, "score": 5024, "attacksWon": 662, "defensesWon": 429, "lastLoginTime": "2017-01-07 06:50:32", "lastUpdated": "2017-01-07 23:41:42", "faction": "empire", "planet": "Tatooine" }, { "playerId": "d0e636f5-2adb-11e4-9545-06896e004ed2", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "OkieTanker", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-12-20 00:35:06", "troopsDonated": 51, "troopsReceived": 60, "hqLevel": 10, "reputationInvested": 6, "xp": 2376, "score": 6306, "attacksWon": 1996, "defensesWon": 300, "lastLoginTime": "2017-01-08 04:41:42", "lastUpdated": "2017-01-08 05:40:53", "faction": "empire", "planet": "Tatooine" }, { "playerId": "49cc0114-cfc9-11e4-aafb-064e54004ec8", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Insomniac", "isOwner": 1, "isOfficer": 1, "joinDate": "2015-03-24 19:13:36", "troopsDonated": 7094, "troopsReceived": 3282, "hqLevel": 9, "reputationInvested": 850, "xp": 2345, "score": 5892, "attacksWon": 595, "defensesWon": 364, "lastLoginTime": "2017-01-08 10:30:14", "lastUpdated": "2017-01-08 10:30:18", "faction": "empire", "planet": "Yavin 4" }, { "playerId": "34541dc2-74c3-11e4-83a3-063b1c004ebe", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "buddy lee", "isOwner": 0, "isOfficer": 1, "joinDate": "2015-03-22 23:39:59", "troopsDonated": 3366, "troopsReceived": 4011, "hqLevel": 9, "reputationInvested": 769, "xp": 2276, "score": 6064, "attacksWon": 609, "defensesWon": 441, "lastLoginTime": "2017-01-08 14:33:07", "lastUpdated": "2017-01-08 14:33:23", "faction": "empire", "planet": "Tatooine" }, { "playerId": "e1de0673-a85c-11e5-ae8b-06f0fe004efe", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Chance", "isOwner": 0, "isOfficer": 0, "joinDate": "2017-01-07 21:28:44", "troopsDonated": 15, "troopsReceived": 24, "hqLevel": 9, "reputationInvested": 1, "xp": 2225, "score": 1428, "attacksWon": 530, "defensesWon": 132, "lastLoginTime": "2017-01-08 06:52:14", "lastUpdated": "2017-01-08 07:29:51", "faction": "empire", "planet": "Tatooine" }, { "playerId": "c7e5a4ea-43bb-11e6-9046-06b9b0004f03", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Master", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-07-09 17:23:24", "troopsDonated": 1241, "troopsReceived": 3195, "hqLevel": 10, "reputationInvested": 517, "xp": 2184, "score": 1491, "attacksWon": 679, "defensesWon": 78, "lastLoginTime": "2017-01-08 14:01:48", "lastUpdated": "2017-01-08 14:09:25", "faction": "empire", "planet": "Tatooine" }, { "playerId": "4bda83a0-123f-11e6-93fc-061672004ec9", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "AA3", "isOwner": 0, "isOfficer": 1, "joinDate": "2016-05-14 18:43:25", "troopsDonated": 2881, "troopsReceived": 3742, "hqLevel": 8, "reputationInvested": 884, "xp": 1984, "score": 5712, "attacksWon": 1371, "defensesWon": 113, "lastLoginTime": "2017-01-08 14:50:37", "lastUpdated": "2017-01-08 14:50:42", "faction": "empire", "planet": "Tatooine" }, { "playerId": "80c295a6-253c-11e6-bd51-067448004f68", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "JagLightstriker", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-11-18 20:21:31", "troopsDonated": 258, "troopsReceived": 101, "hqLevel": 8, "reputationInvested": 147, "xp": 1849, "score": 2771, "attacksWon": 768, "defensesWon": 27, "lastLoginTime": "2017-01-07 18:51:32", "lastUpdated": "2017-01-07 18:51:40", "faction": "empire", "planet": "Tatooine" }, { "playerId": "2c49fe6e-2b8c-11e4-8b0a-066b7c004f72", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Vulmenis", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-07-28 10:47:37", "troopsDonated": 120, "troopsReceived": 127, "hqLevel": 8, "reputationInvested": 0, "xp": 1815, "score": 467, "attacksWon": 78, "defensesWon": 54, "lastLoginTime": "2017-01-08 12:00:56", "lastUpdated": "2017-01-08 12:39:06", "faction": "empire", "planet": "Tatooine" }, { "playerId": "bae1770b-9c90-11e5-9ff8-06cad0004ecc", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Darth maul", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-09-05 19:18:14", "troopsDonated": 173, "troopsReceived": 574, "hqLevel": 9, "reputationInvested": 16, "xp": 1611, "score": 1535, "attacksWon": 971, "defensesWon": 147, "lastLoginTime": "2017-01-08 08:20:33", "lastUpdated": "2017-01-08 08:20:48", "faction": "empire", "planet": "Tatooine" }, { "playerId": "aa4114d1-70a7-11e6-b9b8-069e76004efa", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Super17", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-09-22 23:30:12", "troopsDonated": 249, "troopsReceived": 1162, "hqLevel": 7, "reputationInvested": 0, "xp": 1580, "score": 1276, "attacksWon": 476, "defensesWon": 66, "lastLoginTime": "2017-01-08 08:34:32", "lastUpdated": "2017-01-08 11:52:57", "faction": "empire", "planet": "Dandoran" }, { "playerId": "9f526da4-a086-11e6-af22-06d88e004eb9", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Yorkist", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-11-18 22:03:18", "troopsDonated": 936, "troopsReceived": 1009, "hqLevel": 7, "reputationInvested": 112, "xp": 1367, "score": 2666, "attacksWon": 477, "defensesWon": 27, "lastLoginTime": "2017-01-08 14:20:00", "lastUpdated": "2017-01-08 14:20:07", "faction": "empire", "planet": "Tatooine" }, { "playerId": "47e7cd20-a217-11e6-b14f-06d6be004f86", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "slubo", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-11-20 01:31:31", "troopsDonated": 907, "troopsReceived": 531, "hqLevel": 6, "reputationInvested": 93, "xp": 1335, "score": 2705, "attacksWon": 452, "defensesWon": 18, "lastLoginTime": "2017-01-08 04:22:44", "lastUpdated": "2017-01-08 09:22:26", "faction": "empire", "planet": "Tatooine" }, { "playerId": "3145fd3f-9edd-11e6-8ac1-06eab0004eee", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "DarthJaeger", "isOwner": 0, "isOfficer": 0, "joinDate": "2016-11-19 02:47:21", "troopsDonated": 95, "troopsReceived": 371, "hqLevel": 6, "reputationInvested": 72, "xp": 1286, "score": 1399, "attacksWon": 223, "defensesWon": 15, "lastLoginTime": "2017-01-07 00:59:21", "lastUpdated": "2017-01-07 00:59:32", "faction": "empire", "planet": "Tatooine" }, { "playerId": "8f5a31dd-a6cc-11e5-badd-061054004f58", "squadId": "aea3f09d-b002-11e4-ae9f-06f0fe004efe", "name": "Außenposten 3", "isOwner": 0, "isOfficer": 0, "joinDate": "2017-01-07 21:38:46", "troopsDonated": 0, "troopsReceived": 0, "hqLevel": 6, "reputationInvested": 0, "xp": 1197, "score": 1302, "attacksWon": 337, "defensesWon": 22, "lastLoginTime": "2017-01-07 21:27:40", "lastUpdated": "2017-01-07 21:38:49", "faction": "empire", "planet": "Tatooine" } ]

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Kender2/swc-squadranking/issues/10#issuecomment-271174083, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWERbXoAXtnQI77C7zgu9-mRyQIIKT57ks5rQTzwgaJpZM4KkIKa.