Skip to content
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

PIMS-1741 Lookup Context #2469

Merged
merged 10 commits into from
Jun 20, 2024
Merged

PIMS-1741 Lookup Context #2469

merged 10 commits into from
Jun 20, 2024

Conversation

dbarkowsky
Copy link
Collaborator

@dbarkowsky dbarkowsky commented Jun 19, 2024

🎯 Summary

PIMS-1741

Goal is to add a lookup context to the frontend that would reduce the number of joins needed in other database calls.
Lookup context matches this interface:

export interface LookupAll {
  Risks: Partial<ProjectRisk>[];
  TimestampTypes: Partial<MetadataType>[];
  MonetaryTypes: Partial<MetadataType>[];
  NoteTypes: Partial<MetadataType>[];
  PropertyTypes: Partial<MetadataType>[];
  Tasks: Partial<Task>[];
  ProjectStatuses: Partial<ProjectStatus>[];
  ProjectTiers: Partial<TierLevel>[];
  ConstructionTypes: Partial<BuildingConstructionType>[];
  PredominateUses: Partial<BuildingPredominateUse>[];
  Classifications: Partial<PropertyClassification>[];
  Roles: Partial<Role>[];
  Agencies: Partial<Agency>[];
  AdministrativeAreas: Partial<AdministrativeArea>[];
  RegionalDistricts: Partial<RegionalDistrict>[];
}

This PR only adds the context for use. Will continue this ticket with a second PR that starts to swap out the joins for context usage.

Changes

  • Reinstated frontend /dev route, removing route that was used for LTSA testing
  • Filled out /lookup/all controller logic.
  • Added LookupContext to the frontend

Testing

If you navigate to /dev, there's a log that should print the context to the console.

🔰 Checklist

  • I have read and agree with the following checklist and am following the guidelines in our Code of Conduct document.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation where required.
  • I have tested my changes to the best of my ability.
  • My changes generate no new warnings.

@dbarkowsky dbarkowsky self-assigned this Jun 19, 2024
@dbarkowsky dbarkowsky changed the title Pims 1741 lookup context PIMS-1741 Lookup Context Jun 19, 2024
Copy link

🚀 Deployment Information

The Express API Image has been built with the tag: 2469. Please make sure to utilize this specific tag when promoting these changes to the TEST and PROD environments during the API deployment. For more updates please monitor Image Tags Page on Wiki.

Copy link

codeclimate bot commented Jun 19, 2024

Code Climate has analyzed commit 28c639f and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 95.4% (50% is the threshold).

This pull request will bring the total coverage in the repository to 94.5%.

View more on Code Climate.

@GrahamS-Quartech
Copy link
Contributor

GrahamS-Quartech commented Jun 19, 2024

The context seems to work well. I think one thing that might be desirable to include in this is some functions for retrieving a lookup item by it's numeric id. There would be some upfront cost in collecting objects into a feasible format for this (probably organized into objects of form [primarykey]: { ...restOfRow } ), but past that initial cost we would then be able to retrieve anything in O(1) time. This would keep things super speedy when we go to use these in the tables.

EDIT: Went ahead and made a commit for this functionality. Let me know what you think.

@dbarkowsky
Copy link
Collaborator Author

dbarkowsky commented Jun 19, 2024

@GrahamS-Quartech I like the way that works. Good idea.
Testing out the context in practice with the AdministrativeAreaDetail, I have some errors where I think the context isn't finished populating by the time we're trying to retrieve data from it. Will continue to investigate, but I don't think we should merge this until it's working properly.

EDIT: Ok, think it's working now!

@dbarkowsky dbarkowsky merged commit 4dc085d into main Jun 20, 2024
11 checks passed
@dbarkowsky dbarkowsky deleted the PIMS-1741-Lookup-Context branch June 20, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants