-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
-
-$dbh->do('SET client_min_messages TO WARNING');
-
-my $last_season = find_last_season($dbh);
-my @games = ();
-my %ids = ();
-fetch_games($dbh, $last_season, \@games, \%ids);
-my $tmpnam = output_to_file(\@games, \%ids);
-
-my @ratings = ();
-my @covariances = ();
-train_model($tmpnam, \@ratings, \@covariances);
-unlink($tmpnam);
-
-$dbh->do('TRUNCATE ratings');
-$dbh->do('COPY ratings ( id, rating, rating_stddev ) FROM STDIN');
-$dbh->pg_putcopydata(join("\n", @ratings));
-$dbh->pg_putcopyend();
+$dbh->{AutoCommit} = 1;
+
+my @locales = wloh_common::find_all_locales($dbh);
+my @filenames = ();
+
+for my $locale (@locales) {
+ my $last_season = find_last_season($dbh, $locale);
+ my @games = ();
+ my %ids = ();
+ fetch_games($dbh, $locale, $last_season, \@games, \%ids);
+ my $tmpnam = output_to_file($locale, \@games, \%ids);
+ push @filenames, $tmpnam;
+}