schedule

package module
v0.0.0-...-824bf04 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2018 License: GPL-3.0 Imports: 11 Imported by: 0

README

Shift Scheduler

Build Status codecov Go Report Card GoDoc

Another way to simply schedule employee's shift using Go for the backend and React for the user interface

Usage

  1. Clone this repository git clone https://github.com/rrborja/shift-schedule
  2. Go to the cmd directory and run the shell script install.sh
  3. When you run the shell script, make sure you are in the current working directory of cmd
  4. Make sure the Node.js and Go runtime environments are installed in your system
  5. Once NPM installation is complete, you may access the page http://localhost:3000

API

  1. To retrieve the current shift
    • GET http://localhost:8080/MM/dd/yyyy
  2. To add the employee to the current shift
    • PUT http://localhost:8080/MM/dd/yyyy
    • The content type for the response body is JSON - name: name of the employee - id: id of the employee - start: 0-indexed exclusive start time of the employee - end: 0-indexed inclusive end time of the employee

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckNumber

func CheckNumber(num int, err error) int

CheckNumber is a checker if an error is returned by the string conversion library

func HttpRoutes

func HttpRoutes() http.Handler

HttpRoutes is the combination of all routes to expose the scheduling API to the web. The sole route /{month}/{day}/{year} has two methods:

  1. GET - To retrieve the list of all employees' shift given a certain shift date
  2. PUT - Creates a new employee shift to the list of all employee shifts assuming it doesn't overlap with the schedule.

func Interval

func Interval(shift *Shift) func() (start, end int)

Interval is the wrapper function that extract's the employee's shift time information into interval

func NoIOPermissionsPanic

func NoIOPermissionsPanic(err error)

NoIOPermissionsPanic is a checker if an error is returned by the File Handling library

func TimeToNumeric

func TimeToNumeric(hour int, minute int) int

TimeToNumeric converts hour and minute into the equivalent integer representation that serves as the order or index of a 24-hour pattern

Types

type DayRecord

type DayRecord struct {
	Month int
	Day   int
	Year  int
}

DayRecord is a struct that holds the Month, Day, and Year to form the basis of the name of the directory for later storage of all shifts. This struct contains methods that let's the user save the new employee's shift to the day shift in the DayRecord directory

func (DayRecord) ClockIn

func (dayRecord DayRecord) ClockIn(worker Employee, start, end int)

ClockIn clocks in the employee with the start and end time interval to the current shift day. This makes use of the scheduler's overlapping logic and the operations of the linked list used by the scheduler. When nothing overlaps, the employee shift information will be stored in a text file inside the directory that is named by the date of the shift in question.

func (DayRecord) String

func (dayRecord DayRecord) String() string

String is the string representation of the DayRecord struct

type Employee

type Employee struct {
	Name string
	Id   int
}

Employee is the struct for Employee having a name and an ID

type Shift

type Shift struct {
	Start int
	End   int

	Employee
	// contains filtered or unexported fields
}

Shift is the structure for the Shift of the employee. Start is the starting time of the employee inclusively while the End is the ending shift of the employee exclusively. This struct is the node of a doubly-linked list. The next node must be the next shift accordingly by time.

func Add

func Add(first *Shift, employee *Shift) (*Shift, bool)

Add adds the new employee to the day's shift's linked list and automatically validates any overlapping schedules and inserts according to the order of time

func Construct

func Construct(record DayRecord) *Shift

Construct is the construction of the linked list of all employees' shift from a certain shift day. This retrieves all text files in a certain directory named after the shift day in m.d.YYYY format

func (*Shift) Add

func (shift *Shift) Add(employee *Shift) bool

Add validates the correctness of employee's schedule to the current shift's list of all employees' schedule and adds to the shift if the new employee doesn't overlap any schedule of all employees

func (*Shift) Overlaps

func (shift *Shift) Overlaps(interval func() (int, int)) bool

Overlaps checks the interval whether it will not overlap to the current shifts schedule. Returns true if it overlaps. Returns otherwise.

type WorkerShift

type WorkerShift struct {
	Name  string `json:"name"`
	Id    int    `json:"id"`
	Start int    `json:"start"`
	End   int    `json:"end"`
}

WorkerShift is the json structure for the PUT REST route used to store the employee's shift in the storage, assuming no schedule overlapping occurs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL