-sub generate{
- my ($path, $lang) = @_;
- $path =~ s,/st\.html$,,;
- my $template = $templates{$lang};
- my $htc = HTML::Template::Compiled->new(scalarref => \$template);
- IO::File->new(">$path/meta.yml")->close unless -f "$path/meta.yml";
- flock my $metafh = IO::File->new("<$path/meta.yml"), LOCK_SH;
- my $meta = LoadFile "$path/meta.yml";
- my @problems = sort grep { /^\w+$/ } map { s,.*/,,r } <$path/../pb/*>;
- my %scores;
- for (1 .. $meta->{last}) {
- my $meta = LoadFile "$path/$_/meta.yml";
- if ($meta->{result_text} =~ m/^(\d+)/) {
- $scores{$meta->{user}}{$meta->{problem}} = $1;
- } else {
- $scores{$meta->{user}}{$meta->{problem}} = $meta->{result} ? 0 : 100;
- }
- }
+ my @problems = map { $_->problem } db($env)->contest_problems->search({contest => $ct && $ct->id}, {qw/join problem order_by problem.level/});
+ my (%scores, %tries);
+ for my $job (db($env)->jobs->search({contest => $ct && $ct->id}, {order_by => 'id'})) {