Foorum

 view release on metacpan or  search on metacpan

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

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
}
 
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

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
    $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

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
}
 
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

167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
    $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

230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
            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.245 second using v1.01-cache-2.11-cpan-a5abf4f5562 )