DAVFoundation / missioncontrol

πŸ›° Controls and orchestrates missions between vehicles and DAV users
MIT License
181 stars 156 forks source link

refactor setting TTL in vehicles.js #157

Closed cg-cnu closed 6 years ago

cg-cnu commented 6 years ago

Thank you for your help :heart:

What is this project?

DAV (Decentralized Autonomous Vehicles) is a new foundation working to build an open-source infrastructure for autonomous vehicles (cars, drones, trucks, robots, and all the service providers around them) to communicate and transact with each other over blockchain.

The specific project you are looking at is Mission Control. It is the brain in charge of orchestrating missions between DAV users and autonomous vehicles.

How you can help

Mission Control comes with a built in simulation environment which generates and controls simulated vehicles, allowing developers to start developing without investing in costly hardware first.

One of the things the simulator does is keep track of requests for delivery missions.

Once created, those simulated requests remain indefinitely in memory.

Once we have many developers from around the world experimenting with the simulation environment, more and more requests will be created and kept in memory and never deleted.

What you can do

We need to add a TTL (Time To Live) expiration to the requests stored in Redis so that they are deleted automatically after some time.

In the file /server/store/vehicles.js the code used to set TTL redis.expire(`vehicles:${vehicle.id}`, config('vehicles_ttl')); is repeated twice. The task for this issue is to refactor that code by moving it to a separate function with the name setVehicleTTL(vehicleId).

Contributing to Mission Control

Asking for help

We appreciate your effort in taking the time to work on this issue and help out the open source community and the foundation. If you need any help, feel free to ask below or in our gitter channel. We are always happy to help πŸ˜„

hmainismael commented 6 years ago

Hello, I would like to contribute. Can I claim this issue ?

cg-cnu commented 6 years ago

Sure thing @hmainismael Go ahead πŸ‘

hmainismael commented 6 years ago

Please I just checked the file and there is no redundance of this code redis.expire(vehicles:${vehicle.id}, config('vehicles_ttl'));

cg-cnu commented 6 years ago

Its found here... https://github.com/DAVFoundation/missioncontrol/blob/1c093235ab0086806252046c462fc32f071aa79f/server/store/vehicles.js#L34-L40 in the lines 34 and 40.

hmainismael commented 6 years ago

Thanks a lot for your help!

hmainismael commented 6 years ago

The PR linked to this issue is the #158

cg-cnu commented 6 years ago

Congratulations @hmainismael on your first contribution to open source! And thank you being patient and fixing the additional review comments. We really appreciate it. Hope you had fun and learned few things doing this PR. Feel free to join our gitter channel to find out more opportunities πŸ™‚