app/strategies/calendar_meeting_picker.rb
def pick_meetings_by_season( order = 'ASC', show_cancelled = true, current_user = nil )
    season_id = @parameters[:season_id]
    meetings_count = 0
    
    if season_id && season_id > 0
      # Create filter
      filters = "(season_id = #{season_id})"
      filters += " AND (header_date >= '#{@parameters[:date_start]}')" if @parameters[:date_start]
      filters += " AND (header_date <= '#{@parameters[:date_end]}')" if @parameters[:date_end]
      filters += ' AND (NOT is_cancelled)' if !show_cancelled

      # Verify managements
      team_affiliation_id = @manageable_seasons[season_id] if @manageable_seasons && @manageable_seasons.size > 0
      can_manage = !team_affiliation_id.nil?
      team_affiliation_id = @swimmer_badges[season_id] if team_affiliation_id.nil? && @swimmer_badges && @swimmer_badges.size > 0 
         
      Meeting
        .includes(meeting_sessions: [swimming_pool: [:city, :pool_type], meeting_events: [event_type: [:stroke_type]]], season: [:season_type])
        .where( "#{filters}" )
        .order( "meetings.header_date #{order}" )
        .each do |meeting|
          is_user_tagged = @user_tagged_meetings.include?(meeting.id)
          is_team_tagged = @team_tagged_meetings.include?(meeting.id)

          @calendarDAO.add_meeting( meeting, current_user, can_manage, team_affiliation_id, is_user_tagged, is_team_tagged )
          meetings_count += 1 
        end
    end    
    meetings_count
  end
# Pick meetings by season
# Meetings are those belngs to parameter season
#
Pick meetings by season
Meetings are those belngs to parameter season
Pick meetings by season Meetings are those belngs to parameter season
def pick_meetings_by_season( order = 'ASC', show_cancelled = true, current_user = nil )
    season_id = @parameters[:season_id]
    meetings_count = 0
    if season_id && season_id > 0
      filters = "(season_id = #{season_id})"
      filters += " AND (header_date >= '#{@parameters[:date_start]}')" if @parameters[:date_start]
      filters += " AND (header_date <= '#{@parameters[:date_end]}')" if @parameters[:date_end]
      filters += ' AND (NOT is_cancelled)' if !show_cancelled
      team_affiliation_id = @manageable_seasons[season_id] if @manageable_seasons && @manageable_seasons.size > 0
      can_manage = !team_affiliation_id.nil?
      team_affiliation_id = @swimmer_badges[season_id] if team_affiliation_id.nil? && @swimmer_badges && @swimmer_badges.size > 0 
      Meeting
        .includes(meeting_sessions: [swimming_pool: [:city, :pool_type], meeting_events: [event_type: [:stroke_type]]], season: [:season_type])
        .where( "#{filters}" )
        .order( "meetings.header_date #{order}" )
        .each do |meeting|
          is_user_tagged = @user_tagged_meetings.include?(meeting.id)
          is_team_tagged = @team_tagged_meetings.include?(meeting.id)
          @calendarDAO.add_meeting( meeting, current_user, can_manage, team_affiliation_id, is_user_tagged, is_team_tagged )
          meetings_count += 1 
        end
    end    
    meetings_count
  end
def pick_meetings_by_season ( order = 'ASC' , show_cancelled = true , current_user = nil ) season_id = @parameters [ :season_id ] meetings_count = 0 if season_id && season_id > 0 filters = "(season_id = #{season_id})" filters += " AND (header_date >= '#{@parameters[:date_start]}')" if @parameters [ :date_start ] filters += " AND (header_date <= '#{@parameters[:date_end]}')" if @parameters [ :date_end ] filters += ' AND (NOT is_cancelled)' if ! show_cancelled team_affiliation_id = @manageable_seasons [ season_id ] if @manageable_seasons && @manageable_seasons . size > 0 can_manage = ! team_affiliation_id . nil? team_affiliation_id = @swimmer_badges [ season_id ] if team_affiliation_id . nil? && @swimmer_badges && @swimmer_badges . size > 0 Meeting . includes ( meeting_sessions : [ swimming_pool : [ :city , :pool_type ] , meeting_events : [ event_type : [ :stroke_type ] ] ] , season : [ :season_type ] ) . where ( "#{filters}" ) . order ( "meetings.header_date #{order}" ) . each do | meeting | is_user_tagged = @user_tagged_meetings . include? ( meeting . id ) is_team_tagged = @team_tagged_meetings . include? ( meeting . id ) @calendarDAO . add_meeting ( meeting , current_user , can_manage , team_affiliation_id , is_user_tagged , is_team_tagged ) meetings_count += 1 end end meetings_count end
Pick meetings by season
Meetings are those belngs to parameter season
Pick meetings by season Meetings are those belngs to parameter season
# Create filter # Verify managements
order
show_cancelled
current_user