long_jobs) $this->long_jobs = 0; $now = time(); $query = "insert into bossa_app (create_time, name, user_friendly_name, long_jobs, start_url) values ($now, '$this->name', '$this->user_friendly_name', $this->long_jobs, '$this->start_url')"; $result = mysql_query($query); if (!$result) return false; $this->id = mysql_insert_id(); return true; } static function lookup_name($name) { $result = mysql_query("select * from bossa_app where name='$name'"); if (!$result) return null; $app = mysql_fetch_object($result); mysql_free_result($result); return $app; } static function lookup_id($id) { return bossa_lookup($id, 'bossa_app'); } } class BossaJob { function insert() { $now = time(); $query = "insert into bossa_job (create_time, name, app_id, info, batch, time_estimate, time_limit, more_needed, npending, nsuccess, nsuccess_needed) values ($now, '$this->name', $this->app_id, '$this->info', $this->batch, $this->time_estimate, $this->time_limit, 1, 0, 0, $this->nsuccess_needed)"; $result = mysql_query($query); if (!$result) { echo "$query\n"; return false; } $this->id = mysql_insert_id(); return true; } function update($clause) { return mysql_query("update bossa_job set $clause where id=$this->id"); } static function lookup_id($id) { return bossa_lookup($id, 'bossa_job'); } } class BossaJobInst { function insert() { $now = time(); $query = "insert into bossa_job_inst (create_time, job_id, user_id) values ($now, $this->job_id, $this->user_id)"; $result = mysql_query($query); if (!$result) { echo "$query\n"; return false; } $this->id = mysql_insert_id(); return true; } static function lookup_id($id) { return bossa_lookup($id, 'bossa_job_inst'); } function update($clause) { return mysql_query("update bossa_job_inst set $clause where id=$this->id"); } // Assign a job from the given app to the given user. // Returns the job instance or NULL. // static function assign($app, $user) { // this query skips jobs for which this user // has already been assigned an instance // $query = "select bossa_job.* from bossa_job left join bossa_job_inst on bossa_job_inst.job_id = bossa_job.id where bossa_job.more_needed<>0 and bossa_job_inst.user_id is null limit 1"; echo "$query\n"; $result = mysql_query($query); if (!$result) return null; $job = mysql_fetch_object($result); mysql_free_result($result); echo "