From: Sven Schöling Date: Wed, 9 Jan 2013 17:28:47 +0000 (+0100) Subject: Anzahl der Zeilen für den Report cachen un indizieren X-Git-Tag: release-3.1.0beta1~715 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=63f2cbc1aeb2051fe9cb34ddc0d39801a9db7346;p=kivitendo-erp.git Anzahl der Zeilen für den Report cachen un indizieren Da das auch mal gerne 4mio+ werden dauert das sonst elend lange. --- diff --git a/SL/Controller/CsvImport.pm b/SL/Controller/CsvImport.pm index 23f333263..fd74fad91 100644 --- a/SL/Controller/CsvImport.pm +++ b/SL/Controller/CsvImport.pm @@ -130,7 +130,7 @@ sub action_report { my $report_id = $params{report_id} || $::form->{id}; $self->{report} = SL::DB::Manager::CsvImportReport->find_by(id => $report_id); - my $num_rows = SL::DB::Manager::CsvImportReportRow->get_all_count(query => [ csv_import_report_id => $report_id ]); + my $num_rows = $self->{report}->numrows; my $num_cols = SL::DB::Manager::CsvImportReportRow->get_all_count(query => [ csv_import_report_id => $report_id, row => 0 ]); # manual paginating, yuck @@ -141,7 +141,7 @@ sub action_report { $pages->{cur} = $page < 1 ? 1 : $page > $pages->{max} ? $pages->{max} : $page; - $pages->{common} = SL::DB::Helper::Paginated::make_common_pages($pages->{cur}, $pages->{max}); + $pages->{common} = [ grep { $_->{visible} } @{ SL::DB::Helper::Paginated::make_common_pages($pages->{cur}, $pages->{max}) } ]; $self->{display_rows} = [ 0, @@ -380,6 +380,7 @@ sub save_report { profile => $clone_profile, type => $self->type, file => '', + numrows => scalar @{ $self->data }, )->save(cascade => 1); my $dbh = $::form->get_standard_dbh; diff --git a/SL/DB/MetaSetup/CsvImportReport.pm b/SL/DB/MetaSetup/CsvImportReport.pm index cdc4f77e5..4b61a2a17 100644 --- a/SL/DB/MetaSetup/CsvImportReport.pm +++ b/SL/DB/MetaSetup/CsvImportReport.pm @@ -15,6 +15,7 @@ __PACKAGE__->meta->setup( profile_id => { type => 'integer', not_null => 1 }, type => { type => 'text', not_null => 1 }, file => { type => 'text', not_null => 1 }, + numrows => { type => 'integer' }, ], primary_key_columns => [ 'id' ], diff --git a/sql/Pg-upgrade2/csv_import_report_cache.sql b/sql/Pg-upgrade2/csv_import_report_cache.sql index e401b8397..e3f5cd40e 100644 --- a/sql/Pg-upgrade2/csv_import_report_cache.sql +++ b/sql/Pg-upgrade2/csv_import_report_cache.sql @@ -8,7 +8,8 @@ CREATE TABLE csv_import_reports ( session_id TEXT NOT NULL, profile_id INTEGER NOT NULL REFERENCES csv_import_profiles(id), type TEXT NOT NULL, - file TEXT NOT NULL + file TEXT NOT NULL, + numrows INTEGER NOT NULL, ); CREATE TABLE csv_import_report_rows ( @@ -28,3 +29,5 @@ CREATE TABLE csv_import_report_status ( ); ALTER TABLE csv_import_profiles DROP constraint "csv_import_profiles_name_key"; + +CREATE INDEX "csv_import_report_rows_index_row" ON csv_import_report_rows (row);