1 package System::Introspector::Report::Publish::MediaWiki::Updater;
4 use Module::Runtime qw( use_module );
5 use Log::Contextual::WarnLogger;
6 use Log::Contextual qw( :log ),
7 -default_logger => Log::Contextual::WarnLogger->new({
8 env_prefix => 'SI_REPORT_MEDIAWIKI_UPDATER',
9 levels => [qw( error warn info debug trace )],
12 has connection => (is => 'ro', lazy => 1, builder => 1, handles => {
17 sub _build_connection {
19 return use_module($self->connection_class)->new(
20 api_uri => $self->api_uri,
21 username => $self->username,
22 password => $self->password,
26 http_realm => $self->http_realm,
32 my ($self, $stream) = @_;
33 while (my $report = $stream->()) {
34 $self->_process_page(@$report);
40 my ($self, $page_name, $options, $reports) = @_;
41 unless (scalar @$reports) {
42 log_debug { "Skipping page '$page_name': No reports to publish" };
45 my $do_create = $options->{create};
47 my $page = $self->get_page($page_name);
48 if ($page->is_new and not $do_create) {
49 log_trace { "Skipping page '$page_name': Does not yet exist" };
52 my $is_changed = $page->update($reports);
53 unless ($is_changed) {
54 log_debug { "Not pushing page '$page_name': No changes" };
57 log_debug { "Updating page '$page_name'" };
58 $self->put_page($page);
62 log_error { "Error during page update: $_" };
68 System::Introspector::Report::Publish::MediaWiki::HasConnectInfo