Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PVP Stats Tracking #151

Closed
wants to merge 20 commits into from
Closed

PVP Stats Tracking #151

wants to merge 20 commits into from

Conversation

123FLO321
Copy link
Contributor

@123FLO321 123FLO321 commented Jun 1, 2020

Description

  • Only works with RDM (since others don't send PVP stats) and requires RDM PR 120
  • Adds options to track based on Great and Ultra League PVP stats rank.
    • !track snorlax great1 for top 1 great league snorlax
    • !track everything great1 greatcp1450 for top 1 great league pokemon maxing out at or above 1450CP
    • !track snorlax ultra100 for top 100 ultra league snorlax
    • !track everything ultra1 ultracp2400 for top 1 great league pokemon maxing out at or above 2400CP
    • do not combine greatX and ultraX in same tracking command because that would require BOTH to be true
  • Adds new bestGreatLeagueRank and bestUltraLeagueRank DTS
  • No longer perform a git clone in the Dockerfile

TODO: - Add examples to help command

Motivation and Context

Utilize RDMs PVP Stats being via WebHook (RealDeviceMap/RealDeviceMap#120)

How Has This Been Tested?

Tested locally but needs further testing.

Example DTS

image

Great League (formatted for readability, remove line brakes)

{{#if pvp_rankings_great_league}}**Great League:**\n
{{#each pvp_rankings_great_league}}
 - {{pokemonName this.pokemon}} #{{this.rank}} @{{this.cp}}CP (Lvl. {{this.level}})\n
{{/each}}
{{/if}}

Ultra League (formatted for readability, remove line brakes)

{{#if pvp_rankings_ultra_league}}**Ultra League:**\n
{{#each pvp_rankings_ultra_league}}
- {{pokemonName this.pokemon}} #{{this.rank}} @{{this.cp}}CP (Lvl. {{this.level}})\n
{{/each}}
{{/if}}

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@kamieniarz
Copy link
Contributor

I wanted to try that that for the first time so I switched to RDM PR120 and poracle PR151.
Unfortunately poracle works slower - emoji reactions are slow, !area list is also slow af . But the main issue is with !tracked, cause it causes an error:

{"level":"error","message":"!tracked command unhappy: Cannot read property 'name' of undefined","stack":"TypeError: Cannot read property 'name' of undefined\n at /home/(...)/poracle/src/lib/discord/commando/commands/tracked.js:55:28\n at Array.forEach (<anonymous>)\n at Object.exports.run (/home/(...)/poracle/src/lib/discord/commando/commands/tracked.js:53:12)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (internal/process/task_queues.js:97:5)","timestamp":"2020-07-11T19:28:26.035Z"}

So actually I'm not able to fully try that thing out :(

Interesting thing is that I used only one pr-related command: !track marill great5. Obviously !tracked didn't work but after I switched to develop branch and checked tracked I fugered out at the bottom of mons list I have this:

**Marill** forma: iv: 0%-100% cp: 0-9000 level: 0-40 statystyki: 0/0/0 - 15/15/15, płeć: (it's translated to polish but should be clear enough to figure out that command from above worked like !track marill)

@kamieniarz
Copy link
Contributor

I switched to this PR again from on my existing Poracle clone with existing databse and at start I have this error:

(node:17961) UnhandledPromiseRejectionWarning: Error: alter table `monsters` add `great_league_ranking` int not null default '4096', add `great_league_ranking_min_cp` int not null default '0', add `ultra_league_ranking` int not null default '4096', add `ultra_league_ranking_min_cp` int not null default '0' - Duplicate column name 'great_league_ranking'
    at Packet.asError (/home/user/poracle/node_modules/mysql2/lib/packets/packet.js:712:17)
    at Query.execute (/home/user/poracle/node_modules/mysql2/lib/commands/command.js:28:26)
    at Connection.handlePacket (/home/user/poracle/node_modules/mysql2/lib/connection.js:417:32)
    at PacketParser.onPacket (/home/user/poracle/node_modules/mysql2/lib/connection.js:75:12)
    at PacketParser.executeStart (/home/user/poracle/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/home/user/poracle/node_modules/mysql2/lib/connection.js:82:25)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:273:9)
    at Socket.Readable.push (_stream_readable.js:214:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:17961) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:17961) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I also used one command !track everything great1 greatcp1450 and when I try to check !tracked I receive location and area but no tracked list due to this error:

error: !tracked command unhappy: Cannot read property 'name' of undefined {"stack":"TypeError: Cannot read property 'name' of undefined\n    at /home/user/poracle/src/lib/discord/commando/commands/tracked.js:55:28\n    at Array.forEach (<anonymous>)\n    at Object.exports.run (/home/user/poracle/src/lib/discord/commando/commands/tracked.js:53:12)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)"}

That's actually the same error I had before the changes u made. Anyway I haven't noticed any other issues. I don't rly know if command I used works cause I couldn't check tracked list and I haven't received any GBL related notification yet, but my hundo notifications still work

@PoGoJoshS
Copy link
Contributor

PoGoJoshS commented Aug 3, 2020

Tracking commands and DTS works as expected. Thanks Flo.

@Qualimiox Qualimiox mentioned this pull request Sep 4, 2020
3 tasks
@mag3sticl
Copy link
Contributor

I can confirm this works without issue. Monitored CPU usage over an hour of using !track everything great100, !track everything ultra100, !track everything and CPU on queries where about 1/2%.

@kamieniarz
Copy link
Contributor

I tried this PR again and still have issues. Poracle don't accept any command and it throws errors all the time:

�[31merror�[39m: Can't seem to handle monster: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call? {"name":"KnexTimeoutError","sql":"\n\t\tselect humans.id, humans.name, humans.type, humans.latitude, humans.longitude, monsters.template, monsters.distance, monsters.clean, monsters.ping from monsters\n\t\tjoin humans on humans.id = monsters.id\n\t\twhere humans.enabled = true and\n\t\tpokemon_id=215 and\n\t\tmin_iv<=48.89 and\n\t\tmax_iv>=48.89 and\n\t\tmin_cp<=308 and\n\t\tmax_cp>=308 and\n\t\t(gender = 1 or gender = 0) and\n\t\t(form = 797 or form = 0) and\n\t\tmin_level<=6 and\n\t\tmax_level>=6 and\n\t\tatk<=4 and\n\t\tdef<=10 and\n\t\tsta<=8 and\n\t\tmax_atk>=4 and\n\t\tmax_def>=10 and\n\t\tmax_sta>=8 and\n\t\tmin_weight<=43.5 * 1000 and\n\t\tmax_weight>=43.5 * 1000 and\n\t\tgreat_league_ranking>=495 and\n\t\tgreat_league_ranking_min_cp<=1494 and \n\t\tultra_league_ranking>=857 and \n\t\tultra_league_ranking_min_cp<=2486\n\t\t\n\t\t\tand\n\t\t\t(round (6371000 * acos( cos( radians(52.42097247509197) )\n\t\t\t  * cos( radians( humans.latitude ) )\n\t\t\t  * cos( radians( humans.longitude ) - radians(16.936358785844543) )\n\t\t\t  + sin( radians(52.42097247509197) )\n\t\t\t  * sin( radians( humans.latitude ) ) ) < monsters.distance and monsters.distance != 0) or\n\t\t\t   monsters.distance = 0 and (humans.area like '%\"poznan\"%' or humans.area like '%\"poznan\"%' or humans.area like '%\"poz-winogrady\"%' or humans.area like '%\"polska\"%' ))\n\t\t\t   group by humans.id, humans.name, humans.type, humans.latitude, humans.longitude, monsters.template, monsters.distance, monsters.clean, monsters.ping\n\t\t\t","stack":"KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?\n    at Client_MySQL2.acquireConnection (/home/(...)/poracle/node_modules/knex/lib/client.js:347:26)"}

@mag3sticl
Copy link
Contributor

Must be something wrong with your Poracle build. Works flawlessly with develop and flos custom tile server. No additional server load that I can see either.

@RagingRectangle
Copy link
Contributor

PR seems to be working great so far. Wondering about how tracking evolutions works though. If I want to track the top 10 greats for Garchomp, is that possible? From the tests I've tried running it looks like doing "!track garchomp great10" won't work because Garchomps don't spawn in the wild so the filter wont be triggered. It also looks like doing "!track gible great10" will only respond if the Gible is in the top 10, not if any of the evolutions are in the top 10, is this correct?

@t00fan
Copy link
Contributor

t00fan commented Sep 30, 2020

So did some testing using postman, and it looks like tracking evolutions does not work directly with the pvp pr. If you track !track venomoth great5 , any venonat spawns that are great5 for venomoth will not trigger that notification

so you have to do something like !track venonat venomoth great5 greatcp1450 and hope that venonat does not reach that CP.

Becomes a problem for Eevee.. because !track eevee vaporeon great1 greatcp1450 will alert you if any of the eevolutions are #1. So currently it is not usable to track specific evolutions.

@andi2022
Copy link

andi2022 commented Oct 2, 2020

Works great. Please merge this to develop.

@dondi99
Copy link

dondi99 commented Oct 4, 2020

PR works great for wild non-evolution PVP viable Pokemon (eg Skarmory, Mantine, Snorlax, Lapras) but that is only part of what is needed for PVP. There should be a robust, consistent way to track the wild pre-evolution of good PVP Pokemon (eg Swablu/Altaria, Marill/Azumarill, Mudkip/Swampert) for this PR to truly be useful. For now I suggest NOT merging and instead leaving as a PR until a good pre-evolution method is found.

@dkmur
Copy link

dkmur commented Oct 5, 2020

so it works great, no issues, apparently room for improvement so you suggest to NOT merge it as you are creating a PR for the improvement? Or you know how is?

Else I would say merge it, cause I think it is a major step forward and is not causing any issues, PRs can be accepted lateron on develop branch.

@t00fan
Copy link
Contributor

t00fan commented Oct 18, 2020

I think this is great to merge as is with the limitation as state that you can't track straight evolutions. Workaround is to track the unevolved mon as well. It helps more than it hurts right now!

@t00fan
Copy link
Contributor

t00fan commented Nov 10, 2020

Any chance of this getting this merged into dev?

@bbdoc
Copy link
Contributor

bbdoc commented Nov 27, 2020

Same remark, please merge into develop. This is working fine (once Dockerfile conflict has been resolved).

@PoGoJoshS
Copy link
Contributor

Hi @KartulUdus, could we get this merged into develop please? Been using it since August and it works great.

@PoGoJoshS PoGoJoshS mentioned this pull request Dec 3, 2020
6 tasks
@jfberry
Copy link
Collaborator

jfberry commented Dec 5, 2020

PR was merged (through subsequent rebased PR), thanks!

@jfberry jfberry closed this Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.