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

feat(frontend, backend): connect rxdb #6

Merged
merged 31 commits into from
Sep 14, 2022
Merged

feat(frontend, backend): connect rxdb #6

merged 31 commits into from
Sep 14, 2022

Conversation

kand198
Copy link
Contributor

@kand198 kand198 commented Aug 30, 2022

Description

Closes this ticket.

lol:
image

This is a LARGE PR with a lot of potential to break things. It also includes a number of design changes. I'm very open to suggestions and requests for improvement.

Testing:

  1. Launch backend with npx nx serve backend
  2. Launch frontend with npx nx serve
  3. Navigate to patient details page
  4. Add a student with the "plus" button (NOTE: you cannot delete students at this time)

I would recommend checking that changes are persisted to the database by using the GraphQL playground.
You can check concurrency by opening a second browser, browser profile, or a new browser window in a private browsing mode (multiple tabs do NOT show concurrency and aren't explicitly supported in the current config).

Everything should update concurrently except for ENUM fields, which will require you to unload the patient and reload it (page refresh, or select a different patient). after debounce delay.

You can simulate going "offline" by shutting off the server, making some changes, then turning it back on.

You can simulate deleting a patient by editing the deletedAt field of a patient in the GraphQL playground.

Changes:

  • Added functionality to the "Add Patient" button
  • Major refactor for patient-related frontend and backend code
  • Added RxDB schema and database for patient info
  • Created a hook for accessing patient details
  • Implemented RxDB pull and push replication, linked with backend
  • Added method for mass-setting patients (required for RxDB push replicaiton)
  • Resolved issue with dateOfBirth field returning null unexpectedly by adding custom scalar type
  • Made all patient fields nullable on backend except for ID, to prevent losing information where a student may accidentally forget to fill in fields

To do before merging

Please let me know if any of these are out of scope or should be in a separate PR.

  • Add tests
  • Ensure deletedAt works
  • Ensure offline functionality works
  • Fix NPM vulnerabilities.
  • Fix RxDB related failure in CI

To do in other PRs

  • Ensure lastUpdatedAt wins
  • Fix minUpdatedAt in the patientReplicationFeed query
  • Ensure that only required info is being sent and recieved (optimise network usage)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

TODO.
Basic local manual testing.

Test Configuration:

  • Browser: Chrome (latest)
  • Device: Windows Laptop

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

@kand198 kand198 self-assigned this Aug 30, 2022
@kand198 kand198 changed the title [WIP] Feat/connect rxdb feat: connect rxdb (WIP) Aug 30, 2022
@kand198 kand198 changed the title feat: connect rxdb (WIP) feat(frontend): connect rxdb (WIP) Aug 31, 2022
@kand198 kand198 changed the title feat(frontend): connect rxdb (WIP) feat(frontend, backend): connect rxdb (WIP) Sep 12, 2022
@kand198
Copy link
Contributor Author

kand198 commented Sep 12, 2022

@jcha-686 npm ci works for me locally but the action is failing. Would you be able to take a look for me? I'm a bit lost haha.

Copy link
Contributor Author

@kand198 kand198 left a comment

Choose a reason for hiding this comment

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

Self-review:

I'm relatively happy with the code as it stands. I don't like how boilerplatey the RxDB stuff is, and while I've tried to add abstraction, I made sure not to spend too much time on it. I'd be keen for any ideas on simple ways to improve it.

Ready to open PR for review now.

@kand198 kand198 marked this pull request as ready for review September 14, 2022 02:17
Copy link
Contributor

@uoa-lzha989 uoa-lzha989 left a comment

Choose a reason for hiding this comment

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

As far as I can tell, it's looking good - just that one point (not sure if it was covered before)

@kand198 kand198 changed the title feat(frontend, backend): connect rxdb (WIP) feat(frontend, backend): connect rxdb Sep 14, 2022
Copy link
Contributor

@butterplup butterplup left a comment

Choose a reason for hiding this comment

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

As far as I can tell LGTM. Nice job with the enum serialize/deserialize btw.

Copy link
Contributor

@yuliapechorina yuliapechorina left a comment

Choose a reason for hiding this comment

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

Great work! Just some feedback on functionality, will continue looking through the code itself:

I was able to follow the testing steps and everything persisted to the database:
image

Testing config:
Browser: Chrome
Device: Windows Laptop

Editing the patient's name or another input field in a browser didn't update in the other browser automatically without me refreshing. The name fields update in the tab name, but not the input itself.

Some changes I'd like to see are:

  1. When you initially open the Patient Details page, the page is blank minus the table at the bottom. I know this is kind of OOS for your PR, but we can't really show that in the demo, so it'd be good if you changed this.
    -> Could you remove the table when no patient is selected, and have a message like "No patient selected yet!". Also, if you already have patients, could the user be automatically redirected to the first tab?

  2. Since all fields are nullable in the DB, could you add asterisks next to the required fields on the FE side - just so the user knows what fields should be filled in?

Copy link
Contributor

@yuliapechorina yuliapechorina left a comment

Choose a reason for hiding this comment

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

The code looks nice and clean to me, just 2 nitpicks:

apps/frontend/src/app/hooks/usePatients/usePatients.tsx Outdated Show resolved Hide resolved
apps/frontend/src/polyfills.ts Show resolved Hide resolved
Copy link
Contributor

@hmit106 hmit106 left a comment

Choose a reason for hiding this comment

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

LGTM, functionality is as described and code has no issues as far as I can see.

I noticed some general UI/usability issues that will need to be addressed in future, but they're well out of scope here so I put them in triage on the scrum board.

Copy link
Contributor

@yuliapechorina yuliapechorina left a comment

Choose a reason for hiding this comment

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

🚀 LGTM

@kand198 kand198 merged commit bf26d2d into main Sep 14, 2022
@kand198 kand198 deleted the feat/connect-rxdb branch September 14, 2022 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants