Changeset 11332 for websites/jwatch.jp

Show
Ignore:
Timestamp:
05/10/08 10:34:39 (6 years ago)
Author:
lopnor
Message:

websites/jwatch.jp: little more htmls.

Location:
websites/jwatch.jp/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • websites/jwatch.jp/trunk/lib/JWatch/Controller/Root.pm

    r11302 r11332  
    55use utf8; 
    66use base 'Catalyst::Controller'; 
     7use DateTime; 
    78 
    89# 
     
    3940 
    4041    my @list = $c->model('DBIC')->resultset('Event')->search( 
    41         {}, 
     42        { 
     43            datetime => { 'LIKE' => DateTime->now(time_zone => 'local')->ymd .'%' } 
     44        }, 
    4245        {  
    43             rows => 40,  
     46            rows => 10,  
    4447            order_by => 'datetime desc', 
    4548            join => 'game', 
     
    6467        ); 
    6568        my %score = map {( $_->clubid, $_->get_column('score') )} @score; 
    66         $event->{gamedesc} = join (' ', 
    67             $game->homeclub->shortname, 
    68             $score{$game->clubid_home} || '0', 
    69             '-', 
    70             $score{$game->clubid_away} || '0', 
    71             $game->awayclub->shortname, 
    72         ); 
     69        $event->{score}->{home} = $score{$game->clubid_home}; 
     70        $event->{score}->{away} = $score{$game->clubid_away}; 
    7371        $event->{referee} = $game->officials({type => 'referee'})->next; 
    7472        $event->{referee}->{shortname} = (split(' ', $event->{referee}->name))[0]; 
     
    8280                },{ 
    8381                    order_by => 'serialno desc', 
    84                     rows => 1, 
    8582                } 
    8683            )->name; 
    87             $event->{$player.'name'} = join ('', 
    88                 '#',$event->$player, 
    89                 (split(' ', $name))[0] 
    90             ); 
     84            $event->{$player."name"} = (split(' ', $name))[0]; 
    9185        } 
    9286    } 
    9387    $c->stash->{eventlist} = \@list; 
     88 
     89    my @gamelist = $c->model('DBIC')->resultset('Game')->search( 
     90        { 
     91            kickoff => { 'LIKE' => DateTime->now(time_zone => 'local')->ymd .'%' } 
     92        } 
     93    ); 
     94    for my $g (@gamelist) { 
     95        $g->{referee} = $g->officials({type => 'referee'})->next; 
     96        $g->{referee} or next; 
     97        $g->{referee}->{shortname} = (split(' ', $g->{referee}->name))[0]; 
     98    } 
     99    $c->stash->{gamelist} = \@gamelist; 
    94100    $c->stash->{template} = 'index.tt2'; 
    95101 
  • websites/jwatch.jp/trunk/misc/load_schedule_from_jsgoal.pl

    r11302 r11332  
    66use FindBin; 
    77use Web::Scraper; 
     8use DateTime; 
    89use DateTime::Format::Strptime; 
    9 use DateTime::Format::MySQL; 
    1010use YAML; 
    1111use URI; 
     
    2121my $clubs = $schema->resultset('Club'); 
    2222my $games = $schema->resultset('Game'); 
     23my $events = $schema->resultset('Event'); 
     24 
     25my $gamecount = $games->search_literal( 
     26    'now() > kickoff and '. 
     27    'now() < date_add(kickoff, interval 3 hour)' 
     28); 
     29$gamecount > 0 or exit 0; 
    2330 
    2431my $baseurl = 'http://www.jsgoal.jp'; 
     
    3845)) { 
    3946    for my $game (@{$scraper->scrape(URI->new_abs($uri, $baseurl))}) { 
    40         $games->update_or_create($game); 
     47        my $found = $games->find({id => $game->{id}}); 
     48        if ($found) { 
     49            if (! defined $found->score_home && defined $game->{score_home}) { 
     50                $events->create({ 
     51                        gameid => $game->{id}, 
     52                        type => 'end', 
     53                        datetime => DateTime->now(time_zone => 'Asia/Tokyo'), 
     54                    }); 
     55            } 
     56            $found->update($game); 
     57        } else { 
     58            $games->create($game); 
     59        } 
    4160    } 
    4261} 
     
    5978        result 'kickoff'; 
    6079    }->scrape(URI->new_abs($gameurl, $baseurl)); 
    61     $kickoff = DateTime::Format::MySQL->format_datetime( 
    62         $strp->parse_datetime($kickoff) 
    63     ); 
     80    $kickoff = $strp->parse_datetime($kickoff); 
    6481    my $clubid_home = $clubs->find({shortname => $cell[1]->as_text})->id; 
    6582    my $clubid_away = $clubs->find({shortname => $cell[3]->as_text})->id; 
  • websites/jwatch.jp/trunk/misc/update_game_from_jsgoal.pl

    r11302 r11332  
    3232my ($game,$gameid,$kickoff,$type,$playerhash); 
    3333 
    34 #for ($games->search_literal('now() > date_sub(kickoff, interval 2 hour) and now() < date_add(kickoff, interval 2 hour)')) { 
    35 for ($games->search_literal('kickoff > date_sub(now(),interval 2 day) and kickoff < now()')) { 
     34for ($games->search_literal('now() > date_sub(kickoff, interval 3 hour) and now() < date_add(kickoff, interval 3 hour)')) { 
    3635    $game = $_; 
    37     $gameid = $game->gameid; 
     36    $gameid = $game->id; 
    3837    (my $gameid_short = $gameid) =~ s{\d{8}$}{}; 
    3938    $kickoff = $game->kickoff; 
     
    5251            $game_officials->find_or_create($_); 
    5352        } 
    54 #        $game_players->create($_) for @{$res->{players}}; 
    55 #        $game_officials->create($_) for @{$res->{officials}}; 
    56         my $datetime = DateTime->from_epoch({epoch => $kickoff->epoch})->subtract(hours => 2); 
     53        my $datetime = DateTime->from_epoch({epoch => $kickoff->epoch}) 
     54            ->subtract(hours => 2); 
    5755        $events->find_or_create({ 
    5856                gameid => $gameid, 
    5957                type => 'member', 
    60                 datetime => $DateTime::Format::MySQL->format_datetime($datetime); 
     58                datetime => $datetime, 
    6159            }); 
    6260    } 
     
    164162    $type = ($cell[0]->as_text eq '主審') ? 'referee' : 'assistant'; 
    165163    my $officialid = $officials->search_literal("replace(name, ' ','') = ?", $cell[-1]->as_text)->next->officialid; 
     164    $officialid or return; 
    166165    return { 
    167166        gameid => $gameid, 
  • websites/jwatch.jp/trunk/root/src/index.tt2

    r11302 r11332  
     1[% META title = 'Jリーグ速報!jwatch.jp' %] 
    12[% FOREACH e IN eventlist %] 
    2 [% e.datetime %] [% e.gamedesc %] [% e.gametime %]分  
    3 [% IF e.type == 'goal' %][% e.club.shortname %][% e.player1name %]がゴール! 
    4 [% ELSIF e.type == 'change' %][% e.club.shortname %] 選手交代 IN: [% e.player1name %] -> OUT: [% e.player2name %] 
    5 [% ELSIF e.type == 'yellow' %][% e.referee.shortname %]が[% e.club.shortname %][% e.player1name %]にイエロー! 
    6 [% ELSIF e.type == 'red' %][% e.referee.shortname %]が[% e.club.shortname %][% e.player1name %]にレッド! 
     3■ [% e.datetime.hms %] [% e.game.homeclub.shortname %] [% e.score.home || 0 %] - [% e.score.away || 0 %] [% e.game.awayclub.shortname %] [% e.gametime %]min. <br> 
     4  [% IF e.type == 'goal' %]&#63671;[% e.club.shortname %][% e.player1name %]がゴール! 
     5[% ELSIF e.type == 'change' %][% e.club.shortname %]  OUT: [% e.player1name %] -> IN: [% e.player2name %] 
     6[% ELSIF e.type == 'yellow' %]<font color="yellow">■</font>[% e.referee.shortname %]が[% e.club.shortname %][% e.player1name %]にイエロー! 
     7[% ELSIF e.type == 'red' %]<font color="red">■</font>[% e.referee.shortname %]が[% e.club.shortname %][% e.player1name %]にレッド! 
    78[% ELSE %][% e.description %]に何かが! 
    89[% END %]<br> 
    910[% END %] 
     11<br> 
     12■ 今日の試合<br> 
     13[% FOREACH g IN gamelist %] 
     14[% g.homeclub.shortname %] vs [% g.awayclub.shortname %] [% g.referee.shortname %]<br> 
     15[% END %]