Changes between Version 6 and Version 7 of BossaImplementation
- Timestamp:
- Oct 18, 2007, 3:35:35 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
BossaImplementation
v6 v7 1 1 = Bossa reference manual = 2 2 3 4 == Database tables and PHP structures == 3 == Database tables == 5 4 6 5 Until Bossa has good web-based administration tools, … … 51 50 || info || text || description of the user's skill or ranking at a given app, typically JSON-encoded || 52 51 53 The Bossa PHP code uses the following classes: 52 == Bossa PHP classes == 53 54 Bossa provides the following classes (in '''html/inc/bossa.inc''' and '''html/inc/bossa_db.inc'''): 54 55 55 56 '''!BossaApp, !BossaJob, !BossaJobInst''':: 56 These correspond to the above tables, and have fields corresponding to each database field. They offer variousfunctions to insert, look up, and modify database rows.57 These correspond to the above tables, and have fields corresponding to each database field. They offer functions to insert, look up, and modify database rows. 57 58 '''Bossa''':: 58 Various utility functions.59 Utility functions. 59 60 60 61 == Creating a Bossa project == … … 72 73 }}} 73 74 74 Create a Bossa application (see below)as follows:75 Create a Bossa application as follows: 75 76 {{{ 76 77 cd ~/projects/test_project/html/ops … … 95 96 96 97 == Adding jobs == 98 99 Typically you'll add jobs using a script. 100 Here's an example ('''html/ops/bossa_make_jobs_example.php'''): 101 {{{ 102 1 <?php 103 2 104 3 require_once("../inc/bossa_db.inc"); 105 4 require_once("../inc/db.inc"); 106 5 107 6 db_init(); 108 7 109 8 function make_jobs() { 110 9 $appname = 'bossa_test'; 111 10 $app = BossaApp::lookup_name($appname); 112 11 if (!$app) { 113 12 echo "Application $appname not found\n"; 114 13 exit(1); 115 14 } 116 15 $job = new BossaJob; 117 16 $job->app_id = $app->id; 118 17 $job->batch = 0; 119 18 $job->time_estimate = 30; 120 19 $job->time_limit = 600; 121 20 $job->nsuccess_needed = 3; 122 21 for ($i=0; $i<10; $i++) { 123 22 $job->name = "job_$i"; 124 23 $info = null; 125 24 $info->number = $i % 2; 126 25 $job->info = json_encode($info); 127 26 if (!$job->insert()) { 128 27 echo "BossaJob::insert failed: ", mysql_error(), "\n"; 129 28 exit(1); 130 29 } 131 30 } 132 31 } 133 32 134 33 make_jobs(); 135 34 echo "All done.\n"; 136 35 137 36 ?> 138 }}} 139 140 This creates 10 jobs. 141 Each job has an ''info'' field consisting of a JSON-encoded structure 142 consisting of an integer (0 or 1). 97 143 98 144 == Front-end scripts == … … 157 203 }}} 158 204 159 Line 41::205 Line 41:: 160 206 Call a Bossa utility function to look up the job instance and make sure that it was issued to the logged-in user. The job instance, job, and user are returned. 161 Line 43::207 Line 43:: 162 208 Branch according to whether we are showing a job or handling the completion of a job. 163 209 Line 14:: 210 If we're showing a job, decode its ''info'' structure to decide whether to show which picture to show. 211 Lines 17-18:: 212 Task completion will be handled by this script; arrange to pass the job instance ID. 213 Lines 31-33:: 214 Get the user's response, and encode it in JSON. 215 Line 34:: 216 Call a utility function that marks the job instance as completed and updates its database record. 217 Line 38:: 218 Call a utility function that gets another job (if one is available) and shows it to the user.