dtcarls / fantasy_football_chat_bot

GroupMe Discord and Slack Chatbot for ESPN Fantasy Football
GNU General Public License v3.0
296 stars 234 forks source link

Tuesday Morning (Post Update) showing 00 for all scores and trophies. #55

Closed Carbja23 closed 5 years ago

Carbja23 commented 5 years ago

Yes -- Post update from this week the bot is displaying 00 for all scores and trophies.

TSPARR commented 5 years ago

It looks like this is happening because of the switch to league.box_scores pulling the current week's scores. Since the week has ended, they've all reset to 0. Unfortunately, box_scores doesn't easily accept a negative number.


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'box_scores'```
ZachMyers3 commented 5 years ago

It looks like the API assumes Tuesday morning as part of the next week.

get_scoreboard_short will need to take a parameter for the week, perhaps defaulting to 0.

# default the week to current week, possible to override
def get_scoreboard_short(league, week=0):
    #Gets current week's scoreboard
    box_scores = league.box_scores(week)
    score = ['%s %.2f - %.2f %s' % (i.home_team.team_abbrev, i.home_score,
             i.away_score, i.away_team.team_abbrev) for i in box_scores
             if i.away_team]
    text = ['Actual Score Update'] + score
    return '\n'.join(text)

This would require another function to calculate the previous week number though. I glanced through the espn_ff_api and it doesn't look like there's a way to return the current week number anywhere.

A workaround option could be to set the cron job to run at 11:59:59 Monday, as I'd imagine the rollover into the next week starts on Tuesday.

cwendt94 commented 5 years ago

The League object in ff_espn_api does have a current week variable “current_week”. For Tuesday update you can pass in league.current_week - 1 to box_scores

scuba-fan commented 5 years ago

Experiencing same issue. Has the fix been pushed to master branch?

Kruser727 commented 5 years ago

Yeah I'm experiencing the same issue today too. https://i.imgur.com/gHe39QB.png?1

foobartles commented 5 years ago

So is this going to break power rankings tonight? I’ll just disable the bot if that isn’t going to work either

rhartman93 commented 5 years ago

I don't think this should affect power rankings, the existing logic for current week should work with the power rankings

cwendt94 commented 5 years ago

Yeah power rankings still work and everything else works expect the final end of week update on Tuesday

foobartles commented 5 years ago

Makes sense, thanks.

scuba-fan commented 5 years ago

Any chance of getting this fix merged so we can deploy before game time tonight?

Jsayer7 commented 5 years ago

I could be wrong, but I think the issue is only seen on Tuesday mornings final score and trophy updates. I don't think there should be an issue with tonights matchup/projections updates.

dtcarls commented 5 years ago

@Jsayer7 is correct. I will try to find time today to review the PR and get the Tuesday fix merged in.