Browse files

adding ability to query by last modified

  • Loading branch information...
1 parent 36c287f commit cda521ec222469e1b405c5a87a54eddb5024c8c0 @radicaldesigns committed May 22, 2012
Showing with 19 additions and 3 deletions.
  1. +6 −1 scripts/dispatcher.js
  2. +13 −2 scripts/fetch_table_data.php
View
7 scripts/dispatcher.js
@@ -3,12 +3,17 @@ var async = require('async');
var spawn = require('child_process').spawn;
var exec = require('child_process').exec;
var migrations = require('./migrations');
+var since;
+
+if(process.argv.length == 3){
+ since = process.argv[2];
+}
var table_migrations = [];
_.each(migrations, function(migration){
table_migrations.push(function(done){
var migration_functions = [];
- exec('php fetch_table_data.php '+migration.table, function(err, table_info_json){
+ exec('php fetch_table_data.php '+migration.table+(since ? " '"+since+"'" : ""), function(err, table_info_json){
var table_info = JSON.parse(table_info_json);
var blocksize = Math.ceil(table_info['table_size'] / migration.concurrency);
_.each(_.range(migration.concurrency), function(i){
View
15 scripts/fetch_table_data.php
@@ -1,6 +1,10 @@
<?php
require_once('../boot.php');
-list($cmd, $table) = $argv;
+list($cmd, $table, $since) = $argv;
+if($since){
+ $since_timestamp = strtotime($since);
+ $since = Date("Y-m-d", $since_timestamp);
+}
$special_array = db_numeric();
function db_numeric(){
@@ -17,7 +21,14 @@ function db_numeric(){
function find_table_remote_size(){
global $dia;
global $table;
- return $dia->count($table, array('condition' => $table.'_KEY>=0', 'countColumn' => $table.'_KEY'));
+ global $since;
+ $conditions = array('countColumn' => $table.'_KEY');
+ if($since){
+ $conditions['condition'] = 'Last_Modified>'.$since;
+ } else {
+ $conditions['condition'] = $table.'_KEY>=0';
+ }
+ return $dia->count($table, $conditions);
}
echo json_encode(array('table_size' => find_table_remote_size(), 'special_array' => serialize($special_array)));

0 comments on commit cda521e

Please sign in to comment.