A Ruby on Rails-based full stack web application that facilitates random lunch pairings between employees from different departments
- Mystery Lunch web application randomly selects employees from different departments every month to have lunch together.
- Application makes sure that each selected lunch partner belong to different department
- Application also makes sure that selected partners haven't had coffee together in last 3 months
- Admin can add or delete employees to the system
- When admin adds a new employee it will be added to exiting lunch partners pair (3 people lunch)
- When admin removes an employee it will be removed from future lunch and remaining partner would join an existing pair
- User can apply filters based on date & departments
- A rake task runs every month to generate random mystery lunch partners
mystery_lunch_app_demo.mp4
- User: Devise gem model for admin authentication
- Employee: To store employees data
- Department: To store department data
- MysteryPartners: Store randomly selected mystery partners e.g employees and their departments
ruby 2.7.7
Rails 6.1.7
docker-compose up --build
Postgresql
rake db:create
rake db:migrate
rake db:seed
rake mystery_partner_generator_task
Note: this rake task would be automatically schedule once every month using whenever gem & Sidekiq
Sidekiq schedule job MysteryLunchPartnerGeneratorWorker
Rspec
& FactoryBot
used to write the specs
Admin can create/delete employees and departments. Admin apart of the app is authenticated via devise gem
How algorithm works?
- Store employees in hash based on their departments
- Find available partner against each employee while removing partners which are from different department or already had lunch with that employee in last 3 months
- For odd number of employee, remaining partner is added existing lunch and pair
- In the end data is persisted into the DB
Time complexity O(n) <= O(e x d) where e is number of employee and d is the number of department