aarronc / hutton-helper

data collection tool to aid in better management of the BGS
9 stars 4 forks source link

explocredit.json being requested after most journal events #62

Closed aarronc closed 6 years ago

aarronc commented 6 years ago

it looks as if explocredit.json is being requested after alot of different journal events. it even requests it when I hire and fire a crew member, this may bog down the HH back end with requests with a lot of new people upgrading soon.

Server Output :
[27/Sep/2018:13:42:56 +0100] "GET /explocredit.json/Dongkum%20ThermalPaste HTTP/1.1" 200 19 0.0020
[27/Sep/2018:13:42:56 +0100] "GET /explocredit.json/Dongkum%20ThermalPaste HTTP/1.1" 200 19 0.0017
[27/Sep/2018:13:42:56 +0100] "GET /explocredit.json/Dongkum%20ThermalPaste HTTP/1.1" 200 19 0.0017
[27/Sep/2018:13:43:00 +0100] "GET /explocredit.json/Dongkum%20ThermalPaste HTTP/1.1" 200 19 0.0025
[27/Sep/2018:13:43:03 +0100] "GET /explocredit.json/Dongkum%20ThermalPaste HTTP/1.1" 200 19 0.0024
[27/Sep/2018:13:43:04 +0100] "GET /explocredit.json/Dongkum%20ThermalPaste HTTP/1.1" 200 19 0.0024
[27/Sep/2018:13:43:04 +0100] "GET /explocredit.json/Dongkum%20ThermalPaste HTTP/1.1" 200 19 0.0018
[27/Sep/2018:13:43:04 +0100] "GET /explocredit.json/Dongkum%20ThermalPaste HTTP/1.1" 200 19 0.0018
[27/Sep/2018:13:43:06 +0100] "GET /explocredit.json/Dongkum%20ThermalPaste HTTP/1.1" 200 19 0.0022

Journal Entries:
{ "timestamp":"2018-09-27T12:42:55Z", "event":"SupercruiseExit", "StarSystem":"Epsilon Eridani", "SystemAddress":3657265320658, "Body":"Darkes High", "BodyID":19, "BodyType":"Station" }
{ "timestamp":"2018-09-27T12:42:55Z", "event":"Music", "MusicTrack":"DestinationFromSupercruise" }
{ "timestamp":"2018-09-27T12:42:55Z", "event":"ReceiveText", "From":"Darkes High", "Message":"$STATION_NoFireZone_entered;", "Message_Localised":"No fire zone entered.", "Channel":"npc" }
{ "timestamp":"2018-09-27T12:42:59Z", "event":"Music", "MusicTrack":"NoTrack" }
{ "timestamp":"2018-09-27T12:43:02Z", "event":"DockingRequested", "MarketID":128133624, "StationName":"Darkes High", "StationType":"Orbis" }
{ "timestamp":"2018-09-27T12:43:03Z", "event":"ReceiveText", "From":"Darkes High", "Message":"$DockingChatter_Neutral;", "Message_Localised":"Ensure to observe starport protocol during your visit, pilot.", "Channel":"npc" }
{ "timestamp":"2018-09-27T12:43:03Z", "event":"ReceiveText", "From":"Darkes High", "Message":"$STATION_docking_granted;", "Message_Localised":"Docking request granted.", "Channel":"npc" }
{ "timestamp":"2018-09-27T12:43:03Z", "event":"DockingGranted", "LandingPad":3, "MarketID":128133624, "StationName":"Darkes High", "StationType":"Orbis" }
{ "timestamp":"2018-09-27T12:43:05Z", "event":"Music", "MusicTrack":"DockingComputer" }
sporebat commented 6 years ago
        if self.__reset(cmdr=cmdr) or entry['event'] == 'Scan' or not self.ready:
            self.__check_again()

I don't think it's self.__reset and there's no Scan in the log so self.ready might be stuck by the JSON never parsing. OR maybe I stuffed up xmit with that fix to local.

sporebat commented 6 years ago
                try:
                    return response.json()

No, that's pretty definitive. Only happens on 200, but you're replying with 200.

sporebat commented 6 years ago

I'll give it a poke after breakfast if I decide to stay home.

sporebat commented 6 years ago

@aarronc you'll need to change __check_again_action in exploration.py and tell me what you see in the output when you python EDMarketconnector.py:

    def __check_again_action(self):
        "Get and display exploration credits."

        if self.checking:
            return

        try:
            self.checking = True
            path = '/explocredit.json/{}'.format(self.cmdr)
            json_data = xmit.get(path)
            print '=== A', json_data
            self.credits = float(json_data['ExploCredits'])
            print '=== B', self.credits

            if self.textvariable:
                self.textvariable.set("at least {:,.0f}".format(self.credits))

            self.refresh()

        finally:
            self.checking = False
sporebat commented 6 years ago

I'm getting:

200 GET http://forthemug.com:4567/explocredit.json/sporebat ms=2771
=== A {u'ExploCredits': u'0'}
=== B 0.0

... and then it's self.ready and it stops asking.

sporebat commented 6 years ago

@aarronc if the server is getting slugged, it'd be very handy to have a copy of the JSON returned from /explocredit.json/{} for your alt with a space in its name. (Though, hang on: if Dave from the log in #67 doesn't have a space, maybe there's something else causing the JSON to be mangled.)

If your server side framework lets you, please try parsing the JSON you're about to return, check that it has an ExploCredits that's a number, and crash out with a 500 if not. I do this kind of structural check on all my professional work. It genuinely helps.

Meanwhile, I'll work on a client side mitigation for your explocredit.json getting slugged because it's consistently not returning what these few commanders' copies of the Helper expect.

sporebat commented 6 years ago

Root cause fixed at the server end. Mitigation still in place at the client end.