Guest User

Untitled

a guest
Feb 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. def gapcheck
  2. # season_id = params[ :season_id ]
  3. season_id = 60
  4. @missing_eps = []
  5.  
  6. @max_episode_number = Episode.maximum( :number, :conditions => ["season_id = ?", season_id] )
  7. @total_stored_eps = Episode.count( :id, :conditions => ["season_id = ?", season_id])
  8.  
  9. if ( @max_episode_number != @total_stored_eps )
  10. inc = 0;
  11. max = inc + 10;
  12. while ( inc < @total_stored_eps )
  13. set_episode_count = Episode.count( :id, :conditions => [ "season_id = ? and number > ? and number <= ?", season_id, inc, max ] )
  14. if ( set_episode_count != 10 )
  15. @eps = Episode.find( :all, :conditions => [ "season_id = ? and number > ? and number <= ?", season_id, inc, max ] )
  16. wanted_number = inc + 1
  17. total_eps = @eps.size
  18. current_index = 0
  19. ###################################
  20. while ( current_index < total_eps ) # causing server hand
  21. if ( wanted_number != @eps[current_index].number )
  22. @missing_eps << wanted_number;
  23. else
  24. current_index += 1
  25. end # number check condition
  26. wanted_number += 1
  27. end # end while loop
  28. #####################################
  29. end # set size if check
  30. inc = max
  31. max += 10
  32. end # end while inc les then stored eps while
  33. end # end max and epcount check
  34. end # end def
Add Comment
Please, Sign In to add comment