Arafath10 commited on
Commit
5409f6f
·
verified ·
1 Parent(s): 4301e6f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -5
main.py CHANGED
@@ -84,7 +84,10 @@ def delete_json(b_id):
84
  cursor.close()
85
  connection.close()
86
 
87
- def get_data(b_id):
 
 
 
88
  # Establish connection
89
  connection = mysql.connector.connect(
90
  host=host,
@@ -119,12 +122,12 @@ def get_data(b_id):
119
  result = {
120
  "BID":bid,
121
  "created_at":created_at,
122
- "forecast_data":forecast_data
123
  }
124
  return result
125
 
126
  else:
127
- return None
128
 
129
  # Close the cursor and connection
130
  cursor.close()
@@ -234,11 +237,11 @@ async def generate_product_count_prediction(b_id: int):
234
 
235
 
236
  @app.post("/get_product_count_prediction_from_DB")
237
- async def get_product_count_prediction_from_DB(b_id: int):
238
  response_content = {
239
  "status": "done",
240
  "message": "data from DB",
241
- "data": get_data(b_id),
242
  "status_code":200
243
  }
244
  return response_content
 
84
  cursor.close()
85
  connection.close()
86
 
87
+ def get_data(b_id,page_number,page_size):
88
+ start = (page_number - 1) * page_size
89
+ end = start + page_size
90
+
91
  # Establish connection
92
  connection = mysql.connector.connect(
93
  host=host,
 
122
  result = {
123
  "BID":bid,
124
  "created_at":created_at,
125
+ "forecast_data":forecast_data[start:end]
126
  }
127
  return result
128
 
129
  else:
130
+ return f"plesae genertae forcast for this business id:{b_id}"
131
 
132
  # Close the cursor and connection
133
  cursor.close()
 
237
 
238
 
239
  @app.post("/get_product_count_prediction_from_DB")
240
+ async def get_product_count_prediction_from_DB(b_id: int,page_number :int,page_size :int):
241
  response_content = {
242
  "status": "done",
243
  "message": "data from DB",
244
+ "data": get_data(b_id,page_number,page_size),
245
  "status_code":200
246
  }
247
  return response_content