Create and hook up asynchronous database

Description

Problem: Application performance is slow because of synchronous database calls that hog the browser thread, and large chunks of data are being held in browser memory.

As a user, I want a performant application that doesn't crash.

Acceptance Criteria

  • Add PouchDB library to openlmis-ui-components

  • Create "databaseService" which will wrap PouchDB create and delete methods, returning a reference to a pouchDB instance

  • Add a listener to the openlmis-auth.logout event, that will delete all databases stored in the browser

NOTE: Discussion of local database selection is here

Activity

Nick Reid 
October 23, 2017 at 2:16 PM

– I'm ok with closing this ticket without QA // I'm sure issues will come up in implementation // and we can deal with those then...

Nikodem Graczewski 
October 20, 2017 at 5:38 PM

As this ticket cannot be QA'd do you think it is ready to be closed?

Nick Reid 
October 20, 2017 at 1:52 PM

sounds good to me

I have also removed the A/C about implementing the database

Nikodem Graczewski 
October 20, 2017 at 10:24 AM

I've pushed the changes to master. I think that using this database in https://openlmis.atlassian.net/browse/OLMIS-3318#icft=OLMIS-3318 would make a lot of sense and would be great as a testing environment for it. What do you think?

CC

Nick Reid 
October 18, 2017 at 9:55 PM
(edited)

We this morning that modifying requisitions to use the database service was going to be risky and lots of work – and after reviewing the individual files, I agree that this work is too risky to take on right now.

Many of the files that you mentioned don't use the localStorageService in a meaningful way, and the underlying design of the batch requisitions screen is confusing.

If it were simple to remove the instances that use the localStrorageService for 'requisitions' – replacing these calls in requisition.js and requisition.service.js is less than ideal, as there is a ton of technical debt that if removed and refactored would result in more maintainable code.

The last requirement of this ticket was to actually use pouchDb somewhere in the system

  • We can remove that AC,

  • Or you can implement the database into the permissionService (which should be very quick)

Also, I'll make tickets for doing refactors to the requisition functions – but not when we are about to release

CC

Notes from checking out the code
There is a difference between our offline requisitions and batch requisitions --> I am not sure why there is a difference between these items

Its also worth noting the the requisition batch approval sequence doesn't work OLMIS-3072, and that a user must be online to actually approve a requisition

requisition-approval-list.controller.js
There is only one feature that uses offlineRequisitions, and that is used to show/hide the "View Requisitions" button
--> remove isFullRequisitionAvailable function & replace view button with link to requisition
We might also want to consider removing everything that uses the OfflineService from this page

requisition-batch-approval.controller.js
Access to 'requisitions' offlineStorage can be removed here
localStorage access for 'batchRequisitions' should be move into batchRequisitionsApprovalService

requisition-batch-save-factory.js
offlineRequisitions reference can just be removed – if there is an outdated version, it will be caught at some other point

requisition-search.controller.js
offlineRequisitions here should be removed. The removeOfflineRequisition function should be added into requisition.js or requisitionService

requisition-view.controller.js
localStorage reference should just be removed here

requisition.service.js
requisition.js
Both are just littered with old code that is repetitive between the two files.

Done
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Original estimate

Time tracking

3d 30m logged

Components

Sprint

Fix versions

Priority

Time Assistant

Created September 13, 2017 at 8:53 PM
Updated October 24, 2017 at 7:46 PM
Resolved October 24, 2017 at 6:25 PM