Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: (OT) designing a "per event, resource schedule" manager

by Asim (Hermit)
on Aug 03, 2006 at 19:58 UTC ( [id://565541]=note: print w/replies, xml ) Need Help??


in reply to (OT) designing a "per event, resource schedule" manager

These are just thoughts; it's a project I plan to be working on soon, but have yet to work through the date collision details. However my thought is "use a range of numbers". Figure out your increments, and store the start and end times, along with an array of numbers that represent the times, likely in 24-hour format. For example --  my @hours = (13, 13.25, 13.5, 13.75, 14, 14.25, 14.5, 14.75, 15). Store the array in the DB in some fashion – I admit nothing excellent comes to mind, as a (var)char would have to be parsed, and a cross-reference table might just be overkill. Update2: Of course, it should be possible to auto-generate the numbers in Perl, each time you make the query I talk about next...benchmarking would help tell which approach is best.

At any rate, in Perl, do a SQL query that grabs that array, and also queries for any events whose end time is after your start time, or who's start time is before your end time. Iterate each row from the table against the New Event's array of times, and use something to figure out the Intersection of the two sets -- maybe Array::Compare? The Perl Cookbook also has a solution for this. Whatever matches, is a collision you’ll need to deal with.

This is a very naive solution, so I hope others can improve on it, or offer a different, more refined algorithm for this process. I do hope it helps, though, and if I do the project in question, I'll try to remember to come back and report on it!

Update: Upon relection, there's a module to interface to Google Calendar; it can do a lot of the scheduling for you, although I doubt I'll be able to use it for mine. I did some early work, prior to this module's release, on interfacing with GCal, and I found it rough, but do-able -- and it's been improved, I'm told, since those early days quite a bit.

----Asim, known to some as Woodrow.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://565541]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-26 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found