Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Fiat Tux
Hat softwares
Lutim
Commits
179def2d
Commit
179def2d
authored
May 20, 2017
by
Luc Didry
Browse files
Work on
#42
: cleanbdd command
This commit is dedicated to Schoumi, who is supporting me on Tipeee. Many thanks :-)
parent
0de43b74
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/Lutim/Command/cron/cleanbdd.pm
View file @
179def2d
package
Lutim::Command::cron::
cleanbdd
;
use
Mojo::
Base
'
Mojolicious::Command
';
use
LutimModel
;
use
Mojo::
Util
qw(slurp decode)
;
use
Lutim::DB::
Image
;
use
FindBin
qw($Bin)
;
use
File::
Spec
qw(catfile)
;
...
...
@@ -15,16 +14,15 @@ sub run {
file
=>
File::
Spec
->
catfile
(
$Bin
,
'
..
'
,'
lutim.conf
'),
default
=>
{
keep_ip_during
=>
365
,
dbtype
=>
'
sqlite
',
}
});
my
$separation
=
time
()
-
$config
->
{
keep_ip_during
}
*
86400
;
LutimModel
->
do
(
'
UPDATE lutim SET created_by = "" WHERE path IS NOT NULL AND created_at < ?
',
{},
$separation
);
my
$dbi
=
Lutim::DB::
Image
->
new
(
app
=>
$c
->
app
);
$dbi
->
clean_ips_until
(
$separation
);
}
=encoding utf8
...
...
lib/Lutim/Command/cron/cleanfiles.pm
View file @
179def2d
...
...
@@ -15,7 +15,7 @@ sub run {
my
$config
=
$c
->
app
->
plugin
('
Config
',
{
file
=>
File::
Spec
->
catfile
(
$Bin
,
'
..
'
,'
lutim.conf
'),
default
=>
{
dbtype
=>
'
sqlite
',
dbtype
=>
'
sqlite
',
}
});
...
...
lib/Lutim/DB/Image.pm
View file @
179def2d
...
...
@@ -129,6 +129,20 @@ sub to_hash {
};
}
=head2 clean_ips_until
=over 1
=item B<Usage> : C<$c-E<gt>clean_ips_until($time)>
=item B<Arguments> : unix timestamp
=item B<Purpose> : remove the image's sender information on images created before the given timestamp
=item B<Returns> : the db accessor object
=back
=head2 get_no_longer_viewed_files
=over 1
...
...
lib/Lutim/DB/Image/SQLite.pm
View file @
179def2d
...
...
@@ -13,6 +13,19 @@ sub new {
return
$c
;
}
sub
clean_ips_until
{
my
$c
=
shift
;
my
$time
=
shift
;
Lutim::DB::
SQLite
->
do
(
'
UPDATE lutim SET created_by = "" WHERE path IS NOT NULL AND created_at < ?
',
{},
$time
);
return
$c
;
}
sub
get_no_longer_viewed_files
{
my
$c
=
shift
;
my
$time
=
shift
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment