avantifellows / avantifellows/reporting
Replace firestore with postgres
- Dominant language
- Python
- Stars
- 2
- Forks
- 5
- Avg merge
- 1m
- Merged PRs (30d)
- 3
Description
Replace firestore dependency with postgres in `app/db/sessions_db.py` and related files
To connect to db you can use something like:
```
"""
Helper function to make requests to main database service API
Args:
endpoint (str): The API endpoint (e.g., 'session', 'student')
params (dict): Query parameters
Returns:
list: API response data, or None if request failed
"""
db_url = os.getenv("AF_DB_SERVICE_URL")
db_token = os.getenv("AF_DB_SERVICE_BEARER_TOKEN")
if not db_url or not db_token:
raise ValueError("AF_DB_SERVICE_URL and AF_DB_SERVICE_BEARER_TOKEN environment variables are required")
headers = {
"accept": "application/json",
"Authorization": f"Bearer {db_token}"
}
# Build URL with query parameters
query_string = "&".join([f"{k}={v}" for k, v in params.items()])
url = f"{db_url}/{endpoint}?{query_string}"
try:
response = requests.get(url, headers=headers, timeout=30)
response.raise_for_status()
data = response.json()
return data if data else None
except requests.exceptions.RequestException as e:
print(f"Error fetching {endpoint} from DB API: {e}")
return None
def get_session_by_id(session_id: str) -> Optional[Dict[str, Any]]:
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading app/db/sessions_db.py and tracing the related files that use its session access. Compare the existing Firestore dependency and the provided database-service connection pattern, then verify that session operations work without Firestore and use Postgres instead.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgres, python
- Domain
- backend, databases
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100