From be6ff3e9dba11b13b715fa2f4930718489aa7bca Mon Sep 17 00:00:00 2001 From: Ian Docherty Date: Tue, 11 Dec 2012 10:21:26 -0500 Subject: [PATCH] Started to add beanstalk --- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 20 ++++++++++---------- lib/Lacuna/DB/Result/Schedule.pm | 5 ++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 76b9f371..2821fded 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -1325,12 +1325,12 @@ sub tick { } @{$self->building_cache}; foreach my $building (@buildings) { - if ($building->is_upgrading && $building->upgrade_ends->epoch <= $now_epoch) { - $todo{format_date($building->upgrade_ends).$i} = { - object => $building, - type => 'building upgraded', - }; - } +# if ($building->is_upgrading && $building->upgrade_ends->epoch <= $now_epoch) { +# $todo{format_date($building->upgrade_ends).$i} = { +# object => $building, +# type => 'building upgraded', +# }; +# } if ($building->is_working && $building->work_ends->epoch <= $now_epoch) { $todo{format_date($building->work_ends).$i} = { object => $building, @@ -1377,10 +1377,10 @@ sub tick { $self->tick_to($object->work_ends); $object->finish_work->update; } - elsif ($job eq 'building upgraded') { - $self->tick_to($object->upgrade_ends); - $object->finish_upgrade; - } +# elsif ($job eq 'building upgraded') { +# $self->tick_to($object->upgrade_ends); +# $object->finish_upgrade; +# } } # check / clear boosts diff --git a/lib/Lacuna/DB/Result/Schedule.pm b/lib/Lacuna/DB/Result/Schedule.pm index 3cbcf719..7a7fbabc 100644 --- a/lib/Lacuna/DB/Result/Schedule.pm +++ b/lib/Lacuna/DB/Result/Schedule.pm @@ -11,6 +11,7 @@ use Data::Dumper; __PACKAGE__->table('schedule'); __PACKAGE__->add_columns( queue => {data_type => 'varchar', size => 30, is_nullable => 0}, + job_id => {data_type => 'int', size => 11, is_nullable => 0}, delivery => {data_type => 'datetime', is_nullable => 0}, priority => {data_type => 'int', size => 11, is_nullable => 0, default => 1000}, parent_table => {data_type => 'varchar', size => 30, is_nullable => 0}, @@ -44,7 +45,7 @@ sub queue_for_delivery { my $queue = Lacuna->queue || 'default'; my $priority = $self->priority || 1000; - $queue->publish($self->queue, + my $job = $queue->publish($self->queue, { id => $self->id, parent_table => $self->parent_table, @@ -56,6 +57,8 @@ sub queue_for_delivery { priority => $priority, } ); + $self->job_id($job->id); + $self->update; } no Moose; -- 2.51.2