Open freelancing-solutions opened 3 years ago
fix bug Stock and Broker would Dicts not Instances of Stock and Broker
https://github.com/freelancing-solutions/gcp-database-as-a-service-stock-markets/blob/81c86a3134d228b4f100064df656e8ae7eec039a/data_service/views/stocks.py#L954
else: return jsonify({'status': False, 'message': 'Stock Model not found'}), 500 @use_context @handle_view_errors async def update_stock_model_async(self, stock_model: dict) -> tuple: if ('transaction_id' in stock_model) and (stock_model['transaction_id'] != ""): transaction_id: typing.Union[str, None] = stock_model.get('transaction_id') else: return jsonify({'status': False, 'message': 'transaction_id is required'}), 500 if ('exchange_id' in stock_model) and (stock_model['exchange_id'] != ""): exchange_id: typing.Union[str, None] = stock_model.get('exchange_id') else: return jsonify({'status': False, 'message': 'exchange_id is required'}), 500 if ('stock' in stock_model) and (stock_model['stock'] != ""): stock: typing.Union[Stock, None] = stock_model.get('stock') else: return jsonify({'status': False, 'message': 'stock is required'}), 500 if ('broker' in stock_model) and (stock_model['broker'] != ""): broker: typing.Union[Broker, None] = stock_model.get('broker') else: return jsonify({'status': False, 'message': 'Broker is required'}), 500 # TODO fix bug Stock and Broker would Dicts not Instances of Stock and Broker stock_model_instance: StockModel = StockModel.query( StockModel.transaction_id == transaction_id).get_async().get_result() if stock is not None: stock_instance: Stock = Stock.query(Stock.stock_code == stock['stock_code']).get_async().get_result() else: return jsonify({'status': False, 'message': 'stock is required'}), 500 if broker is not None: broker_instance: Broker = Broker.query( Broker.broker_code == broker['broker_code']).get_async().get_result() else: return jsonify({'status': False, 'message': 'Broker is required'}), 500 if isinstance(stock_model_instance, StockModel): stock_model = stock_model_instance stock_model.transaction_id = transaction_id stock_model.exchange_id = exchange_id stock_model.stock = stock_instance stock_model.broker = broker_instance key = stock_model.put_async(retries=self._max_retries, timeout=self._max_timeout).get_result() if key is not None: return jsonify({'status': True, 'payload': stock_model.to_dict(), 'message': 'stock model is update'}), 200 else: message: str = 'Something snapped while updating stock model' raise DataServiceError(message) else: return jsonify({'status': False, 'message': 'Stock Model not found'}), 500 # noinspection DuplicatedCode @data_wrappers.get_buy_volume_data @use_context
5a7ecf752a4e41cab8341be963c02f1d10eb81cf
fix bug Stock and Broker would Dicts not Instances of Stock and Broker
https://github.com/freelancing-solutions/gcp-database-as-a-service-stock-markets/blob/81c86a3134d228b4f100064df656e8ae7eec039a/data_service/views/stocks.py#L954
5a7ecf752a4e41cab8341be963c02f1d10eb81cf