AnnoCPAN
view release on metacpan or search on metacpan
lib/AnnoCPAN/DBI.pm view on Meta::CPAN
}
sub path {
my (@pv) = shift->podvers;
return unless @pv;
$pv[0]->path; # take the first podver's path as representative
}
__PACKAGE__->set_sql(
pod_dist => "SELECT pod.id id, pod.name name FROM dist, pod, pod_dist
WHERE pod_dist.pod=pod.id AND pod_dist.dist=dist.id
AND pod.name=? AND dist.id=?");
__PACKAGE__->set_sql(
families => 'SELECT pod id, count(*) c FROM pod_dist GROUP BY id
HAVING c>1');
__PACKAGE__->set_sql(
by_author => "SELECT DISTINCT p.id, p.name
FROM pod p, distver dv, podver pv
WHERE dv.pause_id=? AND pv.distver=dv.id AND pv.pod=p.id");
sub count_notes {
my ($self) = @_;
return $self->sql_count_notes->select_val($self->id);
}
__PACKAGE__->set_sql(count_notes => 'SELECT count(*)
FROM note n
WHERE pod=?'
);
sub latest_note_date {
my ($self) = @_;
return $self->sql_latest_note_date->select_val($self->id);
}
__PACKAGE__->set_sql(latest_note_date => 'SELECT time
FROM note n
WHERE pod=?
ORDER BY time DESC
LIMIT 1'
);
sub join_pods {
my ($self, @others) = @_;
my (@notes) = map { $_->notes } (@others);
my (@podvers) = map { $_->podvers } (@others);
my (@pod_dists) = map { $_->pod_dists } (@others);
# steal the notes and podvers
for my $child (@notes, @podvers, @pod_dists) {
$child->pod($self);
$child->update;
}
# union of all the notes/podvers
push @notes, $self->notes;
push @podvers, $self->podvers;
# boldly translate the notes to where they have never been before
for my $note (@notes) {
for my $podver (@podvers) {
my ($np) = AnnoCPAN::DBI::NotePos->search_podver_note(
$podver, $note);
unless ($np) {
$note->guess_section($podver);
}
}
}
# delete the other pods
$_->delete for @others;
$self;
}
=head2 AnnoCPAN::DBI::PodDist
Links a pod with a dist (its a many-to-many relationship).
Columns:
id
dist
pod
=cut
package AnnoCPAN::DBI::PodDist;
use base 'AnnoCPAN::DBI';
__PACKAGE__->table('pod_dist');
__PACKAGE__->columns(Essential => qw(id dist pod));
__PACKAGE__->has_a(dist => 'AnnoCPAN::DBI::Dist');
__PACKAGE__->has_a(pod => 'AnnoCPAN::DBI::Pod');
sub notes { return shift->pod->notes }
sub podvers { return shift->pod->podvers }
=head2 AnnoCPAN::DBI::DistVer
Represents a specific version of a distribution
Columns:
id
dist
version
path
pause_id
distver
mtime
=cut
package AnnoCPAN::DBI::DistVer;
use base 'AnnoCPAN::DBI';
__PACKAGE__->table('distver');
__PACKAGE__->columns(Essential => qw(id dist version path pause_id
distver mtime maturity));
__PACKAGE__->has_a(dist => 'AnnoCPAN::DBI::Dist');
( run in 0.483 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )