Skip to content

Commit

Permalink
Saving progress for prints and scans
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Migurski authored and Michal Migurski committed Feb 6, 2012
1 parent 4dc4644 commit 3769ec4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions site/doc/create.mysql
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions site/lib/data.php
Expand Up @@ -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]));
Expand Down Expand Up @@ -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]));
Expand Down
3 changes: 2 additions & 1 deletion site/www/update-print.php
Expand Up @@ -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');
}
Expand Down
3 changes: 2 additions & 1 deletion site/www/update-scan.php
Expand Up @@ -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');
}
Expand Down

0 comments on commit 3769ec4

Please sign in to comment.