This repository has been archived by the owner on Jun 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE][FIX] Replaced crawler for better results and fix upcoming m…
…atches error (#65) * [FEATURE][FIX] Replaced crawler for better results and fix upcoming matches error * Replaced crawler to [espncricinfo](https://www.espncricinfo.com/) * Fixed pylint errors in app * Dockerfiles updated * [TEST][CI] Added tests for crawler and changed ci to circleci * [TEST][CI] Replaced CI to Circleci * [TEST] Fixed pytest
- Loading branch information
Showing
48 changed files
with
877 additions
and
1,389 deletions.
There are no files selected for viewing
This file contains 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,43 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
python: circleci/[email protected] | ||
docker: circleci/[email protected] | ||
|
||
jobs: | ||
build-and-test: | ||
executor: python/default | ||
environment: | ||
TEST: True | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
- docker/install-docker-compose | ||
- run: | ||
command: | | ||
python -m pip install --upgrade pip | ||
pip install pylint | ||
pip install -r requirements.txt | ||
pip install scrapy-autounit | ||
name: Install dependencies | ||
- run: | ||
command: | | ||
scrapy crawl espn-live | ||
scrapy crawl espn-players | ||
python3 -m unittest discover autounit/tests/ | ||
name: Crawler Test with autounit | ||
- run: | ||
command: | | ||
pylint app -E | ||
pylint app --exit-zero | ||
name: Lint with pylint | ||
- run: | ||
name: Test with pytest | ||
command: | | ||
docker -v | ||
docker-compose -v | ||
docker-compose -f docker/docker-compose-test.yaml up --build --exit-code-from test | ||
workflows: | ||
main: | ||
jobs: | ||
- build-and-test |
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -67,6 +67,7 @@ instance/ | |
|
||
# Scrapy stuff: | ||
.scrapy | ||
autounit | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains 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,37 @@ | ||
"""This module defines all supported fantasy_leagues and their functionality. | ||
All browsers must inherit from app.fantasy_cricket.Team`. | ||
""" | ||
from app.fantasy_cricket.team import Team | ||
|
||
|
||
class Dream11(Team): | ||
"""Dream11 League | ||
Supported formats: | ||
* ODI | ||
* T20 | ||
* TEST | ||
""" | ||
|
||
name = "Dream11" | ||
|
||
batting_dict = { | ||
"runs": [1, 1, 1], | ||
"boundaries": [1, 1, 1], | ||
"sixes": [2, 2, 2], | ||
"50": [4, 4, 8], | ||
"100": [8, 8, 16], | ||
"duck": [-4, -3, -2], | ||
} | ||
|
||
bowling_dict = { | ||
"wicket": [16, 25, 25], | ||
"4-wicket-haul": [4, 4, 8], | ||
"5-wicket-haul": [8, 8, 16], | ||
"Maiden": [0, 8, 4], | ||
} | ||
|
||
wk_dict = { | ||
"Catch": [8, 8, 8], | ||
"Stump": [12, 12, 12], | ||
} |
This file contains 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,56 @@ | ||
""" | ||
The module is defined to get upcoming match data of the next 2 days | ||
""" | ||
|
||
from typing import List | ||
from app.fantasy_cricket.scrapyrt_client import EspnClient | ||
|
||
|
||
class Matches: | ||
""" | ||
A class to get upcoming live match data of the next 2 days | ||
""" | ||
|
||
def __init__(self) -> None: | ||
|
||
self.espn = EspnClient() | ||
|
||
def get_upcoming_match(self): | ||
""" | ||
Gets current matches dict | ||
""" | ||
matches = [] | ||
for match in self.espn.get_upcoming_dets(): | ||
if match["team1_squad"] != [] and match["team2_squad"] != []: | ||
matches.append( | ||
{ | ||
"team1": match["team1"], | ||
"team2": match["team2"], | ||
"flag_team1": "https://a.espncdn.com/i/teamlogos/cricket/500/" | ||
+ match["team1_id"] | ||
+ ".png", | ||
"flag_team2": "https://a.espncdn.com/i/teamlogos/cricket/500/" | ||
+ match["team2_id"] | ||
+ ".png", | ||
} | ||
) | ||
|
||
return matches | ||
|
||
def get_squad_match_type(self, teams: List[str]): | ||
""" | ||
Gets squad and match_class based on teams | ||
""" | ||
|
||
for match in self.espn.get_upcoming_dets(): | ||
|
||
if match["team1"] == teams[0] and match["team2"] == teams[1]: | ||
match_det = { | ||
"team1_squad": match["team1_squad"], | ||
"team2_squad": match["team2_squad"], | ||
"match_type": match["match_id"], | ||
} | ||
break | ||
|
||
return match_det |
Oops, something went wrong.