Skip to content

Not urgent | Optimizing the add-graph call and history component #51

@sidhant-tomar-003

Description

@sidhant-tomar-003

in client/src/context/Graph/graphState.js line 8 and onwards, the fetchallgraphs method is defined. I believe this is an operation that gets all the user graphs from the database by matching userID and stores them in the loadedgraphs useState var. However, when the user adds a new graph, this expensive operation of loading all the graphs will have to be redone. Instead, what we can do is simply append the new graph to the loadedgraphs usestate and independently push the new graph into the database without reloading it to the front end with an API call. Let me demonstrate:

Right now:
-> Load all graphs (expensive!)
-> other tasks . . . .
-> User saves a new graph, push graph to database
-> To keep history component updated, load all graphs (expensive!)

What would be better:
-> Load all graphs (expensive!)
-> other tasks . . . .
-> User saves new graph, push graph to database, (new) append new graph to loaded graphs array
-> History component is refreshed based on loaded graphs array (not expensive!)

Of course, this is only an issue when we have many users and when the users actually populate the database to a notable degree. That's why I'm gonna mark this issue as a long term issue :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions