| | 45 | end |
|---|
| | 46 | |
|---|
| | 47 | # XXX: Experimental |
|---|
| | 48 | # Assume 1 Job = 1 URL |
|---|
| | 49 | # |
|---|
| | 50 | # Return Codes: |
|---|
| | 51 | # -1 = invalid |
|---|
| | 52 | # 0 = not processed yet |
|---|
| | 53 | # 1 = visited |
|---|
| | 54 | # 2 = timed out |
|---|
| | 55 | # 3 = suspicious |
|---|
| | 56 | def query_drone_job(job_id) |
|---|
| | 57 | begin |
|---|
| | 58 | job = DroneJob.find(job_id) |
|---|
| | 59 | |
|---|
| | 60 | if (job.completed_urls_count <= 0) |
|---|
| | 61 | # The job hasn't been processed yet. |
|---|
| | 62 | return 0 |
|---|
| | 63 | end |
|---|
| | 64 | |
|---|
| | 65 | history_url = job.history_urls.last |
|---|
| | 66 | if (history_url.status == "visited") |
|---|
| | 67 | return 1 |
|---|
| | 68 | elsif (history_url.status == "suspicious") |
|---|
| | 69 | return 3 |
|---|
| | 70 | else |
|---|
| | 71 | # Assume the history url was timed out. |
|---|
| | 72 | return 2 |
|---|
| | 73 | end |
|---|
| | 74 | |
|---|
| | 75 | rescue |
|---|
| | 76 | # We assume the Job ID was invalid. |
|---|
| | 77 | logger.warn $!.to_s |
|---|
| | 78 | return -1 |
|---|
| | 79 | end |
|---|