-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Alex/form submission history (#20) * added history of every form submission * added history to the router * created history search * deleted file i accidentally created * added tokens and caregiver adding function (#21) * Add jager to default deployment * Fix tracing and logging Least disorganized git repository * remove unneeded imports * added form finding for caregivers * added find caregivers listing, and remove caregiver functionality * add medication tracking (#22) * add medication tracking also some other files got hit by `cargo fmt` 🤷 * forgot `$set` * improved history and other features * fixed cookie issue * re-added medication --------- Co-authored-by: Chris Graham <Chrisgraham908@gmail.com> Co-authored-by: LeavesOfFall <131100486+LeavesOfFall@users.noreply.github.com>
- Loading branch information
1 parent
0e0f052
commit 09dea11
Showing
31 changed files
with
1,067 additions
and
97 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,97 @@ | ||
# flyctl launch added from .gitignore | ||
# no compiled | ||
**\debug | ||
**\target | ||
target | ||
|
||
# If you commit keys I will personally remove you from this earth | ||
**\.env | ||
|
||
**\**\*.rs.bk | ||
**\*.pdb | ||
|
||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
**\.idea\**\workspace.xml | ||
**\.idea\**\tasks.xml | ||
**\.idea\**\usage.statistics.xml | ||
**\.idea\**\dictionaries | ||
**\.idea\**\shelf | ||
|
||
# AWS User-specific | ||
**\.idea\**\aws.xml | ||
|
||
# Generated files | ||
**\.idea\**\contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
**\.idea\**\dataSources | ||
**\.idea\**\dataSources.ids | ||
**\.idea\**\dataSources.local.xml | ||
**\.idea\**\sqlDataSources.xml | ||
**\.idea\**\dynamic.xml | ||
**\.idea\**\uiDesigner.xml | ||
**\.idea\**\dbnavigator.xml | ||
|
||
# Gradle | ||
# .idea/compiler.xml | ||
# .idea/jarRepositories.xml | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
# *.iml | ||
# *.ipr | ||
**\.idea\**\gradle.xml | ||
**\.idea\**\libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
# .idea/artifacts | ||
# .idea/compiler.xml | ||
# .idea/jarRepositories.xml | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
# *.iml | ||
# *.ipr | ||
|
||
# CMake | ||
**\cmake-build-* | ||
|
||
# Mongo Explorer plugin | ||
**\.idea\**\mongoSettings.xml | ||
|
||
# File-based project format | ||
**\*.iws | ||
|
||
# IntelliJ | ||
**\out | ||
|
||
# mpeltonen/sbt-idea plugin | ||
**\.idea_modules | ||
|
||
# JIRA plugin | ||
**\atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
**\.idea\replstate.xml | ||
|
||
# SonarLint plugin | ||
**\.idea\sonarlint | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
**\com_crashlytics_export_strings.xml | ||
**\crashlytics.properties | ||
**\crashlytics-build.properties | ||
**\fabric.properties | ||
|
||
# Editor-based Rest Client | ||
**\.idea\httpRequests | ||
|
||
# Android studio 3.1+ serialized cache file | ||
**\.idea\caches\build_file_checksums.ser | ||
fly.toml |
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,18 @@ | ||
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ | ||
|
||
name: Fly Deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
name: Deploy app | ||
runs-on: ubuntu-latest | ||
concurrency: deploy-group # optional: ensure only one action runs at a time | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --remote-only | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# fly.toml app configuration file generated for parkinsons-pulse-service on 2024-10-23T11:24:44+13:00 | ||
# | ||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
# | ||
|
||
app = 'parkinsons-pulse-service' | ||
primary_region = 'syd' | ||
|
||
[build] | ||
|
||
[http_service] | ||
internal_port = 8080 | ||
force_https = true | ||
auto_stop_machines = 'stop' | ||
auto_start_machines = true | ||
min_machines_running = 0 | ||
processes = ['app'] | ||
|
||
[[vm]] | ||
memory = '1gb' | ||
cpu_kind = 'shared' | ||
cpus = 1 |
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
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,96 @@ | ||
use axum::{ | ||
extract::{Path, State}, | ||
http::StatusCode, | ||
response::{IntoResponse, Response}, | ||
Json, | ||
}; | ||
use bson::DateTime; | ||
use chrono::Utc; | ||
use futures::StreamExt; | ||
use mongodb::{ | ||
bson::{doc, oid::ObjectId, to_document}, | ||
Collection, Cursor, Database, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
use serde_json::json; | ||
use tracing::info; | ||
|
||
use crate::app::{ | ||
auth::{self, middleware::Auth}, | ||
models::{ | ||
dto::{caregiver::CaregiverTokenPath, form::CreateFormPayload}, | ||
CaregiverToken, Form, User, | ||
}, | ||
}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
struct CaregiverInfo { | ||
id: ObjectId, | ||
first_name: String, | ||
last_name: String, | ||
email_address: String, | ||
} | ||
|
||
#[tracing::instrument] | ||
#[axum::debug_handler] | ||
pub async fn find_caregiver(State(db): State<Database>, Auth(auth): Auth) -> Response { | ||
let Some(auth) = auth else { | ||
return ( | ||
StatusCode::UNAUTHORIZED, | ||
String::from("You must be signed in to find caregivers"), | ||
) | ||
.into_response(); | ||
}; | ||
|
||
// Perform the aggregation using $lookup | ||
let pipeline = vec![ | ||
doc! { | ||
"$match": { | ||
"_id": auth.id | ||
} | ||
}, | ||
doc! { | ||
"$lookup": { | ||
"from": "users", // The caregivers collection | ||
"localField": "caregivers", // The field in users that holds caregiver IDs | ||
"foreignField": "_id", // The field in caregivers that matches the user_id | ||
"as": "caregivers_info" // The result will be stored in this field | ||
} | ||
}, | ||
doc! { | ||
"$project": { | ||
"caregivers_info._id": 1, | ||
"caregivers_info.first_name": 1, // Only retrieve caregiver ID and name | ||
"caregivers_info.last_name": 1, // Only retrieve caregiver ID and name | ||
"caregivers_info.email_address": 1, // Only retrieve caregiver ID and name | ||
} | ||
}, | ||
]; | ||
|
||
let Ok(mut cursor): Result<Cursor<bson::document::Document>, mongodb::error::Error> = | ||
db.collection::<User>("users").aggregate(pipeline).await | ||
else { | ||
return ( | ||
StatusCode::INTERNAL_SERVER_ERROR, | ||
String::from("could not find caregivers"), | ||
) | ||
.into_response(); | ||
}; | ||
|
||
let Some(Ok(caregiver)) = cursor.next().await else { | ||
return ( | ||
StatusCode::INTERNAL_SERVER_ERROR, | ||
String::from("could not find caregiver list"), | ||
) | ||
.into_response(); | ||
}; | ||
|
||
let Some(caregiver_info) = caregiver.get("caregivers_info") else { | ||
return ( | ||
StatusCode::INTERNAL_SERVER_ERROR, | ||
String::from("cannot extract caregiver information"), | ||
) | ||
.into_response(); | ||
}; | ||
(StatusCode::OK, Json(caregiver_info)).into_response() | ||
} |
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.