source: server/trunk/web/lib/Sophie/Controller/Admin/Update.pm @ 422

Last change on this file since 422 was 419, checked in by nanardon, 13 years ago
  • various fixes
File size: 2.0 KB
Line 
1package Sophie::Controller::Admin::Update;
2use Moose;
3use namespace::autoclean;
4
5BEGIN {extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9Sophie::Controller::Admin::Update - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19sub paths :XMLRPC {
20    my ($self, $c) = @_;
21
22    return $c->stash->{xmlrpc} = [
23    map { 
24        { 
25        path => $_->get_column('path'),
26        id   => $_->get_column('d_path_key'),
27        } 
28    } $c->model('Base')->resultset('Paths')->search(
29        {},
30        {
31            select => [ qw(path d_path_key) ],
32        }
33    )->all ]
34}
35
36sub paths_to_update : XMLRPC {
37    my ($self, $c) = @_;
38
39    return $c->stash->{xmlrpc} = [
40    map { 
41        { 
42        path => $_->get_column('path'),
43        id   => $_->get_column('d_path_key'),
44        } 
45    } $c->model('Base')->resultset('Paths')->search(
46        {
47            -or => [
48                { updated => [ 
49                    undef,
50                    \[ " < now() - '24 hours'::interval" ],
51                ], },
52                { needupdate => { '>' => 0 } },
53            ]
54        },
55        {
56            select => [ qw(path d_path_key) ],
57            order_by => [ 'updated' ],
58        }
59    )->all ]
60}
61
62sub set_path_needupdate : XMLRPC {
63    my ($self, $c, @paths) = @_;
64
65    #$self->model('Base')->txn_do(
66    #    sub {
67            foreach my $path (@paths) {
68                warn $path;
69                my $p = $c->model('Base::Paths')->find(
70                    { path => $path }
71                ) or next;
72                $p->update(
73                    {
74                        needupdate => scalar(time),
75                    }
76                );
77            }
78            $c->model('Base')->storage->dbh->commit;
79            return 1;
80    #    }
81    #);
82
83    return $c->stash->{xmlrpc} = 1;
84}
85
86
87=head1 AUTHOR
88
89Olivier Thauvin
90
91=head1 LICENSE
92
93This library is free software. You can redistribute it and/or modify
94it under the same terms as Perl itself.
95
96=cut
97
98__PACKAGE__->meta->make_immutable;
99
1001;
Note: See TracBrowser for help on using the repository browser.