-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Introduce route saving, environmental data computation, and scoring functionalities with a new data processing API. #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4753ee4
84f3c35
558e13e
e16f2df
0598536
a5c32d8
3385dee
e8e953e
0e1e982
e430043
b870060
0faee97
b35e17f
4650c18
b01b129
4ab28ec
ecbae17
a8da103
02db6ae
24f4a94
43a6501
da61bb5
8d69776
88bb043
fd1079a
7034411
a31c58e
bb73943
d8803c7
3d3ad64
79f1878
41881ef
4091e1c
c111433
38c2d82
c7c87f9
a2c09e2
0f32fd3
40a8199
1056d1c
f4f2d38
f3f0b7e
0502047
95fba52
227efcd
dd66f71
1527690
5894240
692349c
6bfd4df
e568621
510eb38
7f74202
697fa7b
1cc36f5
459117a
f500ea0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Use the custom 'theirs' merge driver for all files to prefer incoming changes. | ||
| * merge=theirs | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| from django.http import JsonResponse | ||
| import traceback | ||
| from django.conf import settings | ||
|
|
||
|
|
||
| class ApiExceptionMiddleware: | ||
| """ | ||
| Catch unhandled exceptions for API paths and return a JSON 500 response. | ||
| This avoids triggering Django's HTML technical_500 page (which on some | ||
| environments can fail to render) and gives a stable JSON error for the | ||
| frontend. | ||
| """ | ||
|
|
||
| def __init__(self, get_response): | ||
| self.get_response = get_response | ||
|
|
||
| def __call__(self, request): | ||
| try: | ||
| return self.get_response(request) | ||
| except Exception as exc: | ||
| # Only intercept API routes | ||
| path = getattr(request, 'path', '') or '' | ||
| if path.startswith('/api/'): | ||
| if settings.DEBUG: | ||
| tb = traceback.format_exc() | ||
| return JsonResponse({'success': False, 'message': 'Internal server error', 'error': str(exc), 'trace': tb}, status=500) | ||
| else: | ||
| return JsonResponse({'success': False, 'message': 'Internal server error'}, status=500) | ||
| # Re-raise for non-API routes so Django can handle normally | ||
| raise | ||
|
Comment on lines
+17
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error responses bypass Because Two possible fixes: Option A (preferred): Move the middleware below MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
+ 'api.middleware.ApiExceptionMiddleware',
'django.middleware.security.SecurityMiddleware',
...
- 'api.middleware.ApiExceptionMiddleware',
]Option B: Manually add CORS headers in the error response here, but this duplicates 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| This repository includes a custom merge driver that prefers the incoming ("theirs") side during merges. | ||
|
|
||
| Setup | ||
|
|
||
| - Unix / Git Bash: | ||
| - Run: `./scripts/setup-merge-theirs.sh` | ||
| - Windows PowerShell: | ||
| - Run: `./scripts/setup-merge-theirs.ps1` | ||
|
|
||
| Notes | ||
|
|
||
| - After registering the driver, Git will use the 'theirs' version for all files during merges. | ||
| - To accept incoming changes for an ongoing conflict manually: | ||
|
|
||
| ```powershell | ||
| git checkout --theirs -- . | ||
| git add -A | ||
| git commit -m "Accept incoming changes (theirs) for merge" | ||
| ``` | ||
|
|
||
| Be cautious: this will overwrite local changes with incoming ones for files that conflict. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,7 @@ | ||||||
| Param($O, $A, $B) | ||||||
| if (-not (Test-Path $B)) { | ||||||
| Write-Error "git-merge-theirs.ps1: missing 'their' file" | ||||||
| exit 1 | ||||||
| } | ||||||
| Get-Content -Raw -LiteralPath $B | Set-Content -LiteralPath $A -Encoding UTF8 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, check if the file exists and confirm the code in question
fd git-merge-theirs.ps1Repository: kaihere14/BreathClean Length of output: 93 🌐 Web query:
💡 Result: In Windows PowerShell 5.1, Implications:
Sources
🌐 Web query:
💡 Result:
If you need binary-safe processingRead bytes, not strings:
Then do explicit decoding/encoding only where appropriate, e.g.: $text = [Text.Encoding]::UTF8.GetString($bytes) # decode explicitly
# ...text processing...
$newBytes = [Text.Encoding]::UTF8.GetBytes($text) # re-encode explicitly
[IO.File]::WriteAllBytes($path, $newBytes)If the file is text (but you want reliable text processing)Be explicit about encoding (especially on Windows PowerShell 5.1, where $text = Get-Content -LiteralPath $path -Raw -Encoding utf8
# ...process...
Set-Content -LiteralPath $path -Encoding utf8 -Value $textNotes:
Citations:
🌐 Web query:
💡 Result:
Citations:
Replace
Use 🛡️ Proposed fix-Get-Content -Raw -LiteralPath $B | Set-Content -LiteralPath $A -Encoding UTF8
+Copy-Item -LiteralPath $B -Destination $A -Force📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| exit 0 | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/bin/sh | ||
| # git merge driver that prefers "theirs" (incoming) during merges. | ||
| # Called with: %O %A %B | ||
| if [ -z "$3" ]; then | ||
| echo "git-merge-theirs: missing 'their' file parameter" >&2 | ||
| exit 1 | ||
| fi | ||
| cat "$3" > "$2" | ||
| exit 0 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,4 @@ | ||||||
| Write-Host "Registering merge.theirs driver..." | ||||||
| git config --local merge.theirs.name "Keep theirs (incoming) during merges" | ||||||
| git config --local merge.theirs.driver ".\scripts\git-merge-theirs.ps1 %O %A %B" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Driver command won't execute — Git invokes the merge driver command through The driver path must invoke the PowerShell interpreter explicitly: -git config --local merge.theirs.driver ".\scripts\git-merge-theirs.ps1 %O %A %B"
+git config --local merge.theirs.driver "powershell -ExecutionPolicy Bypass -File ./scripts/git-merge-theirs.ps1 %O %A %B"Use 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| Write-Host "Registered merge.theirs driver (local git config)." | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/sh | ||
| # Register the 'theirs' merge driver locally and make scripts executable. | ||
| git config --local merge.theirs.name "Keep theirs (incoming) during merges" | ||
| git config --local merge.theirs.driver "./scripts/git-merge-theirs.sh %O %A %B" | ||
| chmod +x ./scripts/git-merge-theirs.sh || true | ||
| chmod +x ./scripts/git-merge-theirs.ps1 || true | ||
| echo "Registered merge.theirs driver (local git config)." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* merge=theirsglobally silences ALL merge conflicts — high data-loss risk.Assigning a merge driver in
.gitattributescontrols which driver handles specific files — and you should replace*with the file extension you actually want the custom driver applied to. The current glob*applies the "always take theirs" strategy to every file in the repository — source code, configuration, data files, binaries, and even.gitattributesitself.Specific consequences:
Suggest narrowing the pattern to only files that genuinely require automatic conflict resolution (e.g., auto-generated lock files like
*.lock, build artifacts, etc.) or removing this entirely in favour of an explicit per-file opt-in:🤖 Prompt for AI Agents