Changeset 11302

Show
Ignore:
Timestamp:
05/09/08 21:40:47 (7 years ago)
Author:
lopnor
Message:

websites/jwatch.jp: start to make htmls.

Location:
websites/jwatch.jp/trunk
Files:
28 added
11 modified

Legend:

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

    r10949 r11302  
    1414#                 directory 
    1515 
    16 use Catalyst qw/-Debug ConfigLoader Static::Simple/; 
     16use Catalyst qw/ 
     17    -Debug  
     18    ConfigLoader  
     19    Static::Simple 
     20     
     21    Unicode 
     22    /; 
    1723 
    1824our $VERSION = '0.01'; 
  • websites/jwatch.jp/trunk/lib/JWatch/Controller/Root.pm

    r10949 r11302  
    33use strict; 
    44use warnings; 
     5use utf8; 
    56use base 'Catalyst::Controller'; 
    67 
     
    3435} 
    3536 
     37sub index : Private { 
     38    my ( $self, $c ) = @_; 
     39 
     40    my @list = $c->model('DBIC')->resultset('Event')->search( 
     41        {}, 
     42        {  
     43            rows => 40,  
     44            order_by => 'datetime desc', 
     45            join => 'game', 
     46        } 
     47    ); 
     48    for my $event (@list) { 
     49        my $game = $event->game; 
     50        my @score= $c->model('DBIC')->resultset('Event')->search( 
     51            { 
     52                gameid => $event->gameid, 
     53                gametime => { '<=' => $event->gametime }, 
     54                type => 'goal', 
     55            },  
     56            { 
     57                select => [ 
     58                    { count => 'clubid' }, 
     59                    'clubid', 
     60                ], 
     61                as => [qw(score clubid)], 
     62                group_by => 'clubid', 
     63            } 
     64        ); 
     65        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        ); 
     73        $event->{referee} = $game->officials({type => 'referee'})->next; 
     74        $event->{referee}->{shortname} = (split(' ', $event->{referee}->name))[0]; 
     75        for my $player (qw(player1 player2)) { 
     76            $event->$player or next; 
     77            my $name = $c->model('DBIC')->resultset('Player')->find( 
     78                { 
     79                    year => $game->kickoff->year, 
     80                    clubid => $event->clubid, 
     81                    number => $event->$player, 
     82                },{ 
     83                    order_by => 'serialno desc', 
     84                    rows => 1, 
     85                } 
     86            )->name; 
     87            $event->{$player.'name'} = join ('', 
     88                '#',$event->$player, 
     89                (split(' ', $name))[0] 
     90            ); 
     91        } 
     92    } 
     93    $c->stash->{eventlist} = \@list; 
     94    $c->stash->{template} = 'index.tt2'; 
     95 
     96} 
     97 
    3698=head2 end 
    3799 
  • websites/jwatch.jp/trunk/lib/JWatch/Schema.pm

    r11217 r11302  
    22 
    33use strict; 
    4 use base qw/DBIx::Class::Schema::Loader/; 
     4use warnings; 
    55 
    6 __PACKAGE__->loader_options( 
    7     relationships => 1, 
    8     # debug => 1, 
    9     components => [qw( 
    10         InflateColumn::DateTime 
    11     )], 
    12 ); 
     6use base 'DBIx::Class::Schema'; 
    137 
    14 =head1 NAME 
     8__PACKAGE__->load_classes; 
    159 
    16 JWatch::Schema - DBIx::Class::Schema::Loader class 
    1710 
    18 =head1 SYNOPSIS 
     11# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-05-09 19:54:05 
     12# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OgmUik4aXXMY1Ed5TMMoKw 
    1913 
    20 See L<JWatch> 
    2114 
    22 =head1 DESCRIPTION 
    23  
    24 Generated by L<Catalyst::Model::DBIC::Schema> for use in L<JWatch::Model::DBIC> 
    25  
    26 =head1 AUTHOR 
    27  
    28 A clever guy 
    29  
    30 =head1 LICENSE 
    31  
    32 This library is free software, you can redistribute it and/or modify 
    33 it under the same terms as Perl itself. 
    34  
    35 =cut 
    36  
     15# You can replace this text with custom content, and it will be preserved on regeneration 
    37161; 
    38  
  • websites/jwatch.jp/trunk/misc/jwatch_create.sql

    r11217 r11302  
    11-- vim: ft=mysql 
    22DROP DATABASE IF EXISTS jwatch; 
    3 CREATE DATABASE jwatch; 
     3CREATE DATABASE jwatch default character set utf8; 
    44 
    55use jwatch; 
    66create table `club` ( 
    7     clubid int not null default 0 primary key, 
     7    id int not null default 0 primary key, 
    88    shortname tinytext, 
    99    name tinytext, 
     
    2525 
    2626create table `official` ( 
    27     officialid tinyint not null auto_increment primary key, 
     27    id tinyint not null auto_increment primary key, 
    2828    name tinytext, 
    2929    name_i18n tinytext 
     
    3131 
    3232create table `stadium` ( 
    33     stadiumid int not null primary key, 
     33    id int not null primary key, 
    3434    name tinytext, 
    3535    name_i18n tinytext 
     
    3737 
    3838create table `game` ( 
    39     gameid decimal(20) not null default 0 primary key, 
     39    id char(20) not null default '' primary key, 
    4040    category tinyint, 
    4141    gameno tinyint, 
     
    4444    clubid_away int, 
    4545    stadiumid int, 
    46     score_home tinyint, 
    47     score_away tinyint 
     46    score_home tinyint default null, 
     47    score_away tinyint default null 
    4848); 
    4949 
    5050create table `game_player` ( 
    51     `gameid` decimal(20) not null default 0, 
     51    `gameid` char(20) not null default '', 
    5252    `clubid` int not null default 0, 
    5353    `number` tinyint not null default 0, 
     
    6060 
    6161create table `game_official` ( 
    62     gameid decimal(20) not null default 0, 
     62    gameid char(20) not null default '', 
    6363    officialid tinyint not null default 0, 
    6464    `type` enum('referee', 'assistant', 'fourth'), 
     
    6767 
    6868create table event ( 
    69     `eventid` int not null auto_increment primary key, 
    70     `gameid` decimal(20) not null default 0, 
     69    `id` int not null auto_increment primary key, 
     70    `gameid` char(20) not null default '', 
    7171    `gametime` tinyint not null default 0, 
    7272    `datetime` datetime, 
    73     `type` enum('goal', 'yellow', 'red', 'change', 'other'), 
     73    `type` enum('goal', 'yellow', 'red', 'change', 'other', 'member', 'end'), 
    7474    `clubid` int, 
    7575    `player1` tinyint, 
  • websites/jwatch.jp/trunk/misc/jwatch_fixdata.sql

    r11217 r11302  
     1use jwatch; 
    12update player set 
    23    name = '森崎 浩司' 
     
    2021    name = '高地 系治' 
    2122    where clubid = 44 and year = 2008 and number = 6; 
     23update player set 
     24    name = '楢崎 正剛' 
     25    where clubid = 8 and year = 2008 and number = 1; 
  • websites/jwatch.jp/trunk/misc/load_club_player_from_j.pl

    r11217 r11302  
    7171            my $res = $scraper->scrape(URI->new($memberurl)); 
    7272            return { 
    73                 clubid => int $clubid, 
     73                id => int $clubid, 
    7474                category => int $category, 
    7575                shortname => $shortname, 
  • websites/jwatch.jp/trunk/misc/load_game_from_jsgoal.pl

    r11217 r11302  
    3434for ($games->search({kickoff => {'<' => DateTime->now}})) { 
    3535    $game = $_; 
    36     $gameid = $game->gameid; 
     36    $gameid = $game->id; 
    3737    $kickoff = $game->kickoff; 
    3838    my $uri = URI->new( 
     
    128128    } 
    129129    if ($player1 eq 'オウンゴ−ル') { 
    130         $description = $player1; 
     130        $description = 'own goal'; 
    131131        $player1 = ''; 
    132132    } else { 
     
    149149    my @cell = $_->look_down(_tag => 'td'); 
    150150    $type = ($cell[0]->as_text eq '主審') ? 'referee' : 'assistant'; 
    151     my $officialid = $officials->find({name => $cell[-1]->as_text})->officialid; 
     151    my $officialid = $officials->find({name => $cell[-1]->as_text})->id; 
    152152    return { 
    153153        gameid => $gameid, 
  • websites/jwatch.jp/trunk/misc/load_official_from_j.pl

    r11217 r11302  
    3131            $name_i18n eq 'Name' and return; 
    3232            return { 
    33                 officialid => ++$officialid, 
     33                id => ++$officialid, 
    3434                name => $cell[1]->as_trimmed_text, 
    3535                name_i18n => $name_i18n, 
  • websites/jwatch.jp/trunk/misc/load_schedule_from_jsgoal.pl

    r11217 r11302  
    6262        $strp->parse_datetime($kickoff) 
    6363    ); 
    64     my $clubid_home = $clubs->find({shortname => $cell[1]->as_text})->clubid; 
    65     my $clubid_away = $clubs->find({shortname => $cell[3]->as_text})->clubid; 
     64    my $clubid_home = $clubs->find({shortname => $cell[1]->as_text})->id; 
     65    my $clubid_away = $clubs->find({shortname => $cell[3]->as_text})->id; 
    6666    my $stadiumlink = $cell[4]->look_down(_tag => 'a'); 
    6767    my $stadiumid = URI->new($stadiumlink->attr('href'))->query_param('s') if $stadiumlink; 
    6868    return { 
    69         gameid => $gameid || '', 
     69        id => $gameid || '', 
    7070        category => $category, 
    7171        gameno => $gameno, 
     
    7474        clubid_away => $clubid_away, 
    7575        stadiumid => $stadiumid || 0, 
    76         score_home => $score_home || 0, 
    77         score_away => $score_away || 0, 
     76        score_home => defined $score_home ? $score_home : undef, 
     77        score_away => defined $score_away ? $score_away : undef, 
    7878    }; 
    7979} 
  • websites/jwatch.jp/trunk/misc/load_stadium_from_jsgoal.pl

    r11217 r11302  
    2626        my $stadiumid = URI->new($a->attr('href'))->query_param('s'); 
    2727        return { 
    28             stadiumid => int $stadiumid, 
     28            id => int $stadiumid, 
    2929            name => $a->as_trimmed_text, 
    3030        }; 
  • websites/jwatch.jp/trunk/misc/update_player_from_j.pl

    r11217 r11302  
    2525for my $info (reverse @infolist) { 
    2626    my $date = delete $info->{date}; 
    27     my $clubid = $schema->resultset('Club')->find({name => $info->{clubname}})->clubid; 
     27    my $clubid = $schema->resultset('Club')->find({name => $info->{clubname}})->id; 
    2828    my $name; 
    2929    my $player = $schema->resultset('Player')->find(