-
Notifications
You must be signed in to change notification settings - Fork 275
Implement Football Offers Report #657
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
Open
vibraslap3
wants to merge
5
commits into
cwendt94:master
Choose a base branch
from
vibraslap3:Offers_report
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e0f162b
Implement Football Offers Report
vibraslap3 c387bf1
Refactor to allow for offers in other sports, account for variable nu…
vibraslap3 b8a2688
small refactor to rename offer.time -> offer.dateTime, standardize cl…
vibraslap3 23656fa
Fix variable names
vibraslap3 e7d5385
Resolve off by one error in data fetch 🤡
vibraslap3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| from datetime import datetime | ||
|
|
||
|
|
||
| class Offer(object): | ||
| def __init__(self, data, player_map, get_team_data): | ||
| status = data['status'] | ||
| self.id = data['id'] | ||
| self.time = None | ||
| if status == 'CANCELED': | ||
| self.result = 'Canceled' | ||
| else: | ||
| if status == 'EXECUTED': | ||
| self.result = 'Processed' | ||
| elif status == 'FAILED_INVALIDPLAYERSOURCE': | ||
| self.result = 'Outbid' | ||
| elif status == 'FAILED_AUCTIONBUDGETEXCEEDED': | ||
| self.result = 'Budget Exceeded' | ||
| elif status == 'FAILED_POSITIONLIMIT': | ||
| self.result = 'Position Limit Exceeded' | ||
| elif status == 'FAILED_ROSTERLOCK': | ||
| self.result = 'Failed Due to Roster Lock' | ||
| elif status == 'FAILED_PLAYERALREADYDROPPED' or status == 'FAILED_ROSTERLIMIT' or status == 'PENDING': | ||
| self.result = 'Player already dropped' | ||
| else: | ||
| self.result = status | ||
| # fixes bug with unprocessed waivers stuck on "PENDING" status | ||
| if 'processDate' in data: | ||
| self.time = datetime.fromtimestamp(int(data['processDate'] / 1000)) # convert from milliseconds to seconds | ||
| self.amount = data['bidAmount'] | ||
| self.teamId = data['teamId'] | ||
| self.dropped_player = None | ||
| for item in data['items']: | ||
| if item['type'] == 'ADD': | ||
| self.player = item['playerId'] | ||
| elif item['type'] == 'DROP' and self.result == 'Processed': | ||
| self.dropped_player = item['playerId'] | ||
|
|
||
| def __lt__(self, other): | ||
| # sort by status, then bid amount | ||
| result_ranking = {'Processed': 7, | ||
| 'Outbid': 6, | ||
| 'Player already dropped': 5, | ||
| 'Budget Exceeded': 4, | ||
| 'Position Limit Exceeded': 3, | ||
| 'Failed Due to Roster Lock': 2, | ||
| 'CANCELLED': 1, | ||
| 'PENDING': 0} | ||
| if result_ranking[self.result] != result_ranking[other.result]: | ||
| return result_ranking[self.result] < result_ranking[other.result] | ||
| else: | ||
| # sort by bid amount | ||
| return self.amount < other.amount | ||
|
|
||
| def __repr__(self): | ||
| if self.result == 'Canceled': | ||
| return 'Canceled bid' | ||
| else: | ||
| ret_string = 'Offer(Date:{0}, Player:{1}, Team:{2}, Result:{3}, Bid:{4}'.format(self.time, self.player, self.teamId, | ||
| self.result, self.amount) | ||
| if self.dropped_player: | ||
| ret_string += ', Dropped:{0})'.format(self.dropped_player) | ||
| else: | ||
| ret_string += ')' | ||
| return ret_string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.