My Issues

Hey Y'all,

Thanks so much for checking this out for me -- I really really appreciate it.  Please take your time -- I've got tons of areas to work in so I won't get held up at all.

Here's some of the things I sort of know intuitively could be improved but I don't know how to go about fixing:
  1) station.rb feels big, but I'm not sure where I'd put any of the methods except for where they are
  2) station.update_estimated_airtimes, make_log_current, and generate_playlist all step through the playlist in similar ways, but the way they modify the playlist is each so different I'm not sure how to refactor this code so it's not repeated.  I'm guessing it needs 'passed-blocks' or 'yields' but how to execute one this complicated is a little over my head.  No biggie though -- they all 3 work fine.
  3) station.rb and my database talk to each other -- a lot.   Especially in these:
            station -- generate_playlist, update_estimated_airtimes, make_log_current
            in_memory.db -- insert_spin

Anyways, I am obviously a beginner here (don't get me wrong... a pretty good beginner, but still a beginner) so if I'm missing some more glaring problems than these feel free to concentrate on whatever you think is important.

Anyways, thank you SO much!  I owe you many beers.

Talk to you soon,
-Brian

Milliseconds -- for editing purposes. They have to be converted to/from Time.—
Sent from Mailbox

On Fri, Jun 20, 2014 at 1:53 PM, Britt Ballard <notifications@github.com>
wrote:

>> @@ -293,7 +292,43 @@ def offset   # measurement of shift in end_time
>>        @original_playlist_end_time - self.end_time
>>      end
>>  
>> -    def adjust_offset
>> +    def adjust_offset(adjustment_date)  
>> +      offset = self.offset
>> +      current_playlist = PL.db.get_current_playlist(@id)
>> +      first_spin_after_3am = current_playlist.find_by { |spin| (spin.estimated_airtime.day == adjustment_date.day + 1) &&
>> +                                                                (spin.estimated_airtime.hour == 3) }
>> +
>> +      if offset < 0
>> +        # search for a song to add
>> +        closest_in_duration = @spins_per_week.keys.min_by { |id| (offset.abs - PL.db.get_spin(id).duration/1000).abs }
>> +
>> +        # if it's close enough to reduce the offset, add it
>> +        if (offset.abs - closest_in_length.duration/1000).abs < offset.abs
> What units are durations stored in?
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/briankeane/pl2/pull/1/files#r14035561