Skip to content

in data store the create page the upload doc fixed - #22

Open
cherry-git999 wants to merge 8 commits into
Agriworks:mainfrom
cherry-git999:main
Open

in data store the create page the upload doc fixed #22
cherry-git999 wants to merge 8 commits into
Agriworks:mainfrom
cherry-git999:main

Conversation

@cherry-git999

Copy link
Copy Markdown
Member

No description provided.

- Remove custom upload/view endpoints in datasets.py
- Use getPresignedUrl and extractDataset from hey-api SDK
- Add /s3local proxy in next.config.ts to resolve browser CORS issues
- Add file_id ObjectId lookup in get_presigned_url endpoint to return correct download URL
- Clean PUT signature parameters before GET fetch in FileDownloadButton
- Trigger instant browser download into Downloads folder using hey-api SDK
Comment on lines +98 to -103
role_ids = user.get("role_id")
role_name = "user"
if role_id:
role = get_role_by_id(role_id)
if role and role.get("role_name"):
role_name = role["role_name"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if its plural ids being stored / retrieved, then I'd like to know. like the property should be role_ids then

role_name = "admin"
elif roles_found:
role_name = roles_found[0]
logger.debug("User role resolved: role_ids=%s role_name=%s", role_ids, role_name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generally problematic so we need to have an rbac code that will be used to centralize all the role checking under that. Even admins and superadmins need to have some kind of a flow

Comment thread backend/test_presigned.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should fall under tests, don't pollute the directory

// Clean query parameters to avoid signature mismatch on GET requests
let cleanUrl = rawUrl ? rawUrl.split("?")[0] : "";
if (!cleanUrl && objectName) {
cleanUrl = `http://localhost:9000/uploads/${objectName}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't hard code this url, this won't work in deployment

Comment on lines +194 to +197
targetUrl = targetUrl.replace(
/^http:\/\/(localhost|127\.0\.0\.1):9000/,
`${window.location.origin}/s3local`
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't assume these are the things, presigned urls should be passing the entire url, not like this please chekc this

Comment thread frontend/next.config.ts
{
source: "/s3local/:path*",
destination: "http://localhost:9000/:path*",
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can't be setup like this, presigned urls should not be proxied since it might be coming from aws in the future

…ric storage sync engine

Phase 1:
- Updated csa-erp-client dependency to local editable package (/workspaces/erpnext_client)
- Replaced custom REST extraction in erp.py with unified ERPNextClient methods
- Supported DocTypes and Query Reports (Stock Balance) via generic client methods
- Maintained full backward compatibility for FastAPI endpoints, task runners, and Streamlit dashboards

Phase 2:
- Added sync_checkpoints collection in database.py to track watermarks and sync states
- Enhanced store_to_mongodb() in mongodb_service.py with configurable record merging (upsert)
- Prevented duplicate records on re-sync (idempotency) and enabled in-place record updates
- Extended pipeline_mapping.py to support sync_strategy (timestamp vs snapshot) and identity_key
- Enabled incremental DocType extraction using ERPNext 'modified' timestamps in erp.py
- Supported snapshot replacement for Query Reports (Stock Balance)
- Updated TaskRunner in task_executor.py to advance checkpoints only after successful MongoDB storage
- Organized test suites under backend/tests/
…layer & multi-ERP routing

- Implement BaseMapper abstraction with strict schema validation and date/number normalizers
- Create dedicated mappers for all 6 dashboards (NFCoordinator, TerritoryTransactions, FarmerIncomeVisits, StockMovement, StockInventory, RevenueAnalysis)
- Add Central MapperRegistry for dataset-to-mapper binding with clean unmapped passthrough
- Add multi-ERP routing support in erp.py for erp.csa-india.org and erp.fpohub.com
- Integrate mapping step in TaskRunner pipeline execution
- Document mapping architecture and live ERP schema alignments
- Add comprehensive Phase 3 test suite in test_phase3_dashboard_mapping.py
…goDB & dynamic calculations

- Implement load_dashboard_data_from_mongodb helper with clean BSON _id exclusion in utilities.py
- Migrate Dashboard 1 (NF Coordinator) to 'nf_coordinator_activities'
- Migrate Dashboard 2 (Purchase & Sales) to 'territory_transactions' with zero-sales safety
- Migrate Dashboard 3 (Farmer Income) to 'farmer_income_visits' with safe null financial metrics
- Migrate Dashboard 4 (Stock Movement) to 'stock_movement'
- Migrate Dashboard 5 (Stock Inventory) to 'stock_inventory'
- Migrate Dashboard 6 (Revenue Analysis) to 'revenue_analysis' & eliminate all hardcoded mockup constants
- Preserve all reference CSV files in app/dashboards/data/ as offline fallbacks
- Add comprehensive test suites for pilot, stock, commercial, E2E regression, and warehouse integration
…ERPNext

- Implement trigger_warehouse_auto_sync in utilities.py reusing existing TaskRunner, ERPNextClient, and MapperRegistry
- Add auto_sync support to load_dashboard_data_from_mongodb to trigger synchronous sync prior to querying MongoDB
- Update stock_inventory_dashboard and stock_movement_dashboard to trigger auto-sync on mount/refresh
- Set @st.cache_data(ttl=10) and add manual 'Sync with ERP' sidebar button
- Preserve existing MongoDB documents and freeze checkpoints on ERP failure/outage
- Add comprehensive test suite in test_phase5_warehouse_auto_sync.py verifying live sync, idempotency, zero duplication, and fault tolerance
@cherry-git999 cherry-git999 reopened this Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants