Creating an employee schedule - javascript

I need help in how to think about creating a work schedule. Each employee needs x amount of shifts, x amount of weekends, and can't work back to back. There are other rules I would build in, like employee requests, holidays etc
I am thinking of approaching it such that I would create every possible schedule and weigh them based on a set of rules.
However, with 14 shifts and 34 employees, the number of possible schedules for a give 2 month block would be astronomical.
Should I use a specific library for this?
is this something Javascript can handle?
Other Thoughts?
Thanks

Request is waaaay too big, fill in a few variables (ie. amount of shifts/amount of weekends) otherwise you're going to waste so much time going through possibilities (1,391,975,640) that it would be futile. Additionally, you could save time by adding a maximum and minimum shift time, and a maximum and minimum weekend time. Once you fill in those variables, you can use Google Sheets or Excel to create a quick employee schedule. Additionally, adding a quick formula to account for requested time off can be added to a new field.

Related

Javascript/CSS: create graph animation based on data changing in time

Don't ask me why but I made up my mind to create an animation of a graph like the one you see in this video with Javascript
https://www.youtube.com/watch?v=FJi5LcWpznw
My data are similar to
2023-01-01 user1,10 user2,12
2023-01-02 user1,11 user2,12 user3,1
2023-01-03 user1,11 user2,14 user3,12 user4,5
and so on .. day by day
Can you help me to convert my madness into all this?
Thanks in advance
You're going to need more data, otherwise your video is going to only have three states in it...
I'd start by creating a static graphic, using your favorite JavaScript charting library (https://www.chartjs.org/?) I'd store all this data in a day-sorted array. After you get that working, then I'd come up with a mapping between days and seconds. For a very limited number of days, I'd probably do something like 1 day = 3 seconds. Then, I'd create an event loop, and every three seconds, pick out the next datapoint from the array, and update the graphics. After that point, you need to record your browser.
You'd better update your question quickly before the stackoverflow admins reject it for one of their many, many, many reasons and edit my response into oblivion.

How to dynamically change a field depending on a unique date formula

I'm working on a work schedule of sorts, a feature that I'm trying to create would be one that can be setup initial and would not need to be touched ever again. However I'm not sure where to even start; I have a weekly schedule with three different fields, a middle field that is unique and requires no attention and a day/night field. My user is able to drag users into these fields and set that they are expected to working during that period. However as my user has different shifts that sometimes overlap I'm looking to color code each of the shifts of which there is a total of five, the shifts go on a pattern of working: 2 nights, than 2 days off, than 3 days working and lastly than 2 days off. What would be the best approach of mapping this as I cannot simply put that Monday nights are color X as the by the time next weeks comes around the shift would be starting on Wednesday, along side this some shifts will be working at the same time so the color coding should not cover the entire day but only a limited number of entries (2). My initial idea was to try using Hashmap or something of the sort but I'm uncertain how I would structure it to achieve what I'm looking for..
Drag and drop experience would be nice but I assume not mandatory, so can try to use standard features. Im not sure which user is using this - the worker doing the shift, or a manager allocating workers to the shifts? If is for a manager - If you created a 'shift' object and had shifts represented as records you'd be able to create list views of those shifts ie. 'next n days','this month' etc. Then you could use bulk action within the list view to assign a user to multiple shift records at a time. Would be reasonably efficient and quick to build. Just a thought... (and I couldnt follow what you meant about color coding sorry.)

Find the point where maximum intervals overlap for certain interval length

I'm trying to maximize attendance to a event given a list of busy times for each person. The event can be scheduled anytime between a certain date and hours (Ex. March 1st to March 8th from 9-5) and that attendance is maximized.
So far I've tried using a sliding window approach, and a counting approach described here (https://www.geeksforgeeks.org/find-the-point-where-maximum-intervals-overlap/) however I only managed to get the sliding window approach working with a time complexity of O(n^3) which unfortunately is not good enough for my use case. The counting approach does not work because I can find the maximum interval but not for a certain timeframe.
A worst case scenario use case would be ~500 people and a month timespan.
Any help would be much appreciated.
Solved using a Interval Tree (https://en.wikipedia.org/wiki/Interval_tree)

Change the real time into a given span of time, with jquery, mysql and/or php

I'm working on an RPG chat coded in old php-mysql and javascript (at the time there was no jquery), and the playing story is about vampires (not a twilight style, I assure you :P).
And I need to set a time watch visible, that doesn't have the real time, but only a night time, extended throughout all day.
For example, at real time 6 AM, must correspond a in-game time of 20PM, and so on, until a real time 5:59AM, which must correspond to a in-game time of 5AM.
So that through the whole real-life day, the in game time span goes only from 20PM to 5AM, only the night, in short.
Is it possible? It's ok to use php and mysql, or even jquery or javascript (even though I think it would be easier done with the last two).
PHP writing is in the old procedural style, not object oriented, just to specify.
Thanks for the replies!
Interesting problem. I would think the algorithm would go something like this:
Calculate what percentage of an actual day has passed.
Use that to calculate how much time has passed in a virtual day (multiply times 32400 to get the number of seconds, probably).
Add that number of seconds to a date object that has been set to 20:00PM on today's date.

Charting sporadic events over time on Highcharts (Dynamic Precision?)

How would you chart something like pageviews over time using Highcharts?
Given that page views take place at sporadic irregular intervals, how could you chart this as accurately and legibly as possible?
One way is to group pageviews into time intervals (like days), and then sum up all pageviews on any given day.
The obvious issue here is that if you are only looking at data for a few days, the intervals are too large, and the data fits basically into a few buckets (not really showing any trends).
Another solution I thought of is to have a minimum interval (say, 7 steps) and when less than 7 days of data are requested, (say 3) I could divide that time period into 7 intervals.
However this seems like too much fuss, especially on the backend, for the purpose of simply showing data.
Given that the underlying data does not change, only the manner in which it's rendered, I figured there must be a general solution to this problem.
It depends on what you are trying to discover in the data. If you want to compare it with another data set then use the same scheme it does ("pageviews per day" or whatever). If you want to spot trends over time you need to decide on your horizon and use an appropriate time period (so, for example, if you are trying to justify the purchase of a larger server then perhaps quarterly data comparing this year to last would be good). Designing visualizations for datasets is a huge topic.
So, in other words, I think you pretty much answered your own question.
It looks like the answer is forced Data Grouping
http://api.highcharts.com/highstock/#plotOptions.series.dataGrouping
forced: Boolean
When data grouping is forced, it runs no matter how small the
intervals are. This can be handy for example when the sum should be
calculated for values appearing at random times within each hour.
Defaults to false.
I'll try this and see if it works well
This could work for highstock, but it's not part of highcharts...

Categories

Resources