Skip to content

Commit 0f869dd

Browse files
authored
Merge pull request #11 from EVEprosper/plex_split
Plex split functionality
2 parents 0e30665 + cd25a98 commit 0f869dd

25 files changed

Lines changed: 2091 additions & 175 deletions

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ install:
99
- "travis_wait 15 pip install ."
1010
script:
1111
- "python scripts/manage_api.py --testkey"
12+
- "python scripts/create_splitcache.py --regions=10000002 --type=34,35 --range=30 --db=publicAPI/cache/travis_splitcache.json --source=esi"
1213
- "python setup.py test"
1314
branches:
1415
only:
1516
- master
1617
- travis_test
1718
after_success:
1819
- "pip install python-coveralls"
19-
- "coveralls"
20+
- "coveralls"

debian/changelog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
prosper-api (1.2.0.dev0) stable; urgency=low
2+
3+
* Adding split coverage ahead of PLEX split
4+
* Converting CCP source to ESI by default
5+
6+
-- John Purcell <jpurcell.ee@gmail.com> Mon, 08 May 2017 20:00:00 -0700
7+
18
prosper-api (1.1.4) stable; urgency=low
29

310
* changing to tinymongo for API key checking (Kane Larrete)

debian/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
ifneq ($(wildcard /opt/intel/intelpython3/.*),) #use intelpython bindings if available
66
override_dh_virtualenv:
7-
dh_virtualenv --python /opt/intel/intelpython3/bin/python3.5 --preinstall cython==0.24 --preinstall numpy==1.11.1 --preinstall matplotlib --extra-index-url https://repo.fury.io/lockefox/
7+
dh_virtualenv --python /opt/intel/intelpython3/bin/python3.5 --preinstall cython==0.24 --preinstall numpy==1.11.1 --preinstall matplotlib --extra-index-url https://repo.fury.io/lockefox/ --use-system-packages
88
else
99
override_dh_virtualenv:
1010
dh_virtualenv --python /usr/bin/python3.5 --preinstall cython --preinstall numpy --preinstall matplotlib --extra-index-url https://repo.fury.io/lockefox/

docs/release.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ _Testing Should Be Easy_
3232

3333
What is code without coverage? [pytest](http://doc.pytest.org/en/latest/) hooks have been built-in to make testing easy. Testing is just one command away:
3434

35-
>`python setup.py test`
35+
> `python scripts/manage_api.py -t` (first time only)
36+
37+
> `python scripts/create_splitcache.py --regions=10000002 --type=34,35 --range=30 --db=publicAPI/cache/travis_splitcache.json --source=esi` (first time only)
38+
39+
> `python setup.py test`
3640
3741
Included in the test pass:
3842
* unit testing

docs/split.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Stock Splits
2+
_Because Lockefox is an idiot and made the project no-db_
3+
4+
So, they announced [PLEX was going to be split](https://community.eveonline.com/news/dev-blogs/plex-changes-on-the-way/). NBD, right? Because ProsperAPI has no backing database, this is actually more difficult than it should be.
5+
6+
# Declaring A Split
7+
8+
```javascript
9+
publicAPI/split_info.json
10+
[
11+
12+
{
13+
"type_id": , #which item
14+
"type_name": , #type name for debug
15+
"original_id": , #ID before the split
16+
"new_id": , #ID after the split
17+
"split_date": , #%Y-%m-%d of split
18+
"bool_mult_div": , #price multiplied by split?
19+
"split_rate": , #new quantity
20+
}
21+
]
22+
```
23+
24+
Split info is designed to work in pairs. Define both old and new items in paired splits for backwards-compatability.
25+
26+
Also can be used with a `"split_rate": 1` for a `type_id` remapping.
27+
28+
# Backloading cache data
29+
Because [Prophet](https://github.com/EVEprosper/ProsperAPI/blob/master/docs/crest_endpoint.md#prophet) requires 720 days of back history, we need to keep an archive in-project to keep expected quality of service. Also, though CCP has said ESI will allow some back-compat, [EVE-Marketdata](https://eve-marketdata.com/) makes no such promises.
30+
31+
To backload:
32+
> `python scripts/create_splitcache.py`
33+
34+
See `-h` for settings for switching source, type, filename, regions, etc
35+
36+
Don't forget to commit updates ;)
37+
38+
# Testing
39+
Test suite uses a hacky sideload that uses Tritanium (34) and Pyerite (35) to validate behavior.
40+
41+
Also, `.travis.yml` creates a local split_cache.json file just for automated testing. See `.travis.yml` for preparing [test environment](https://github.com/EVEprosper/ProsperAPI/blob/master/docs/release.md#2-test-your-shit).
42+
43+
# Database Note:
44+
Splitcache has purposefully been made to run in a flat-file, rather than use [tinymongo](https://github.com/schapman1974/tinymongo) for remote database connection compatability. This was done to continue the spirit of "anyone can launch ProsperAPI anywhere".
45+
46+
PLEX split was prepared with the following:
47+
> `python scripts\create_splitcache.py -t 29668 -r 720 -s eve-marketdata`

publicAPI/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import publicAPI.crest_endpoint as crest_endpoint
77
import publicAPI.config as config
8+
import publicAPI.split_utils as split_utils
89

910
import prosper.common.prosper_logging as p_logging
1011

@@ -34,7 +35,7 @@ def create_app(
3435

3536
log_builder = p_logging.ProsperLogger(
3637
'publicAPI',
37-
HERE,
38+
'/var/log/prosper/',
3839
local_configs
3940
)
4041
if not app.debug:
@@ -51,4 +52,6 @@ def create_app(
5152
config.CONFIG = local_configs
5253
config.load_globals(local_configs)
5354
crest_endpoint.LOGGER = app.logger
55+
56+
config.SPLIT_INFO = split_utils.read_split_info(logger=crest_endpoint.LOGGER)
5457
return app

publicAPI/api_utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def check_key(
3131
(bool) access allowed or not
3232
3333
"""
34-
35-
# Connect to TinyMongoDB and use prosperAPI DB
34+
35+
# Connect to TinyMongoDB and use prosperAPI DB
3636
connection = TinyMongoClient(CACHE_PATH)
3737
userdb = connection.prosperAPI.users
3838
api_value = userdb.find_one({'api_key': api_key})
@@ -49,10 +49,8 @@ def check_key(
4949
currenttime = datetime.now().isoformat()
5050
userdb.update(
5151
{'api_key': api_key},
52-
{
53-
'$set': {'last_accessed': currenttime}
54-
}
55-
)
52+
{'$set': {'last_accessed': currenttime}}
53+
)
5654
connection.close()
5755
access_allowed = True
5856
else:

publicAPI/cache/splitcache.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

publicAPI/config.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""config.py: a place to hold config/globals"""
22
from os import path
3+
from enum import Enum
34

45
import prosper.common.prosper_logging as p_logging
56
import prosper.common.prosper_config as p_config
@@ -16,6 +17,15 @@
1617
MAX_RANGE = 180
1718
DEFAULT_HISTORY_RANGE = 700
1819
EXPECTED_CREST_RANGE = 400
20+
21+
SPLIT_CACHE_FILE = path.join(HERE, 'cache', 'splitcache.json')
22+
23+
class SwitchCCPSource(Enum):
24+
"""enum for switching between crest/esi"""
25+
ESI = 'ESI'
26+
CREST = 'CREST'
27+
EMD = 'EMD'
28+
1929
def load_globals(config=CONFIG):
2030
"""loads global vars from config object"""
2131
global USER_AGENT, USER_AGENT_SHORT, DEFAULT_RANGE, MAX_RANGE
@@ -25,3 +35,5 @@ def load_globals(config=CONFIG):
2535

2636
DEFAULT_RANGE = int(config.get('CREST', 'prophet_range'))
2737
MAX_RANGE = int(config.get('CREST', 'prophet_max'))
38+
39+
SPLIT_INFO = {}

0 commit comments

Comments
 (0)