diff --git a/lib/Act/Data.pm b/lib/Act/Data.pm index 3e2cf686e..4a77a5e08 100644 --- a/lib/Act/Data.pm +++ b/lib/Act/Data.pm @@ -475,6 +475,23 @@ sub fetch_orders ($order_id) { } +# ---------------------------------------------------------------------- +# From Act::Talk +# Another two subroutines which don't pass a conference because they +# refer to talks, which are associated with a conference. +sub delete_talk_attendance ($talk_id) { + sql('DELETE FROM user_talks WHERE talk_id=?', $talk_id); +} + +sub talk_stars ($talk_id) { + my $sth = sql('SELECT COUNT(*) FROM user_talks' + . ' WHERE talk_id=?', $talk_id); + my ($count) = $sth->fetchrow_array(); + $sth->finish; + return $count || 0; +} + + # ---------------------------------------------------------------------- # Fetch the database handler sub dbh { @@ -743,6 +760,15 @@ which is mapped to C<'t'> or C<'f'>. Returns an array reference holding hash references for each of the orders. +=head3 Act::Data::delete_talk_attendance ($talk_id) + +Removes information about a talk's attendance (before deleting the +talk itself). + +=head3 $count = Act::Data::talk_stars($talk_id) + +Returns the number of stars for a talk given by its ID. + =head1 CAVEATS The Act test suite doesn't exercise all of these functions. This is bad. diff --git a/lib/Act/Talk.pm b/lib/Act/Talk.pm index 325e5c5b2..bcb71a521 100644 --- a/lib/Act/Talk.pm +++ b/lib/Act/Talk.pm @@ -1,5 +1,6 @@ package Act::Talk; use Act::Config; +use Act::Data; use Act::Object; use base qw( Act::Object ); @@ -32,7 +33,7 @@ our %sql_opts = ( 'order by' => 'talk_id' ); sub delete { my ($self, %args) = @_; - sql('DELETE FROM user_talks WHERE talk_id=?', $self->talk_id); + Act::Data::delete_talk_attendance($self->talk_id); $self->SUPER::delete(%args); $Request{dbh}->commit; @@ -40,10 +41,7 @@ sub delete { sub stars { my ($self, %args) = @_; - my $sth = sql('SELECT COUNT(*) FROM user_talks WHERE talk_id=?', $self->talk_id); - my ($count) = $sth->fetchrow_array(); - $sth->finish; - return $count || 0; + return Act::Data::talk_stars($self->talk_id); } =head1 NAME