Repository navigation
Snehita - Add mock data so every chart on the Total Construction Summary is populated - #2467
Open
snehitakandula wants to merge 4 commits into
Open
snehitakandula wants to merge 4 commits into
snehitakandula wants to merge 4 commits into
Conversation
|
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Implements: (PRIORITY HIGH) Phase 2 – Add mock data so every chart on the Total Construction Summary is populated (BM Dashboard → Reports → Total Construction Summary).
How each task item is addressed:
src/scripts/seedTcsMockData.js).How to load and reset the mock data
From the HGNRest root, with the usual
.env:Every inserted ID is recorded in a
mockDataManifestsdocument, so reset deletes only the mock records. Nothing created by other developers on the shared dev database is touched. Running the load again replaces the mock data instead of duplicating it.Main changes explained:
src/utilities/tcsMockDataSeeder.js: builds the mock records (seeded random, so the data is consistent between runs) and contains the load/reset logic. Models are passed in, so it is unit-testable.src/scripts/seedTcsMockData.js: CLI runner (same pattern asseedToolReplacements.js).src/models/bmdashboard/mockDataManifest.js: stores the inserted IDs for a safe reset.src/utilities/__tests__/tcsMockDataSeeder.test.js: 15 unit tests with mocked models (record builders, date range, field limits, risk profile/project name linking, reset deletes only manifest IDs, missing projects or admin user).Notes on how some charts read their data:
Issuesdocument whose_idis the risk profile'sprojectId, so oneIssuesdocument per project is created and linked.ProjectStatusandLaborCostto projects by name, so those are seeded by name.Charts
Now populated: Quantity of Materials Used (Last Week), Total Material Cost per Project, Project Status (Completed Projects, Avg Duration, Material Cost, Material Used, Material Wasted, Labor Cost), Issues Breakdown, Issue Chart, Longest Open Issues, Injury Severity by Projects, Injury by Worker Category, Lessons Learnt, Supplier Performance, Tools Returned Late, Paid Labor Cost, Expenditure, Actual vs Planned, Cost Breakdown, Risk Profile (by project name).
Cannot be filled by mock data (frontend/backend behavior, not data):
weeklyProjectSummaryService.projectId, so it was not seeded to avoid colliding with existing rows.How to test:
npm install,npm run build, copysrc/datatodist/data,npm startnpx jest tcsMockDataSeeder; all 15 tests passnode src/scripts/seedTcsMockData.jsand check the printed summarydevelopment, go to/bmdashboard/totalconstructionsummaryand verify the charts above show datanode src/scripts/seedTcsMockData.js --resetand confirm the mock data is removed (then load it again)Screenshots:
Note:
Backend only. The mock data is currently loaded on the dev database.