named_scope :open, lambda{|at_time| {:include => [:operation_hours],
:conditions => ["
# // FIRST OPEN TIMES DURNING THE PRESENT DAY
( operation_hours.open_time <= :compare_time
and operation_hours.close_time >= :compare_time
and operation_hours.open_day_id = :day_id
and operation_hours.close_day_id = :day_id
)
OR
# // OPEN PREVIOUS DAY AND EXTEND INTO THE EARLY MORNING
(
operation_hours.open_day_id = :day_id -1
and operation_hours.close_time >= :compare_time
and operation_hours.close_day_id = :day_id
)
# // FINALLY OPEN TILL LATE TOMORROW
OR
( operation_hours.open_day_id = :day_id
and operation_hours.open_time <= :compare_time
and operation_hours.close_day_id = :day_id +1
)
", {:day_id => OperationHour.parse(at_time)[0].to_i,
:compare_time => OperationHour.parse(at_time)[1]} ] }}
Thursday, August 5, 2010
Hours of operation aint that fun!
I geeked out for a while and worked on hours of operation named scope called 'open'.... This was a beeoych but in the end I kicked it's ass!
Monday, August 2, 2010
fulll circle geo/gis
So I have been geeking out with the Geo location stuff for about six months. So far I have played with mysql's geom//multi/poly/point and postgres multi poly/point...as well as lat/lng searching using geokit,
My inclination was to use Mysql as it is drop dead simple to set this stuff up...but it doesnt seem to work very well with GeoRuby or PostGIS. I think I read somewhere that Mysql can work with postgis but I couldn't get ita working.
So I tried Posgresql/PostGIS and I really liked it. Postgres as a database is pretty kick-ass and coming from a mostly mysql background I was pleasently suprised at the simplicity. Ok there are some subtle differences...
Then I started getting into using Sphinx with geo and ran into some wierd problems... It seems like a good idea but... I couldn't get it to work right. I even posted my problems on the group and didnt get a response (so far)...
I started having problems with postgres's ordering thru associations...wierd things started happening where it just wasnt sorting correctly....so to makw a long story short.. I just switched back to mysql as I am using geokit (lat/lng) for everything anyway... Lets see were this gets me!
My inclination was to use Mysql as it is drop dead simple to set this stuff up...but it doesnt seem to work very well with GeoRuby or PostGIS. I think I read somewhere that Mysql can work with postgis but I couldn't get ita working.
So I tried Posgresql/PostGIS and I really liked it. Postgres as a database is pretty kick-ass and coming from a mostly mysql background I was pleasently suprised at the simplicity. Ok there are some subtle differences...
Then I started getting into using Sphinx with geo and ran into some wierd problems... It seems like a good idea but... I couldn't get it to work right. I even posted my problems on the group and didnt get a response (so far)...
I started having problems with postgres's ordering thru associations...wierd things started happening where it just wasnt sorting correctly....so to makw a long story short.. I just switched back to mysql as I am using geokit (lat/lng) for everything anyway... Lets see were this gets me!
Subscribe to:
Posts (Atom)