Revision 0be80dd0
Von Kivitendo Admin vor mehr als 8 Jahren hinzugefügt
SL/Shop.pm | ||
---|---|---|
4 | 4 |
|
5 | 5 |
use parent qw(Rose::Object); |
6 | 6 |
use SL::ShopConnector::ALL; |
7 |
use SL::DB::Part; |
|
7 | 8 |
|
8 | 9 |
# __PACKAGE__->run_before('check_auth'); |
9 | 10 |
|
... | ... | |
12 | 13 |
'scalar --get_set_init' => [ qw(connector) ], |
13 | 14 |
); |
14 | 15 |
|
16 |
sub updatable_parts { |
|
17 |
my ($self, $last_update) = @_; |
|
18 |
$last_update ||= DateTime->now(); # need exact timestamp, with minutes |
|
19 |
|
|
20 |
my $parts; |
|
21 |
my $active_shops = SL::DB::Manager::Shop->get_all(query => [ obsolete => 0 ]); |
|
22 |
foreach my $shop ( @{ $active_shops } ) { |
|
23 |
# maybe run as an iterator? does that make sense with with_objects? |
|
24 |
my $update_parts = SL::DB::Manager::ShopPart->get_all(query => [ |
|
25 |
and => [ |
|
26 |
'active' => 1, |
|
27 |
'shop_id' => $shop->id, |
|
28 |
# shop => '1', |
|
29 |
or => [ 'part.mtime' => { ge => $last_update }, |
|
30 |
'part.itime' => { ge => $last_update }, |
|
31 |
'itime' => { ge => $last_update }, |
|
32 |
'mtime' => { ge => $last_update }, |
|
33 |
], |
|
34 |
] |
|
35 |
], |
|
36 |
with_objects => ['shop', 'part'], |
|
37 |
# multi_many_ok => 1, |
|
38 |
); |
|
39 |
push( @{ $parts }, @{ $update_parts }); |
|
40 |
}; |
|
41 |
return $parts; |
|
42 |
|
|
43 |
}; |
|
44 |
|
|
15 | 45 |
sub init_connector { |
16 | 46 |
my ($self) = @_; |
17 | 47 |
# determine the connector from the connector type in the webshop config |
18 |
return SL::ShopConnector::ALL->shop_connector_class_by_name($self->config->connector)->new( config => $self->config);
|
|
48 |
return SL::ShopConnector::ALL->shop_connector_class_by_name($self->config->connector)->new( config => $self->config); |
|
19 | 49 |
|
20 | 50 |
}; |
21 | 51 |
|
... | ... | |
27 | 57 |
|
28 | 58 |
=head1 NAME |
29 | 59 |
|
30 |
SL::WebShop - Do stuff with WebShop instances
|
|
60 |
SL::Shop - Do stuff with Shop instances
|
|
31 | 61 |
|
32 | 62 |
=head1 SYNOPSIS |
33 | 63 |
|
34 |
my $config = SL::DB::Manager::WebShop->get_first();
|
|
64 |
my $config = SL::DB::Manager::Shop->get_first(); |
|
35 | 65 |
my $shop = SL::WebShop->new( config => $config ); |
36 | 66 |
|
37 | 67 |
From the config we know which Connector class to load, save in $shop->connector |
Auch abrufbar als: Unified diff
Shop - first attempt at determining updated parts