Re: [GENERAL] Schedule - Mailing list pgsql-general

From Adrian Klaver
Subject Re: [GENERAL] Schedule
Date
Msg-id 6690ed09-a63b-717f-c53c-35de3ab2b05d@aklaver.com
Whole thread Raw
In response to Re: [GENERAL] Schedule  (Steve Clark <steve.clark@netwolves.com>)
Responses Re: [GENERAL] Schedule
List pgsql-general
On 06/20/2017 08:12 AM, Steve Clark wrote:
> On 06/20/2017 10:38 AM, Adrian Klaver wrote:
>> On 06/20/2017 07:00 AM, Steve Clark wrote:

> We already have a monitoring system in place that has been in operation circa 2003. Just recently we have
> added a new class of customer whose operation is not 24/7.
>
> I envision the schedule could be fairly complicated
> including WE and holidays, plus the enduser might shut down for lunch etc. I am looking for more on how to organize
the
> schedule, EG a standard weekly schedule then exceptions for holidays etc, or a separate individual schedule for
> each week, also need to consider how easy it is to maintain the schedule, etc.

Yes this could be become complicated if for no other reason then it is
being driven from the customer end and there will need to be a process
to verify and incorporate their changes. I am going to wave my hand on
that part and proceed to the actual scheduling part. I have delved into
some of this for an yet unfinished timeclock/payroll project I peck away
at on occasion. Some thoughts from that project:

1) Settle on what a week is. ISO Monday(1) to Sunday(7) or non-ISO
Sunday(0) to Saturday(6)

2) Figure out what a day is. In other words are different timezones
involved and if so what do you 'anchor' a day to?

3) Figure out how to deal with schedules that cross Midnight. This might
come into play with holidays.

3) Create a parent table of default schedules. You could int4range as
day ranges. Assuming ISO week:

Weekend     '[6, 7]'::int4range
Weekday         '[1, 5]'::int4range

So in your monitoring determine day of week(dow) and look up schedule
for which dow falls in range.

4) Create child table to above that blocks out hours in schedule to
allow for lunch period, different start, stop hours.

5) Create holiday schedule that has date. When you determine dow in step
3) you will be using the date so you could look up to see it is a
holiday. This might tie into schedule table as I am not sure if there
are holiday schedules.

>
> Thanks,
> Steve
>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Melvin Davidson
Date:
Subject: Re: [GENERAL] Schedule
Next
From: Rory Campbell-Lange
Date:
Subject: Re: [GENERAL] Schedule