Foorum
view release on metacpan or search on metacpan
lib/Foorum/ResultSet/Forum.pm view on Meta::CPAN
676869707172737475767778798081828384858687}
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
93949596979899100101102103104105106107108109110111112
$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
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169}
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
167168169170171172173174175176177178179180181182183184185186187
$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
230231232233234235236237238239240241242243244245246247248249
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 )