Permalink
Browse files

Saving progress for prints and scans

  • Loading branch information...
1 parent 4dc4644 commit 3769ec4174bfcac11484f5f0d2db149132a40803 Michal Migurski committed Feb 6, 2012
Showing with 10 additions and 4 deletions.
  1. +4 −0 site/doc/create.mysql
  2. +2 −2 site/lib/data.php
  3. +2 −1 site/www/update-print.php
  4. +2 −1 site/www/update-scan.php
@@ -63,6 +63,8 @@ ALTER TABLE prints ADD COLUMN atlas_pages TEXT NULL AFTER geotiff_url;
ALTER TABLE prints ADD COLUMN form_id VARCHAR(8) NULL AFTER id;
+ALTER TABLE prints ADD COLUMN progress FLOAT NULL AFTER composed;
+
DROP TABLE IF EXISTS pages;
@@ -142,6 +144,8 @@ CREATE TABLE scans (
ALTER TABLE scans ADD COLUMN has_geojpeg ENUM('yes', 'no') DEFAULT 'no' AFTER has_geotiff;
ALTER TABLE scans ADD COLUMN geojpeg_bounds TEXT AFTER uploaded_file;
+ALTER TABLE scans ADD COLUMN progress FLOAT NULL AFTER failed;
+
DROP TABLE IF EXISTS forms;
View
@@ -698,7 +698,7 @@ function set_print(&$dbh, $print)
$update_clauses = array();
- foreach(array('north', 'south', 'east', 'west', 'zoom', 'paper_size', 'orientation', 'layout', 'provider', 'pdf_url', 'preview_url', 'geotiff_url', 'atlas_pages', 'form_id', 'user_id', 'country_name', 'country_woeid', 'region_name', 'region_woeid', 'place_name', 'place_woeid') as $field)
+ foreach(array('north', 'south', 'east', 'west', 'zoom', 'paper_size', 'orientation', 'layout', 'provider', 'pdf_url', 'preview_url', 'geotiff_url', 'atlas_pages', 'form_id', 'user_id', 'country_name', 'country_woeid', 'region_name', 'region_woeid', 'place_name', 'place_woeid', 'progress') as $field)
if(!is_null($print[$field]))
if($print[$field] != $old_print[$field])
$update_clauses[] = sprintf('%s = %s', $field, $dbh->quoteSmart($print[$field]));
@@ -774,7 +774,7 @@ function set_scan(&$dbh, $scan)
// TODO: ditch dependency on table_columns()
// TODO: ditch special-case for base_url
- foreach(array('print_id', 'user_id', 'min_row', 'min_column', 'min_zoom', 'max_row', 'max_column', 'max_zoom', 'description', 'is_private', 'will_edit', 'base_url', 'uploaded_file', 'decoding_json', 'has_geotiff', 'has_geojpeg', 'geojpeg_bounds', 'has_stickers') as $field)
+ foreach(array('print_id', 'user_id', 'min_row', 'min_column', 'min_zoom', 'max_row', 'max_column', 'max_zoom', 'description', 'is_private', 'will_edit', 'base_url', 'uploaded_file', 'decoding_json', 'has_geotiff', 'has_geojpeg', 'geojpeg_bounds', 'has_stickers', 'progress') as $field)
if(in_array($field, $column_names) && !is_null($scan[$field]))
if($scan[$field] != $old_scan[$field] || in_array($field, array('base_url')))
$update_clauses[] = sprintf('%s = %s', $field, $dbh->quoteSmart($scan[$field]));
@@ -24,7 +24,8 @@
{
$dbh->query('START TRANSACTION');
- error_log("Update print {$print['id']} with {$progress}");
+ $print['progress'] = $progress;
+ set_print($dbh, $print);
$dbh->query('COMMIT');
}
@@ -24,7 +24,8 @@
{
$dbh->query('START TRANSACTION');
- error_log("Update scan {$scan['id']} with {$progress}");
+ $scan['progress'] = $progress;
+ set_scan($dbh, $scan);
$dbh->query('COMMIT');
}

0 comments on commit 3769ec4

Please sign in to comment.