Skip to content

Commit e99c897

Browse files
Configurate streams amount from bridge config
1 parent c4950e2 commit e99c897

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

openprocurement/auction/bridge_utils/managers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def get_streams(self, db, streams_id=STREAMS_ID):
8282
:return: amount of streams for auction per day
8383
:rtype: int
8484
"""
85-
8685
streams = db.get(streams_id, deepcopy(DEFAULT_STREAMS_DOC))
8786
return streams.get(self.streams_key, DEFAULT_STREAMS_DOC[self.streams_key])
8887

openprocurement/auction/databridge.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
IAuctionDatabridge, IAuctionsManager
2424
from openprocurement.auction.bridge_utils.design import sync_design
2525
from openprocurement.auction.bridge_utils.managers import MANAGERS_MAPPING
26-
from openprocurement.auction.bridge_utils.constants import WORKING_DAYS, CALENDAR_ID
26+
from openprocurement.auction.bridge_utils.constants import WORKING_DAYS, CALENDAR_ID, STREAMS_ID
2727

2828
from openprocurement.auction.core import components
2929
from openprocurement.auction.utils import FeedItem, check_workers
@@ -85,6 +85,7 @@ def __init__(self, config, re_planning=False, debug=False):
8585

8686
self.stream_db = Database(db_for_streams, session=Session(retry_delays=range(10)))
8787
self._set_holidays()
88+
self._set_streams_limits()
8889
sync_design(self.stream_db)
8990

9091
# Managers Mapping
@@ -102,6 +103,15 @@ def _set_holidays(self):
102103
del self.stream_db[CALENDAR_ID]
103104
self.stream_db.save(calendar)
104105

106+
def _set_streams_limits(self):
107+
streams = self.config.get('main').get('streams', {})
108+
109+
stream_amount = {'_id': STREAMS_ID}
110+
stream_amount.update(streams)
111+
if STREAMS_ID in self.stream_db:
112+
del self.stream_db[STREAMS_ID]
113+
self.stream_db.save(stream_amount)
114+
105115
def config_get(self, name):
106116
return self.config.get('main').get(name)
107117

openprocurement/auction/tests/bridge_utils/auctions_data_bridge.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ main:
77
auctions_db: database
88
timezone: Europe/Kiev
99
stream_db : test_stream_db
10+
streams:
11+
streams: 10
12+
dutch_streams: 15
13+
texas_streams: 20
1014
plugins:
1115
english:
1216
auction_worker_config: /home/oleksiy.veretiuk/QuintaGroup/projects/kadastral/openprocurement.auction.buildout/etc/auction_worker_defaults.yaml

0 commit comments

Comments
 (0)