Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
switch from mysql to postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
FROGGS committed Nov 1, 2014
1 parent 00cc706 commit 3240e6e
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions app.pl
Expand Up @@ -8,10 +8,10 @@

Bailador::import;

DBIish.install_driver('mysql');
my $dbh = DBIish.connect('mysql',
:user<foo>, :password<bar>,
:host<localhost>, :port<3306>, :database<cpandatesters>
DBIish.install_driver('Pg');
my $dbh = DBIish.connect('Pg',
:user<cpandatesters>, :password<cpandatesters>,
:host<localhost>, :port<5432>, :database<cpandatesters>
);
my $host = '127.0.0.1';

Expand All @@ -29,9 +29,9 @@

get '/' | '/dists' => sub {
# TODO create a table `dists` and precalc its PASS ratio in a cronjob
my $sth = $dbh.prepare("SELECT DISTINCT `distname`, `distauth`
FROM `cpandatesters`.`reports`
ORDER BY `distname`");
my $sth = $dbh.prepare('SELECT DISTINCT distname, distauth
FROM reports
ORDER BY distname');
$sth.execute;
my $dist-lines = '';
while $sth.fetchrow_hashref -> $/ {
Expand All @@ -46,10 +46,10 @@
}

get /^ '/dist/' (.+) / => sub ($distname) {
my $sth = $dbh.prepare("SELECT `id`,`grade`,`distname`,`distauth`,`distver`,`compver`,`backend`,`osname`,`osver`,`arch`
FROM `cpandatesters`.`reports`
WHERE `distname`=?
ORDER BY `id` DESC");
my $sth = $dbh.prepare('SELECT id,grade,distname,distauth,distver,compver,backend,osname,osver,arch
FROM reports
WHERE distname=?
ORDER BY id DESC');
$sth.execute($distname);
my %reports;
my @osnames = <linux mswin32 darwin netbsd openbsd freebsd solaris>;
Expand Down Expand Up @@ -109,10 +109,10 @@
}

get '/recent' => sub {
my $sth = $dbh.prepare("SELECT `id`,`grade`,`distname`,`distauth`,`distver`,`compver`,`backend`,`osname`,`osver`,`arch`
FROM `cpandatesters`.`reports`
ORDER BY `id` DESC
LIMIT 100");
my $sth = $dbh.prepare('SELECT id,grade,distname,distauth,distver,compver,backend,osname,osver,arch
FROM reports
ORDER BY id DESC
LIMIT 100');
$sth.execute;
my @reports;
my @osnames = <linux mswin32 darwin netbsd openbsd freebsd solaris>;
Expand Down Expand Up @@ -170,9 +170,9 @@
}

get / '/report/' (.+) '/' (\d+) / => sub ($path, $id) {
my $sth = $dbh.prepare("SELECT *
FROM `cpandatesters`.`reports`
WHERE `id`=?");
my $sth = $dbh.prepare('SELECT *
FROM reports
WHERE id=?');
$sth.execute($id);
if $sth.fetchrow_hashref -> $r {
my @path = $path.Str.split('/');
Expand Down Expand Up @@ -202,9 +202,9 @@

post '/report' => sub {
my $report = from-json request.body;
my $sth = $dbh.prepare("INSERT INTO `cpandatesters`.`reports`
(`grade`,`distname`,`distauth`,`distver`,`compver`,`backend`,`osname`,`osver`,`arch`,`raw`)
VALUES (?,?,?,?,?,?,?,?,?,?)");
my $sth = $dbh.prepare('INSERT INTO reports
(grade,distname,distauth,distver,compver,backend,osname,osver,arch,"raw")
VALUES (?,?,?,?,?,?,?,?,?,?)');
$sth.execute(
$report<build-passed> && $report<test-passed> ?? 'PASS' !! 'FAIL',
$report<name>,
Expand Down

0 comments on commit 3240e6e

Please sign in to comment.