mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-22 14:29:36 +02:00
feat: enhance ImmichIntegrationView to support date range filtering and improve error handling for invalid date formats
This commit is contained in:
parent
cf108ecd3a
commit
d0c1ecd394
1 changed files with 22 additions and 5 deletions
|
@ -95,7 +95,25 @@ class ImmichIntegrationView(viewsets.ViewSet):
|
||||||
if query:
|
if query:
|
||||||
arguments['query'] = query
|
arguments['query'] = query
|
||||||
if date:
|
if date:
|
||||||
arguments['takenBefore'] = date
|
# Create date range for the entire selected day
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
try:
|
||||||
|
# Parse the date and create start/end of day
|
||||||
|
selected_date = datetime.strptime(date, '%Y-%m-%d')
|
||||||
|
start_of_day = selected_date.strftime('%Y-%m-%d')
|
||||||
|
end_of_day = (selected_date + timedelta(days=1)).strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
arguments['takenAfter'] = start_of_day
|
||||||
|
arguments['takenBefore'] = end_of_day
|
||||||
|
except ValueError:
|
||||||
|
return Response(
|
||||||
|
{
|
||||||
|
'message': 'Invalid date format. Use YYYY-MM-DD.',
|
||||||
|
'error': True,
|
||||||
|
'code': 'immich.invalid_date_format'
|
||||||
|
},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST
|
||||||
|
)
|
||||||
|
|
||||||
# check so if the server is down, it does not tweak out like a madman and crash the server with a 500 error code
|
# check so if the server is down, it does not tweak out like a madman and crash the server with a 500 error code
|
||||||
try:
|
try:
|
||||||
|
@ -135,7 +153,6 @@ class ImmichIntegrationView(viewsets.ViewSet):
|
||||||
status=status.HTTP_404_NOT_FOUND
|
status=status.HTTP_404_NOT_FOUND
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@action(detail=False, methods=['get'])
|
@action(detail=False, methods=['get'])
|
||||||
def albums(self, request):
|
def albums(self, request):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue