Foorum

 view release on metacpan or  search on metacpan

lib/Foorum/ResultSet/Forum.pm  view on Meta::CPAN

}

sub get_forum_url {
    my ( $self, $forum ) = @_;

    my $forum_url = '/forum/' . $forum->{forum_code};

    return $forum_url;
}

sub update_forum {
    my ( $self, $forum_id, $update ) = @_;

    my $schema = $self->result_source->schema;
    my $cache  = $schema->cache();

    $self->search( { forum_id => $forum_id } )->update($update);

    $cache->remove("forum|forum_id=$forum_id");

    if ( $update->{forum_code} ) {

lib/Foorum/ResultSet/Topic.pm  view on Meta::CPAN

    $schema->resultset('User')->update_user(
        $user,
        {   threads => \'threads + 1',
            point   => \'point + 2',
        }
    );

    return $topic;
}

sub update_topic {
    my ( $self, $topic_id, $update ) = @_;

    my $schema = $self->result_source->schema;
    my $cache  = $schema->cache();

    $self->search( { topic_id => $topic_id } )->update($update);

    $cache->remove("topic|topic_id=$topic_id");
}

lib/Foorum/ResultSet/User.pm  view on Meta::CPAN

}

sub delete_cache_by_user_cond {
    my ( $self, $cond ) = @_;

    my $user = $self->get($cond);
    $self->delete_cache_by_user($user);
}

# call this update will delete cache.
sub update_user {
    my ( $self, $user, $update ) = @_;

    $self->delete_cache_by_user($user);
    $self->search( { user_id => $user->{user_id} } )->update($update);
}

# update threads and replies count
sub update_threads_and_replies {
    my ( $self, $user ) = @_;

    my $schema = $self->result_source->schema;

    # get $threads + $replies
    my $total = $schema->resultset('Comment')->count(
        {   author_id   => $user->{user_id},
            object_type => 'topic',
        }
    );

lib/Foorum/TheSchwartz/Worker/Scraper.pm  view on Meta::CPAN


    $name = substr( $name, 0, 24 );
    my $rs = $schema->resultset('Variables')->search(
        {   type => 'log',
            name => $name
        }
    )->first;
    return $rs ? $rs->value : 0;
}

sub update_last_scraped_msg_id {
    my ( $schema, $name, $value ) = @_;

    $name = substr( $name, 0, 24 );
    $schema->resultset('Variables')->search(
        {   type => 'log',
            name => $name,
        }
    )->delete;
    $schema->resultset('Variables')->create(
        {   type  => 'log',

lib/Foorum/TheSchwartz/Worker/Scraper.pm  view on Meta::CPAN

            author_id        => $user_id,
            last_updator_id  => $user_id,
            last_update_date => time(),
            hit              => 0,
            total_replies    => $replies_no
        }
    );
    return ( $new_topic->topic_id, 0 );
}

sub update_forum {
    my ( $schema, $cache, $forum_id, $last_post_id ) = @_;

    my $forum
        = $schema->resultset('Forum')->count( { forum_id => $forum_id } );
    return unless ($forum);

    # update forum
    $schema->resultset('Forum')->search( { forum_id => $forum_id, } )
        ->update( { last_post_id => $last_post_id || 0, } );



( run in 0.255 second using v1.01-cache-2.11-cpan-a5abf4f5562 )