Conversation
|
No actionable comments were generated in the recent review. 🎉 WalkthroughAdded a call to reset stuck imports at the end of the re_export_stuck_exports task and bumped fyle-accounting-mappings from 3.1.0 to 3.2.0 in requirements.txt. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Failure. Coverage is below 90%.Diff Coverage
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@apps/internal/tasks.py`:
- Around line 34-37: The comparison against a naive datetime causes timezone
mismatches; update the query and update call in the tasks module where
ImportLog.objects.filter(...) sets updated_at__lt=datetime.now() and
import_logs.update(..., updated_at=datetime.now()) to use timezone-aware
datetimes (e.g., datetime.now(timezone.utc)); ensure timezone is imported (from
datetime import datetime, timezone or from django.utils import timezone) and
replace both occurrences that reference datetime.now() for ImportLog
(import_logs) so the filter and the updated_at assignment use timezone-aware
values.
- Line 113: The call to handle_stuck_imports is currently inside the conditional
that checks task_logs.count() and uses workspace_ids_list (which only contains
workspaces with stuck exports), so stuck imports get missed; move the
handle_stuck_imports(...) invocation out of the if block so it always runs, and
call it with prod_workspace_ids instead of workspace_ids_list (update any
variable name references accordingly) to ensure all production workspaces are
checked for stuck imports.
- Line 7: The import is pulling List from
fyle_accounting_library.rabbitmq.helpers instead of the standard typing module;
update the import so that the symbol List is imported from typing (replace the
current List import from fyle_accounting_library.rabbitmq.helpers with an import
from typing) to match the rest of the codebase and ensure consistency for usages
of List in this module (search for the List symbol and the import line to make
the change).
🧹 Nitpick comments (1)
apps/internal/tasks.py (1)
35-37: Minor: avoid redundant queries —.exists()+.count()+.update()is three DB hits.You can simplify by calling
.update()directly and checking the returned row count, which is a single query.Proposed refactor
- if import_logs.exists(): - logger.info('Stuck import logs found: %s', import_logs.count()) - import_logs.update(status='FAILED', updated_at=datetime.now()) + updated_count = import_logs.update(status='FAILED', updated_at=datetime.now(tz=timezone.utc)) + if updated_count: + logger.info('Stuck import logs found and reset: %s', updated_count)
apps/internal/tasks.py
Outdated
| from django.db.models import F, Q | ||
| from django_q.models import OrmQ, Schedule | ||
| from fyle_accounting_library.fyle_platform.enums import ExpenseImportSourceEnum | ||
| from fyle_accounting_library.rabbitmq.helpers import List |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, check if the file exists and read the relevant lines
head -50 apps/internal/tasks.py | cat -nRepository: fylein/fyle-qbo-api
Length of output: 2604
🏁 Script executed:
# Search for all List imports in the repository
rg -n "import List" --type py -A 2Repository: fylein/fyle-qbo-api
Length of output: 1768
🏁 Script executed:
# Search for List usage in the tasks.py file specifically
rg -n "List\[" apps/internal/tasks.pyRepository: fylein/fyle-qbo-api
Length of output: 122
🏁 Script executed:
# Check if fyle_accounting_library exists in the repo at all
find . -type d -name "fyle_accounting_library" 2>/dev/null | head -20Repository: fylein/fyle-qbo-api
Length of output: 45
🏁 Script executed:
# Check the imports section of the file more carefully
sed -n '1,30p' apps/internal/tasks.py | cat -nRepository: fylein/fyle-qbo-api
Length of output: 1559
Import List from typing instead of fyle_accounting_library.rabbitmq.helpers.
Line 7 imports List from fyle_accounting_library.rabbitmq.helpers, but all other files in the codebase import it from typing. This is non-standard and inconsistent. Change the import to use the canonical source:
Proposed fix
-from fyle_accounting_library.rabbitmq.helpers import List
+from typing import List📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| from fyle_accounting_library.rabbitmq.helpers import List | |
| from typing import List |
🤖 Prompt for AI Agents
In `@apps/internal/tasks.py` at line 7, The import is pulling List from
fyle_accounting_library.rabbitmq.helpers instead of the standard typing module;
update the import so that the symbol List is imported from typing (replace the
current List import from fyle_accounting_library.rabbitmq.helpers with an import
from typing) to match the rest of the codebase and ensure consistency for usages
of List in this module (search for the List symbol and the import line to make
the change).
Coverage Report
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Failure. Coverage is below 90%.Diff Coverage
|
Coverage Report
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Coverage Report
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff Coverage
|
Description
feat: reset failed import logs
Clickup
https://app.clickup.com/
Summary by CodeRabbit
Bug Fixes
Chores