Skip to content

Commit

Permalink
moved file storing out of docs folder
Browse files Browse the repository at this point in the history
  • Loading branch information
star-nox committed Nov 15, 2023
1 parent 4b4b75a commit 7ca12c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 177 deletions.
7 changes: 4 additions & 3 deletions ai_ta_backend/export_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import datetime
import uuid
import pandas as pd
import supabase
from flask import send_file
Expand Down Expand Up @@ -36,8 +36,9 @@ def export_convo_history_csv(course_name: str, from_date= '', to_date= ''):
print("id count greater than zero")
first_id = response.data[0]['id']
last_id = response.data[-1]['id']
filename = course_name + '_convo_history.csv'
file_path = os.path.join(os.getcwd(), 'docs/' + filename)

filename = course_name + '_' + str(uuid.uuid4()) + '_convo_history.csv'
file_path = os.path.join(os.getcwd(), filename)
# Fetch data in batches of 25 from first_id to last_id
while first_id <= last_id:
print("Fetching data from id: ", first_id)
Expand Down
4 changes: 2 additions & 2 deletions ai_ta_backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,12 @@ def export_convo_history():
)

export_status = export_convo_history_csv(course_name, from_date, to_date)
print(export_status)
print("EXPORT FILE LINKS: ", export_status)

response = make_response(send_from_directory(export_status[2], export_status[1], as_attachment=True))
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers["Content-Disposition"] = f"attachment; filename={export_status[1]}"

os.remove(export_status[0])
return response

Expand Down
172 changes: 0 additions & 172 deletions cropwizard_convo_history.csv

This file was deleted.

0 comments on commit 7ca12c8

Please sign in to comment.