about summary refs log tree commit diff
path: root/lib/jitterbug
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-10-03 11:36:54 +0200
committerfranck cuny <franck@lumberjaph.net>2010-10-03 11:36:54 +0200
commit96c2d313ad30d649050116ef3f8878db45baa14a (patch)
tree59e0d627e39f787d0710063eab66943126abf9a3 /lib/jitterbug
parentupdate makefile (diff)
downloadjitterbug-96c2d313ad30d649050116ef3f8878db45baa14a.tar.gz
remove redis, use dbic instead
Diffstat (limited to 'lib/jitterbug')
-rw-r--r--lib/jitterbug/Plugin/Redis.pm25
-rw-r--r--lib/jitterbug/Schema/Result/Commit.pm29
-rw-r--r--lib/jitterbug/Schema/Result/Project.pm26
-rw-r--r--lib/jitterbug/Schema/Result/Task.pm29
4 files changed, 84 insertions, 25 deletions
diff --git a/lib/jitterbug/Plugin/Redis.pm b/lib/jitterbug/Plugin/Redis.pm
deleted file mode 100644
index 030475d..0000000
--- a/lib/jitterbug/Plugin/Redis.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-package jitterbug::Plugin::Redis;
-
-use Dancer::Config qw/setting/;
-use Dancer::Plugin;
-use Redis;
-
-register redis => sub {
-    Redis->new( server => setting('redis') );
-};
-
-sub _key {
-    my $s = setting('jitterbug');
-    my $ns = $s->{namespace} || 'jitterbug';
-    join( ':', $ns, @_ );
-}
-
-register key_projects       => sub { _key('projects'); };
-register key_project        => sub { _key('project', @_); };
-register key_builds_project => sub { _key('builds', @_); };
-register key_task_repo      => sub { _key('tasks', @_); };
-register key_tasks          => sub { _key('tasks'); };
-
-register_plugin;
-
-1;
diff --git a/lib/jitterbug/Schema/Result/Commit.pm b/lib/jitterbug/Schema/Result/Commit.pm
new file mode 100644
index 0000000..02387e1
--- /dev/null
+++ b/lib/jitterbug/Schema/Result/Commit.pm
@@ -0,0 +1,29 @@
+package jitterbug::Schema::Result::Commit;
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->load_components(qw/InflateColumn::DateTime/);
+
+__PACKAGE__->table('commit_push');
+__PACKAGE__->add_columns(
+    sha256 => {
+        data_type         => 'text',
+        is_auto_increment => 0,
+    },
+    content   => { data_type => 'text', },
+    projectid => {
+        data_type      => 'int',
+        is_foreign_key => 1,
+    },
+    timestamp => { data_type => 'datetime' },
+);
+__PACKAGE__->set_primary_key('sha256');
+__PACKAGE__->belongs_to(
+    project => 'jitterbug::Schema::Result::Project',
+    'projectid'
+);
+__PACKAGE__->has_many(
+    tasks => 'jitterbug::Schema::Result::Task',
+    'taskid',
+);
+
+1;
diff --git a/lib/jitterbug/Schema/Result/Project.pm b/lib/jitterbug/Schema/Result/Project.pm
new file mode 100644
index 0000000..245b54c
--- /dev/null
+++ b/lib/jitterbug/Schema/Result/Project.pm
@@ -0,0 +1,26 @@
+package jitterbug::Schema::Result::Project;
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('project');
+__PACKAGE__->add_columns(
+    projectid => {
+        data_type         => 'int',
+        is_auto_increment => 1,
+    },
+    name        => { data_type => 'text', },
+    url         => { data_type => 'text', },
+    description => { data_type => 'text', },
+    owner       => { data_type => 'text', }
+);
+__PACKAGE__->set_primary_key('projectid');
+__PACKAGE__->add_unique_constraint( [qw/name/] );
+__PACKAGE__->has_many(
+    commits => 'jitterbug::Schema::Result::Commit',
+    'sha256',
+);
+__PACKAGE__->has_many(
+    tasks => 'jitterbug::Schema::Result::Task',
+    'taskid',
+);
+
+1;
diff --git a/lib/jitterbug/Schema/Result/Task.pm b/lib/jitterbug/Schema/Result/Task.pm
new file mode 100644
index 0000000..e63e101
--- /dev/null
+++ b/lib/jitterbug/Schema/Result/Task.pm
@@ -0,0 +1,29 @@
+package jitterbug::Schema::Result::Task;
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('task');
+__PACKAGE__->add_columns(
+    taskid => {
+        data_type         => 'int',
+        is_auto_increment => 1,
+    },
+    sha256    => { data_type => 'text', is_foreign_key => 1 },
+    projectid => {
+        data_type      => 'int',
+        is_foreign_key => 1,
+    },
+);
+
+__PACKAGE__->set_primary_key('taskid');
+__PACKAGE__->add_unique_constraint( [qw/projectid/] );
+__PACKAGE__->add_unique_constraint( [qw/sha256/] );
+__PACKAGE__->belongs_to(
+    project => 'jitterbug::Schema::Result::Project',
+    'projectid'
+);
+__PACKAGE__->belongs_to(
+    commit => 'jitterbug::Schema::Result::Commit',
+    'sha256'
+);
+
+1;