Class Timeslot
In: app/models/timeslot.rb
Parent: ActiveRecord::Base

Methods

Public Class methods

Produce a paginated list of timeslots, ordered by the absolute distance between their start_time and the current time.

It can take whatever parameters you would send to a WillPaginate#paginate call. Of course, you can specify a different ordering - in which case this would act as a normal paginator

Returns the paginated list of timeslots concurrent with the Time object passed as the first parameter - This means, those timeslots for which the current system clock is between tolerance_pre and tolerance_post. If either of them is not defined, we take the default values (see default_tolerance_pre, default_tolerance_post)

It can take whatever parameters you would send to a WillPaginate#paginate call. Of course, you can specify a different search criteria - in which case this would act as a normal paginator

Returns the paginated list of current timeslots - those for which attendance can be taken now.

It can take whatever parameters you would send to a WillPaginate#paginate call. Of course, you can specify a different search criteria - in which case this would act as a normal paginator

The systemwide default value for post-timeslot tolerance: Whatever is defined in SysConf for tolerance_post, or 30 minutes if not defined.

The systemwide default value for pre-timeslot tolerance: Whatever is defined in SysConf for tolerance_pre, or 30 minutes if not defined.

Returns a paginated list with all of the timeslots for the specified date, ordered by start time

There are many operations which want to get the current timeslot, in case there is only one - So, if there is only a single current timeslot, return it. If there is none (or there are more), return nil.

Public Instance methods

The time difference between now and the timeslot‘s start_time, returned as the number of seconds for its beginning (i.e. Ruby‘s natural interval representation).

The result will be negative for timeslots which have already begun.

An easier-on-the-eyes format…

The time difference between now and the timeslot‘s start_time, returned as a d+hh:mm:ss string (‘d+’ is the number of days - I could not find a more natural notation).

Intervals in Ruby are represented as a semi-opaque "thing" that becomes an integer number of seconds when needed… Treating them in any other way breaks applications. So, as soon as we get them, stringify them to something PostgreSQL will grok.

Intervals in Ruby are represented as a semi-opaque "thing" that becomes an integer number of seconds when needed… Treating them in any other way breaks applications. So, as soon as we get them, stringify them to something PostgreSQL will grok.

Protected Instance methods

Two timeslots are overlapping if they happen at the same room, and their tolerance periods overlap.

Evaluate for the future: Will we implement proposal types per timeslot? If so, we could manage timeslot duration and have a more complete and real timeslot overlapping checks… Meanwhile, here we go

The tolerance periods are just strings. However, they must make sense - So, we limit them to be hh:mm:ss.

Nil/blank is acceptable (i.e. it means "default value is OK")

[Validate]