# encoding: utf-8 #################################################################### # generiert am <%= Time.now %> # using <%= SportDB.banner %> #################################################################### ########################################### # <%= event.title %> <%# todo: use proper key from event for variable e.g. pl or similar (strip season, etc.) %> ev = Event.find_by_key!( '<%= event.key %>' ) <% event.teams.each do |team| %> <%= '%-18s' % team.key %> = Team.find_by_key!( '<%= team.key %>' ) <% end %> <% event.rounds.each do |round| %> <%= 'r%02d' % round.pos %> = Round.create!( event: ev, pos: <%= round.pos %>, title: '<%= round.title %>', start_at: Time.utc('<%= round.start_at.strftime('%Y-%m-%d %H:%M') %>')) <% end %> <% event.rounds.each do |round| %> <%= 'games%02d' % round.pos %> = [ <% round.games.each_with_index do |game| %> [ <%= '%-18s' % "#{game.team1.key}," %> [<%= "#{game.score1},#{game.score2}" if game.score1.present? && game.score2.present? %>], <%= '%-18s' % "#{game.team2.key}," %> Time.utc('<%= game.play_at.strftime('%Y-%m-%d %H:%M') %>') ], <%# does comma for last entry matter? ruby ignores it for sure? check %> <% end %> ] <% end %> <% event.rounds.each do |round| %> Game.create_from_ary!( <%= 'games%02d' % round.pos %>, <%= 'r%02d' % round.pos %> ) <% end %> <%# todo: what to put for value??? %> Prop.create!( key: 'db.<%= event.key %>.fixtures.version', value: '1' )