Skip to content

Latest commit

 

History

History
77 lines (75 loc) · 2.62 KB

README.md

File metadata and controls

77 lines (75 loc) · 2.62 KB

LeaveManagement


Problem Statement

Company XYZ is managing its leave module by maintaining 2 CSV files in their "Leaves" directory

  • EmployeeData.csv
  • Leaves.csv
Employees' data present in EmployeeData.csv file in below format -
empIdnameleavesTakenavailableLeaves
1Mayank218
2Keyur515
3Rahim182

An employee can apply for leave by adding an entry in the Leaves.csv file in below format.
empIdappliedLeaves
14
23

The program will initially read data from the EmployeeData.csv file and continuously monitor Leaves.csv.
When any employee has applied for leaves then perform below operations every minute - The program will initially read data from the EmployeeData.csv file and continuously monitor Leaves.csv.
When any employee has applied for leaves then perform below operations every minute -
  1. Check whether the employee is eligible for the leave(s) or not based on available Leaves value
    1. If the employee is eligible for the leave then print in the console: <name> is eligible for the leave.
    2. If the employee is not eligible for the leave then print in the console: <name> is not eligible for the leave.
  2. if the employee is eligible for the leave, then remove the entry from Leaves.csv and update the "leavesTaken" and "available Leaves" in EmployeeData.csv.
  3. If the employee is not eligible for the leave then remove the entry from Leaves.csv.

Solution Approach

Keywords
Approach
  • Application must schedule on time frequency
  • Application should not create new CSV files, must be use old file and update if needed
Algorithm
  • Create a cron job to run program after time frequency
  • First read the Leaves.csv if any leave application found then read the EmployeeData.csv else skip the processing
  • Schedule frequency should be user configurable.