pubgsh / api Goto Github PK
View Code? Open in Web Editor NEWThe API component of https://pubg.sh
The API component of https://pubg.sh
There is an issue with matches not getting displayed when there is more than 4 players in Custom games. In the Match.js on line 15 the max squad size is hard coded to 4. Then on the UI, there is a check in src/routes/Player/index.js const forTeamSize = teamSize => player.matches.filter(m => m.teamSize === teamSize)
on line 78. I believe this is the cause for the match not being displayed correctly.
apazzolini-
No issue, just a feature request. If you could add a way to "Create a Gif" from a selected part of the replay, this would be very useful in sharing info with other teammates, especially on mobile. Good job on the app, keep it up!
Unique constraint for name on players table is incorrect. Need to include either shard or just pc/xbox flag to allow the same handle to exist on both platforms with different account ids.
Hey again @apazzolini, I'd like to get the repo into a state where I can work on improvements to the client. But at the moment all the tests seem to be failing and I don't quite understand why.
Note that the majority of tests will require an available PostgreSQL database. Each test will run in its own self-contained DB seeded with test/seed.sql and the DB will be dropped after the test.
Currently, most of the tests are failing when running yarn jest
even though the above paragraph indicates that the database will be pre-seeded and/or the static fixtures will be used instead. But I get the following:
❯ yarn test ✔ 2307 11:27:56
yarn run v1.22.4
$ jest
FAIL src/lib/TemporarySet.test.js
● TemporarySet › clears item after the timeout
expect(received).toEqual(expected)
Expected value to equal:
[]
Received:
[2]
Difference:
- Expected
+ Received
- Array []
+ Array [
+ 2,
+ ]
27 | setTimeout(() => expect([...s]).toEqual([1, 2]), 70)
28 | setTimeout(() => expect([...s]).toEqual([2]), 110)
> 29 | setTimeout(() => expect([...s]).toEqual([]), 210)
30 |
31 | await Promise.delay(250)
32 | })
at Timeout.setTimeout (src/lib/TemporarySet.test.js:29:41)
FAIL src/resolvers/all.test.js
● model :: Player and Match › retrieves new players from the PUBG api
expect(value).toMatchSnapshot()
Received value does not match stored snapshot 1.
- Snapshot
+ Received
Object {
"result": Object {
"data": Object {
- "player": Object {
- "id": "account.a36bed11ed214557b0ddef9ef1a56d07",
- "matches": Array [
- Object {
- "id": "d9719859-5d8d-4a39-ab02-de41758b5632",
- },
- Object {
- "id": "9d6f836b-a7f1-43d6-ac82-1d2c149952d9",
- },
- Object {
- "id": "b6a4e260-6bf0-4395-9cb4-846f8e3b92e3",
- },
- Object {
- "id": "742382c5-6139-4879-a3e6-65677baaae69",
- },
- Object {
- "id": "97c15fbe-1b34-41be-b700-1e340af63d94",
- },
- Object {
- "id": "bc49df15-f847-4874-87e7-392d1a2030f1",
- },
- Object {
- "id": "f03394d9-e9df-46df-974b-730ded3a3531",
- },
- Object {
- "id": "18ea21fa-40d3-4435-ac2e-71dab5c506ba",
- },
- Object {
- "id": "96c554c0-7e73-4139-acbf-b6a80237eaf5",
- },
- Object {
- "id": "d0716a8a-ad4d-45bc-a410-ff5b0801b5d5",
- },
- Object {
- "id": "7a18ac6d-6baa-467b-87c5-e9b555ac9c82",
- },
- Object {
- "id": "cd2be27f-ee97-47fe-80b0-d35cfbbad106",
- },
- Object {
- "id": "c79f027b-49cd-49dc-b7a3-a85b140a459b",
- },
- Object {
- "id": "b9975379-ba62-459f-83a9-bbca31a3c24f",
- },
- Object {
- "id": "c8a79952-cd63-45ed-b2fd-04deafa44797",
- },
- Object {
- "id": "e2b4aa8d-8846-4720-987c-b1a480e1a377",
- },
- Object {
- "id": "bc9f481f-ced4-4598-9df5-93e747d3685b",
- },
- Object {
- "id": "0837df06-4703-4ff0-a10e-e328b526451b",
- },
- Object {
- "id": "6f6797ae-190d-43a9-8ae3-ad7fe50f5fa9",
- },
- Object {
- "id": "cf7406f8-aaad-4d0b-ad86-8475f9328f82",
- },
- Object {
- "id": "51629acf-393e-49b0-9501-7e3ca3436f83",
- },
- Object {
- "id": "7cc05145-3525-4ff0-8307-00d0de88505e",
- },
- Object {
- "id": "001ea16c-4413-4375-bd87-ca5d4ddb41a7",
- },
- Object {
- "id": "cb9eec54-9fb7-4211-a8f4-e8426e44cd5a",
- },
- Object {
- "id": "9e4dfcfd-686e-437c-916a-fedb2513d1ca",
- },
- Object {
- "id": "ea60f7b9-0bd0-4b76-9fdc-967b8fd0e80f",
- },
- Object {
- "id": "b0bf93d3-033b-4f9a-8be8-18e49ae7e63e",
- },
- Object {
- "id": "fca1b66c-a7a4-44d1-882f-6dbe70fd79fe",
- },
- Object {
- "id": "bd76dc47-bd93-4d20-a539-82f5505205eb",
- },
- Object {
- "id": "989f0d97-8428-4b2b-8973-026891f4e4db",
- },
- Object {
- "id": "ee6d6b0e-e8aa-4a8b-9539-ad45517b5518",
- },
- Object {
- "id": "18cb9ca1-7b7f-4acf-8b5b-9eee4c15876e",
- },
- Object {
- "id": "17dfc0b7-fd2b-40f0-b38f-0fc2a6bb26ce",
- },
- Object {
- "id": "c6631faa-6cac-4c4d-a88e-2fd17eb1f5bd",
- },
- Object {
- "id": "0eea2abb-51c1-491a-baa6-407f4f0a2e86",
- },
- Object {
- "id": "3f3c09fb-6415-472b-a543-43479239e73a",
- },
- Object {
- "id": "464ebf95-7b54-4bec-98f5-bddf3ffb567d",
- },
- Object {
- "id": "26880e2d-ed3d-48f8-9022-73d24ec89f24",
- },
- Object {
- "id": "64741cf3-b35c-420a-8e45-8603d64060fd",
- },
- Object {
- "id": "cdd12f3d-b639-4d9f-9ec4-1196f75f981e",
- },
- ],
- "name": "BreaK",
- },
+ "player": null,
},
},
"statusCode": 200,
}
32 | }
33 | }
> 34 | `)).toMatchSnapshot()
35 |
36 | expect(Player.createOrUpdate).toHaveBeenCalled()
37 | })
at Object.test (src/resolvers/all.test.js:34:13)
● model :: Player and Match › re-requesting a player retrieves it from the db
expect(value).toMatchSnapshot()
Received value does not match stored snapshot 1.
- Snapshot
+ Received
Object {
"result": Object {
"data": Object {
- "player": Object {
- "id": "account.a36bed11ed214557b0ddef9ef1a56d07",
- "matches": Array [
- Object {
- "id": "d9719859-5d8d-4a39-ab02-de41758b5632",
- },
- Object {
- "id": "9d6f836b-a7f1-43d6-ac82-1d2c149952d9",
- },
- Object {
- "id": "b6a4e260-6bf0-4395-9cb4-846f8e3b92e3",
- },
- Object {
- "id": "742382c5-6139-4879-a3e6-65677baaae69",
- },
- Object {
- "id": "97c15fbe-1b34-41be-b700-1e340af63d94",
- },
- Object {
- "id": "bc49df15-f847-4874-87e7-392d1a2030f1",
- },
- Object {
- "id": "f03394d9-e9df-46df-974b-730ded3a3531",
- },
- Object {
- "id": "18ea21fa-40d3-4435-ac2e-71dab5c506ba",
- },
- Object {
- "id": "96c554c0-7e73-4139-acbf-b6a80237eaf5",
- },
- Object {
- "id": "d0716a8a-ad4d-45bc-a410-ff5b0801b5d5",
- },
- Object {
- "id": "7a18ac6d-6baa-467b-87c5-e9b555ac9c82",
- },
- Object {
- "id": "cd2be27f-ee97-47fe-80b0-d35cfbbad106",
- },
- Object {
- "id": "c79f027b-49cd-49dc-b7a3-a85b140a459b",
- },
- Object {
- "id": "b9975379-ba62-459f-83a9-bbca31a3c24f",
- },
- Object {
- "id": "c8a79952-cd63-45ed-b2fd-04deafa44797",
- },
- Object {
- "id": "e2b4aa8d-8846-4720-987c-b1a480e1a377",
- },
- Object {
- "id": "bc9f481f-ced4-4598-9df5-93e747d3685b",
- },
- Object {
- "id": "0837df06-4703-4ff0-a10e-e328b526451b",
- },
- Object {
- "id": "6f6797ae-190d-43a9-8ae3-ad7fe50f5fa9",
- },
- Object {
- "id": "cf7406f8-aaad-4d0b-ad86-8475f9328f82",
- },
- Object {
- "id": "51629acf-393e-49b0-9501-7e3ca3436f83",
- },
- Object {
- "id": "7cc05145-3525-4ff0-8307-00d0de88505e",
- },
- Object {
- "id": "001ea16c-4413-4375-bd87-ca5d4ddb41a7",
- },
- Object {
- "id": "cb9eec54-9fb7-4211-a8f4-e8426e44cd5a",
- },
- Object {
- "id": "9e4dfcfd-686e-437c-916a-fedb2513d1ca",
- },
- Object {
- "id": "ea60f7b9-0bd0-4b76-9fdc-967b8fd0e80f",
- },
- Object {
- "id": "b0bf93d3-033b-4f9a-8be8-18e49ae7e63e",
- },
- Object {
- "id": "fca1b66c-a7a4-44d1-882f-6dbe70fd79fe",
- },
- Object {
- "id": "bd76dc47-bd93-4d20-a539-82f5505205eb",
- },
- Object {
- "id": "989f0d97-8428-4b2b-8973-026891f4e4db",
- },
- Object {
- "id": "ee6d6b0e-e8aa-4a8b-9539-ad45517b5518",
- },
- Object {
- "id": "18cb9ca1-7b7f-4acf-8b5b-9eee4c15876e",
- },
- Object {
- "id": "17dfc0b7-fd2b-40f0-b38f-0fc2a6bb26ce",
- },
- Object {
- "id": "c6631faa-6cac-4c4d-a88e-2fd17eb1f5bd",
- },
- Object {
- "id": "0eea2abb-51c1-491a-baa6-407f4f0a2e86",
- },
- Object {
- "id": "3f3c09fb-6415-472b-a543-43479239e73a",
- },
- Object {
- "id": "464ebf95-7b54-4bec-98f5-bddf3ffb567d",
- },
- Object {
- "id": "26880e2d-ed3d-48f8-9022-73d24ec89f24",
- },
- Object {
- "id": "64741cf3-b35c-420a-8e45-8603d64060fd",
- },
- Object {
- "id": "cdd12f3d-b639-4d9f-9ec4-1196f75f981e",
- },
- ],
- "name": "BreaK",
- },
+ "player": null,
},
},
"statusCode": 200,
}
48 | }
49 | }
> 50 | `)).toMatchSnapshot()
51 | expect(Player.createOrUpdate).not.toHaveBeenCalled()
52 | })
53 |
at Object.test (src/resolvers/all.test.js:50:13)
● model :: Player and Match › re-requesting a player refreshes matches if enough time has passed
expect(jest.fn()).toHaveBeenCalled()
Expected mock function to have been called.
73 | }
74 | `)
> 75 | expect(Player.createOrUpdate).toHaveBeenCalled()
76 | })
77 |
78 | test('re-requesting a player refreshes matches earlier if has lower fetch interval', async () => {
at Object.test (src/resolvers/all.test.js:75:39)
● model :: Player and Match › re-requesting a player refreshes matches earlier if has lower fetch interval
expect(jest.fn()).toHaveBeenCalled()
Expected mock function to have been called.
102 | }
103 | `)
> 104 | expect(Player.createOrUpdate).toHaveBeenCalled()
105 | })
106 |
107 | test('retrieves match data from the PUBG api', async () => {
at Object.test (src/resolvers/all.test.js:104:39)
● model :: Player and Match › retrieves match data from the PUBG api
expect(received).toMatchObject(expected)
Expected value to match object:
{"result": {"data": {"match": {"id": null, "telemetryUrl": Any<String>}}}}
Received:
{"result": {"errors": [{"locations": [{"column": 29, "line": 15}], "message": "Cannot query field \"DBNOs\" on type \"MatchStats\"."}]}, "statusCode": 400}
Difference:
- Expected
+ Received
Object {
"result": Object {
- "data": Object {
- "match": Object {
- "id": null,
- "telemetryUrl": Any<String>,
+ "errors": Array [
+ Object {
+ "locations": Array [
+ Object {
+ "column": 29,
+ "line": 15,
},
+ ],
+ "message": "Cannot query field \"DBNOs\" on type \"MatchStats\".",
},
+ ],
},
}
133 | }
134 | }
> 135 | `)).toMatchObject({
136 | result: {
137 | data: {
138 | match: {
at Object.test (src/resolvers/all.test.js:135:13)
› 2 snapshot tests failed.
Snapshot Summary
› 2 snapshot tests failed in 1 test suite. Inspect your code changes or run `yarn test -u` to update them.
Test Suites: 2 failed, 2 total
Tests: 6 failed, 2 passed, 8 total
Snapshots: 2 failed, 2 total
Time: 12.433s
Ran all test suites.
error Command failed with exit code 1.
I've managed to replicate the test environment in Github Actions here: https://github.com/dalanmiller/api/blob/master/.github/workflows/nodejs.yml
I know you mentioned no longer being interested in maintaining the project as you no longer play PUBG, so I think if you can get me to a good spot in terms of maintenance, I'd be happy to try and start taking this off your hands!
Telemetry from PUBG's API is only available for two weeks, so it's pointless to store this data until we have a method in place to store the telemetry data ourselves.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.