App-Chronicle

 view release on metacpan or  search on metacpan

lib/Chronicle/Plugin/Generate/Archive.pm  view on Meta::CPAN

    my $dbh    = $args{ 'dbh' };
    my $config = $args{ 'config' };

    #
    #  Date-record
    #
    my %hash;
    my %index;

    my $all = $dbh->prepare(
         "SELECT strftime( '%m %Y', date, 'unixepoch') FROM blog ORDER BY date")
      or
      die "Failed to prepare";


    $all->execute() or die "Failed to execute:" . $dbh->errstr();
    my $dt;
    $all->bind_columns( undef, \$dt );

    while ( $all->fetch() )
    {

lib/Chronicle/Plugin/Generate/Archive.pm  view on Meta::CPAN

    {
        my $datelang = Date::Language->new( $ENV{ 'MONTHS' } // "English" );
        my $mon      = "";
        my $year     = "";
        if ( $ym =~ /^([0-9]+) ([0-9]+)$/ )
        {
            $mon  = $1;
            $year = $2;
        }
        my $ids = $dbh->prepare(
            "SELECT id FROM blog WHERE strftime( '%m %Y', date, 'unixepoch') = ? ORDER BY date DESC"
          ) or
          die "Failed to prepare";

        $ids->execute($ym) or die "Failed to execute:" . $dbh->errstr();

        my $id;
        $ids->bind_columns( undef, \$id );

        my $ym_archive_path = "$config->{'output'}/archive/$year/$mon";

lib/Chronicle/Plugin/Snippets/Archives.pm  view on Meta::CPAN

    {
        my $tmp;

        foreach my $mon ( $self->_months_in_year( $dbh, $year ) )
        {

            #
            #  We have a year and a month.
            #
            my $sql = $dbh->prepare(
                "SELECT count(id) FROM blog WHERE ( strftime('%Y', date, 'unixepoch')=? AND strftime('%m', date, 'unixepoch') =? )"
              ) or
              die "Failed to prepare query";

            $sql->execute( $year, $mon );
            my $count = $sql->fetchrow_array();

            push @$tmp,
              { count      => $count,
                month      => $mon,
                month_name => decode( 'ISO-8859-1',

lib/Chronicle/Plugin/Snippets/Archives.pm  view on Meta::CPAN

sub _years
{
    my ( $self, $dbh ) = (@_);

    my @results;

    #
    #  Find each year.
    #
    my $years = $dbh->prepare(
        "SELECT DISTINCT(strftime( '%Y', date, 'unixepoch')) FROM blog ORDER BY strftime( '%s', date, 'unixepoch' ) DESC"
      ) or
      die "Failed to prepare query";

    $years->execute() or die "Failed to execute:" . $dbh->errstr();
    my $year;
    $years->bind_columns( undef, \$year );


    while ( $years->fetch() )
    {

lib/Chronicle/Plugin/Snippets/Archives.pm  view on Meta::CPAN

sub _months_in_year
{
    my ( $self, $dbh, $year ) = (@_);

    my @results;

    #
    #  Find each year.
    #
    my $s = $dbh->prepare(
        "SELECT DISTINCT(strftime( '%m', date, 'unixepoch')) FROM blog WHERE (strftime('%Y',date,'unixepoch') = ?) ORDER BY strftime( '%s', date, 'unixepoch' ) DESC"
      ) or
      die "Failed to prepare query";

    $s->execute($year) or die "Failed to execute:" . $dbh->errstr();
    my $mon;
    $s->bind_columns( undef, \$mon );

    while ( $s->fetch() )
    {
        push( @results, $mon );



( run in 1.388 second using v1.01-cache-2.11-cpan-64ef6c95b5d )