generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #768 from hackforla/refactor/backend-data-flow
use db data for coordinator dashboard, initial admin view
- Loading branch information
Showing
25 changed files
with
995 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# using a generic base image since we want to install python, nodejs, etc | ||
FROM mcr.microsoft.com/vscode/devcontainers/base:dev-bullseye | ||
|
||
# use latest available system package listings and installations | ||
RUN sudo apt-get update -y && sudo apt-get upgrade -y | ||
|
||
# we need `curl` to download things, and `build-essential` to | ||
# install python and node from source | ||
RUN sudo apt-get install -y \ | ||
curl \ | ||
build-essential \ | ||
libsqlite3-dev \ | ||
libpq-dev | ||
|
||
# these packages currently using 3.9 as latest available, | ||
# ideally these would be included in the `apt-get` command: | ||
# - python3 | ||
# - python3-dev | ||
|
||
# keep dependency installation resources separate from source | ||
WORKDIR /opt | ||
|
||
# download and install python from source | ||
# as of this writing, the latest package supported by apt is Python 3.9, and | ||
# this is the simplest way to get Python 3.12+ installed for dev | ||
RUN curl -LO https://www.python.org/ftp/python/3.12.5/Python-3.12.5.tgz \ | ||
&& tar xzf Python-3.12.5.tgz \ | ||
&& cd Python-3.12.5 \ | ||
&& ./configure --enable-loadable-sqlite-extensions \ | ||
&& make \ | ||
&& sudo make install \ | ||
&& cd .. | ||
|
||
# intall nodejs from prebuilt binaries | ||
# this approach avoids an issue with other provided installation steps | ||
# using Node/Vercel tools and scripts, namely surrounding the execution | ||
# of `source` and `.` commands during a Docker build | ||
RUN curl -LO https://nodejs.org/dist/v20.17.0/node-v20.17.0-linux-x64.tar.xz \ | ||
&& tar xJf node-v20.17.0-linux-x64.tar.xz \ | ||
&& cd node-v20.17.0-linux-x64 \ | ||
&& cp -r ./bin/* /usr/local/bin/ \ | ||
&& cp -r ./lib/* /usr/local/lib/ \ | ||
&& cp -r ./share/* /usr/local/share/ \ | ||
&& cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "FullStack", | ||
"build": { | ||
"dockerfile": "./Dockerfile", | ||
"context": ".." | ||
}, | ||
// install the decalred pip and npm packages | ||
"postCreateCommand": "bash ./scripts/install-deps-debian.bash", | ||
"runArgs": ["--platform=linux/amd64"], | ||
"forwardPorts": [ | ||
38429, | ||
38428 | ||
], | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "bash", | ||
"extensions.verifySignature": false | ||
}, | ||
"extensions": [ | ||
"ms-python.vscode-pylance", | ||
"ms-vscode.vscode-typescript-next" | ||
] | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# using a generic base image since we want to install python, nodejs, etc | ||
FROM mcr.microsoft.com/vscode/devcontainers/base:dev-bullseye | ||
|
||
# use latest available system package listings and installations | ||
RUN sudo apt-get update -y && sudo apt-get upgrade -y | ||
|
||
# we need `curl` to download things, and `build-essential` to | ||
# install python and node from source | ||
RUN sudo apt-get install -y \ | ||
curl \ | ||
build-essential \ | ||
libsqlite3-dev \ | ||
libpq-dev | ||
|
||
# these packages currently using 3.9 as latest available, | ||
# ideally these would be included in the `apt-get` command: | ||
# - python3 | ||
# - python3-dev | ||
|
||
# keep dependency installation resources separate from source | ||
WORKDIR /opt | ||
|
||
# download and install python from source | ||
# as of this writing, the latest package supported by apt is Python 3.9, and | ||
# this is the simplest way to get Python 3.12+ installed for dev | ||
RUN curl -LO https://www.python.org/ftp/python/3.12.5/Python-3.12.5.tgz \ | ||
&& tar xzf Python-3.12.5.tgz \ | ||
&& cd Python-3.12.5 \ | ||
&& ./configure --enable-loadable-sqlite-extensions \ | ||
&& make \ | ||
&& sudo make install \ | ||
&& cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "Python", | ||
"build": { | ||
"dockerfile": "./Dockerfile", | ||
"context": ".." | ||
}, | ||
"postCreateCommand": "python3 -m pip install .", | ||
//// TODO: if we can use the latest Python offered in devcontainers, this may | ||
//// provide a better dev UX | ||
// "image": "mcr.microsoft.com/vscode/devcontainers/python:3.9-bullseye", | ||
"runArgs": ["--platform=linux/amd64"], | ||
"forwardPorts": [ | ||
38429 | ||
], | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "bash", | ||
"extensions.verifySignature": false | ||
}, | ||
"extensions": ["ms-python.vscode-pylance"] | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from flask import Response | ||
|
||
from openapi_server.models.database import DataAccessLayer | ||
from openapi_server.models.schema import users_schema | ||
from openapi_server.models.user_roles import UserRole | ||
from openapi_server.repositories.user_repo import UserRepository, UnmatchedCaseRepository | ||
|
||
import json | ||
""" | ||
userName: | ||
type: string | ||
caseStatus: | ||
type: string | ||
coordinatorName: | ||
type: string | ||
userType: | ||
type: string | ||
lastUpdated: | ||
type: string | ||
notes: | ||
type: string | ||
""" | ||
def get_dashboard_data() -> Response: | ||
with DataAccessLayer.session() as session: | ||
user_repo = UserRepository(session) | ||
coordinator_users_by_id = {x.id: x for x in user_repo.get_users_with_role(UserRole.COORDINATOR)} | ||
print(f'get_dashboard_data(): coordinator_users_by_id = {json.dumps({k:v.email for k,v in coordinator_users_by_id.items()})}') | ||
case_repo = UnmatchedCaseRepository(session) | ||
|
||
all_users = [] | ||
for guest in user_repo.get_users_with_role(UserRole.GUEST): | ||
print(f'get_dashboard_data(): looking at guest: {guest.email} with ID "{guest.id}"') | ||
case_status = case_repo.get_case_for_guest(int(guest.id)) | ||
print(f'get_dashboard_data(): get_case_for_guest({guest.id}) returned "{case_status}"') | ||
coordinator = coordinator_users_by_id[case_status.coordinator_id] | ||
all_users.append({ | ||
'id': guest.id, | ||
'userName': f'{guest.firstName} {guest.lastName}', | ||
'caseStatus': 'In Progress', | ||
'userType':'GUEST', | ||
'coordinatorName': f'{coordinator.firstName} {coordinator.lastName}', | ||
'lastUpdated': '2024-08-25', | ||
'Notes': 'N/A' | ||
}) | ||
|
||
for host in user_repo.get_users_with_role(UserRole.HOST): | ||
all_users.append({ | ||
'id': host.id, | ||
'userName': f'{host.firstName} {host.lastName}', | ||
'caseStatus': 'In Progress', | ||
'userType':'HOST', | ||
'coordinatorName': f'N/A', | ||
'lastUpdated': '2024-08-25', | ||
'Notes': 'N/A' | ||
}) | ||
|
||
for coordinator in user_repo.get_users_with_role(UserRole.COORDINATOR): | ||
all_users.append({ | ||
'id': coordinator.id, | ||
'userName': f'{coordinator.firstName} {coordinator.lastName}', | ||
'caseStatus': 'N/A', | ||
'userType':'COORDINATOR', | ||
'coordinatorName': f'N/A', | ||
'lastUpdated': '2024-08-25', | ||
'Notes': 'N/A' | ||
}) | ||
|
||
return { | ||
'dashboardItems': all_users | ||
}, 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.