Changes between Version 6 and Version 7 of BossaImplementation


Ignore:
Timestamp:
Oct 18, 2007, 3:35:35 PM (17 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BossaImplementation

    v6 v7  
    11= Bossa reference manual =
    22
    3 
    4 == Database tables and PHP structures ==
     3== Database tables ==
    54
    65Until Bossa has good web-based administration tools,
     
    5150|| info || text || description of the user's skill or ranking at a given app, typically JSON-encoded ||
    5251
    53 The Bossa PHP code uses the following classes:
     52== Bossa PHP classes ==
     53
     54Bossa provides the following classes (in '''html/inc/bossa.inc''' and '''html/inc/bossa_db.inc'''):
    5455
    5556 '''!BossaApp, !BossaJob, !BossaJobInst'''::
    56   These correspond to the above tables, and have fields corresponding to each database field.  They offer various functions 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.
    5758 '''Bossa'''::
    58   Various utility functions.
     59  Utility functions.
    5960
    6061== Creating a Bossa project ==
     
    7273}}}
    7374
    74 Create a Bossa application (see below) as follows:
     75Create a Bossa application as follows:
    7576{{{
    7677cd ~/projects/test_project/html/ops
     
    9596
    9697== Adding jobs ==
     98
     99Typically you'll add jobs using a script.
     100Here'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
     140This creates 10 jobs.
     141Each job has an ''info'' field consisting of a JSON-encoded structure
     142consisting of an integer (0 or 1).
    97143
    98144== Front-end scripts ==
     
    157203}}}
    158204
    159 Line 41::
     205 Line 41::
    160206  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::
    162208  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.