refactor: rename helper function
Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
This commit is contained in:
parent
53ed1a7057
commit
e7b0cdaf0c
2 changed files with 9 additions and 5 deletions
|
|
@ -51,7 +51,7 @@ def dbBhavCopyEquityList(request):
|
||||||
logger.info('Enqueue background task to populate Postgres DB')
|
logger.info('Enqueue background task to populate Postgres DB')
|
||||||
django_rq.enqueue(populate_bhav_copy_data_into_postgres, args=(None, req_date))
|
django_rq.enqueue(populate_bhav_copy_data_into_postgres, args=(None, req_date))
|
||||||
logger.info('Data not available in Postgres, redirecting to BSE')
|
logger.info('Data not available in Postgres, redirecting to BSE')
|
||||||
return _bseBhavCopyEquityList(request)
|
return _bse_bhav_copy_equity_list(request)
|
||||||
return Response({
|
return Response({
|
||||||
"data": serializer.data,
|
"data": serializer.data,
|
||||||
"message": ret_message
|
"message": ret_message
|
||||||
|
|
@ -70,7 +70,7 @@ def cacheBhavCopyEquityListV1(request):
|
||||||
logger.info('Enqueue background task to populate Redis')
|
logger.info('Enqueue background task to populate Redis')
|
||||||
django_rq.enqueue(populate_bhav_copy_data_into_redis_v1, args=(None, req_date))
|
django_rq.enqueue(populate_bhav_copy_data_into_redis_v1, args=(None, req_date))
|
||||||
logger.info('Data not available in Redis, trying to fetch from BSE')
|
logger.info('Data not available in Redis, trying to fetch from BSE')
|
||||||
return _bseBhavCopyEquityList(request)
|
return _bse_bhav_copy_equity_list(request)
|
||||||
pipe = cache.pipeline()
|
pipe = cache.pipeline()
|
||||||
for stock in stocks:
|
for stock in stocks:
|
||||||
pipe.hgetall(f"stock:{datestr}:{stock}")
|
pipe.hgetall(f"stock:{datestr}:{stock}")
|
||||||
|
|
@ -92,7 +92,7 @@ def cacheBhavCopyEquityListV2(request):
|
||||||
logger.info('Enqueue background task to populate Redis')
|
logger.info('Enqueue background task to populate Redis')
|
||||||
django_rq.enqueue(populate_bhav_copy_data_into_redis_v2, args=(None, req_date))
|
django_rq.enqueue(populate_bhav_copy_data_into_redis_v2, args=(None, req_date))
|
||||||
logger.info('Data not available in Redis, trying to fetch from BSE')
|
logger.info('Data not available in Redis, trying to fetch from BSE')
|
||||||
return _bseBhavCopyEquityList(request)
|
return _bse_bhav_copy_equity_list(request)
|
||||||
return Response({
|
return Response({
|
||||||
"data": json.loads(stocks),
|
"data": json.loads(stocks),
|
||||||
"message": ret_message
|
"message": ret_message
|
||||||
|
|
@ -101,9 +101,12 @@ def cacheBhavCopyEquityListV2(request):
|
||||||
|
|
||||||
@api_view(['GET'])
|
@api_view(['GET'])
|
||||||
def bseBhavCopyEquityList(request):
|
def bseBhavCopyEquityList(request):
|
||||||
return _bseBhavCopyEquityList(request)
|
"""Fetch and return data from BSE."""
|
||||||
|
return _bse_bhav_copy_equity_list(request)
|
||||||
|
|
||||||
def _bseBhavCopyEquityList(request):
|
|
||||||
|
def _bse_bhav_copy_equity_list(request):
|
||||||
|
"""Fetchinig data from BSE helper."""
|
||||||
date = request.query_params.get('date')
|
date = request.query_params.get('date')
|
||||||
req_date, _ = verify_date(date, "")
|
req_date, _ = verify_date(date, "")
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@
|
||||||
name: 'BhavStock',
|
name: 'BhavStock',
|
||||||
methods: {
|
methods: {
|
||||||
allowedDates: val => {
|
allowedDates: val => {
|
||||||
|
// Block out weekends, since market is not open
|
||||||
var day = new Date(val).getDay();
|
var day = new Date(val).getDay();
|
||||||
return !(day == 6 || day == 0);
|
return !(day == 6 || day == 0);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue