From 63f2cbc1aeb2051fe9cb34ddc0d39801a9db7346 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 9 Jan 2013 18:28:47 +0100 Subject: [PATCH] =?utf8?q?Anzahl=20der=20Zeilen=20f=C3=BCr=20den=20Report?= =?utf8?q?=20cachen=20un=20indizieren?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Da das auch mal gerne 4mio+ werden dauert das sonst elend lange. --- SL/Controller/CsvImport.pm | 5 +++-- SL/DB/MetaSetup/CsvImportReport.pm | 1 + sql/Pg-upgrade2/csv_import_report_cache.sql | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) 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); -- 2.20.1