Changeset 15167
- Timestamp:
- Oct 2, 2007, 4:48:49 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pztool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pztool.c
r15156 r15167 37 37 38 38 static bool copydoneCompleteExp(pxConfig *config); 39 static psArray *pzGet KnownCameras(pxConfig *config);39 static psArray *pzGetPendingCameras(pxConfig *config); 40 40 static psArray *pzArrayZip(psArray *arraySet); 41 41 … … 220 220 } 221 221 222 psArray *cameras = pzGet KnownCameras(config);222 psArray *cameras = pzGetPendingCameras(config); 223 223 if (!cameras) { 224 224 psError(PXTOOLS_ERR_DATA, false, "failed to find any cameras"); … … 229 229 psArray *cameraImfiles = psArrayAlloc(0); 230 230 231 // the total number of imfiles retreived so far 232 long imfiles = 0; 233 // any slots left over by a query returning less than the per camera limit 234 long leftOvers = 0; 231 235 for (long i = 0; i < psArrayLength(cameras); i++) { 232 236 psString query = pxDataGet("pztool_pendingimfile.sql"); … … 250 254 if (limit) { 251 255 // in the case where the limit asked for is less then the number of 252 // cameras we have, return 1 imfile per camera 256 // cameras we have, return 1 imfile per camera and we'll stop 257 // making per camera queries when we have reached limit. 253 258 if (limit < psArrayLength(cameras)) { 254 259 camLimit = 1; 255 260 } else { 256 261 camLimit = limit / psArrayLength(cameras); 257 // add the modulous to the first camera in the list 262 // add the modulous to the first camera in the list, so if 263 // limit is not even divsable by the number of cameras, the 264 // left overs don't get dropped on the floor 258 265 if (i == 0) { 259 266 camLimit += limit % psArrayLength(cameras); … … 264 271 // treat limit == 0 as "no limit" 265 272 if (camLimit) { 273 // pickup the left overs from the prevous camera 274 camLimit += leftOvers; 275 266 276 // divide limit by the number of cameras 267 277 psString limitString = psDBGenerateLimitSQL(camLimit); … … 290 300 } 291 301 302 // if we got less rows then the limit for this camera, give the extra 303 // slots to the next camera. 304 if (camLimit) { 305 leftOvers = camLimit - psArrayLength(result); 306 } 307 308 // update the total count of imfiles fetched 309 imfiles += psArrayLength(result); 310 292 311 // add this query into the array of result set 293 312 psArrayAdd(cameraImfiles, 0, result); 294 313 psFree(result); 314 315 // check to see if we've retreived enough imfiles 316 if (imfiles >= limit) { 317 break; 318 } 295 319 } 296 320 … … 601 625 } 602 626 603 static psArray *pzGet KnownCameras(pxConfig *config)627 static psArray *pzGetPendingCameras(pxConfig *config) 604 628 { 605 629 // get a list of cameras we've seen exps for 606 if (!p_psDBRunQuery(config->dbh, "SELECT DISTINCT camera FROM summitExp")) {630 if (!p_psDBRunQuery(config->dbh, "SELECT DISTINCT camera FROM pzPendingImfile")) { 607 631 psError(PS_ERR_UNKNOWN, false, "database error"); 608 632 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
