Jeremy D commited on 2011-09-30 16:23:13
Showing 1 changed files, with 76 additions and 12 deletions.
... | ... |
@@ -217,6 +217,7 @@ class mbt_to_tbg |
217 | 217 |
*/ |
218 | 218 |
function doStep1() |
219 | 219 |
{ |
220 |
+ $step_size = 500; |
|
220 | 221 |
$substep = $this->getSubStep(__FUNCTION__); |
221 | 222 |
|
222 | 223 |
$query = ' |
... | ... |
@@ -225,7 +226,7 @@ class mbt_to_tbg |
225 | 226 |
enabled, last_vist AS lastseen, date_created AS joined |
226 | 227 |
FROM |
227 | 228 |
' . $this->mbt_db_prefix . 'user_table |
228 |
- LIMIT ' . $substep . ' 500'; |
|
229 |
+ LIMIT ' . $substep . ' ' . $step_size; |
|
229 | 230 |
|
230 | 231 |
// We could let this save up a few inserts then do them at once, but are we really worried about saving queries here? |
231 | 232 |
foreach ($this->db->query($sql) as $row) |
... | ... |
@@ -237,7 +238,7 @@ class mbt_to_tbg |
237 | 238 |
VALUES (' . $row['id'] . ', "' . $row['username'] . '", "' . $row['buddyname'] . '", "' . $row['realname'] . '", "' . $row['email'] . '", "' . $password . '", ' . $row['enabled'] . ', ' . $row['username'] . ', ' . $row['joined'] . ')'); |
238 | 239 |
} |
239 | 240 |
|
240 |
- $this->updateSubStep($substep + 500); |
|
241 |
+ $this->updateSubStep($substep + $step_size); |
|
241 | 242 |
$this->checkTimeout(__FUNCTION__); |
242 | 243 |
} |
243 | 244 |
|
... | ... |
@@ -247,6 +248,7 @@ class mbt_to_tbg |
247 | 248 |
*/ |
248 | 249 |
function doStep2() |
249 | 250 |
{ |
251 |
+ $step_size = 500; |
|
250 | 252 |
$substep = $this->getSubStep(__FUNCTION__); |
251 | 253 |
|
252 | 254 |
$query = ' |
... | ... |
@@ -254,14 +256,14 @@ class mbt_to_tbg |
254 | 256 |
id, name, description, |
255 | 257 |
(CASE WHEN enabled = 0 THEN 1 ELSE 0) AS locked |
256 | 258 |
FROM ' . $this->mbt_db_prefix . 'project_table |
257 |
- LIMIT ' . $substep . ' 500'; |
|
259 |
+ LIMIT ' . $substep . ' ' . $step_size; |
|
258 | 260 |
|
259 | 261 |
foreach ($this->db->query($sql) as $row) |
260 | 262 |
$this->db->query(' |
261 | 263 |
INSERT INTO ' . $this->tbg_db_prefix . 'projects (id, name, locked, description) |
262 | 264 |
VALUES (' . $row['id'] . ', "' . $row['name'] . '", ' . $row['locked'] . ', "' . $row['description'] . '")'); |
263 | 265 |
|
264 |
- $this->updateSubStep($substep + 500); |
|
266 |
+ $this->updateSubStep($substep + $step_size); |
|
265 | 267 |
$this->checkTimeout(__FUNCTION__); |
266 | 268 |
} |
267 | 269 |
|
... | ... |
@@ -271,20 +273,21 @@ class mbt_to_tbg |
271 | 273 |
*/ |
272 | 274 |
function doStep3() |
273 | 275 |
{ |
276 |
+ $step_size = 500; |
|
274 | 277 |
$substep = $this->getSubStep(__FUNCTION__); |
275 | 278 |
|
276 | 279 |
$query = ' |
277 | 280 |
SELECT |
278 | 281 |
name |
279 | 282 |
FROM ' . $this->mbt_db_prefix . 'category_table |
280 |
- LIMIT ' . $substep . ' 500'; |
|
283 |
+ LIMIT ' . $substep . ' ' . $step_size; |
|
281 | 284 |
|
282 | 285 |
foreach ($this->db->query($sql) as $row) |
283 | 286 |
$this->db->query(' |
284 | 287 |
INSERT INTO ' . $this->tbg_db_prefix . 'listtypes (name, itemtype, scope) |
285 | 288 |
VALUES (' . $row['name'] . ', "category", 1)'); |
286 | 289 |
|
287 |
- $this->updateSubStep($substep + 500); |
|
290 |
+ $this->updateSubStep($substep + $step_size); |
|
288 | 291 |
$this->checkTimeout(__FUNCTION__); |
289 | 292 |
} |
290 | 293 |
|
... | ... |
@@ -294,6 +297,7 @@ class mbt_to_tbg |
294 | 297 |
*/ |
295 | 298 |
function doStep4() |
296 | 299 |
{ |
300 |
+ $step_size = 500; |
|
297 | 301 |
$substep = $this->getSubStep(__FUNCTION__); |
298 | 302 |
|
299 | 303 |
// Obtain any current builds. |
... | ... |
@@ -309,7 +313,7 @@ class mbt_to_tbg |
309 | 313 |
SELECT |
310 | 314 |
id, project_id, version, released AS isreleased |
311 | 315 |
FROM ' . $this->mbt_db_prefix . 'project_version_table |
312 |
- LIMIT ' . $substep . ' 500'; |
|
316 |
+ LIMIT ' . $substep . ' ' . $step_size; |
|
313 | 317 |
|
314 | 318 |
foreach ($this->db->query($sql) as $row) |
315 | 319 |
{ |
... | ... |
@@ -323,7 +327,7 @@ class mbt_to_tbg |
323 | 327 |
|
324 | 328 |
} |
325 | 329 |
|
326 |
- $this->updateSubStep($substep + 500); |
|
330 |
+ $this->updateSubStep($substep + $step_size); |
|
327 | 331 |
$this->checkTimeout(__FUNCTION__); |
328 | 332 |
} |
329 | 333 |
|
... | ... |
@@ -334,6 +338,7 @@ class mbt_to_tbg |
334 | 338 |
*/ |
335 | 339 |
function doStep5() |
336 | 340 |
{ |
341 |
+ $step_size = 500; |
|
337 | 342 |
$substep = $this->getSubStep(__FUNCTION__); |
338 | 343 |
|
339 | 344 |
// Obtain any current builds. |
... | ... |
@@ -361,7 +366,7 @@ class mbt_to_tbg |
361 | 366 |
version |
362 | 367 |
FROM ' . $this->mbt_db_prefix . 'bug_table AS bt |
363 | 368 |
LEFT JOIN ' . $this->mbt_db_prefix . 'bug_text_table AS btt ON (btt.id = bt.bug_text_id) |
364 |
- LIMIT ' . $substep . ' 500'; |
|
369 |
+ LIMIT ' . $substep . ' ' . $step_size; |
|
365 | 370 |
|
366 | 371 |
foreach ($this->db->query($sql) as $row) |
367 | 372 |
{ |
... | ... |
@@ -383,7 +388,7 @@ class mbt_to_tbg |
383 | 388 |
INSERT INTO (' . $this->tbg_db_prefix . 'issueaffectsbuild (id, build) VALUES(' . $row['id'] . ', ' . $affect_id . ')'); |
384 | 389 |
} |
385 | 390 |
|
386 |
- $this->updateSubStep($substep + 500); |
|
391 |
+ $this->updateSubStep($substep + $step_size); |
|
387 | 392 |
$this->checkTimeout(__FUNCTION__); |
388 | 393 |
} |
389 | 394 |
|
... | ... |
@@ -393,6 +398,7 @@ class mbt_to_tbg |
393 | 398 |
*/ |
394 | 399 |
function doStep6() |
395 | 400 |
{ |
401 |
+ $step_size = 500; |
|
396 | 402 |
$substep = $this->getSubStep(__FUNCTION__); |
397 | 403 |
|
398 | 404 |
$query = ' |
... | ... |
@@ -401,16 +407,74 @@ class mbt_to_tbg |
401 | 407 |
bn.reporter_id AS updated_by, bn.reporter_id AS posted_by, bnt.note AS content |
402 | 408 |
FROM ' . $this->mbt_db_prefix . 'bugnote_table AS bn |
403 | 409 |
INNER JOIN ' . $this->mbt_db_prefix . 'butnote_text_table AS bnt ON (bn.id = bnt.bug_text_id) |
404 |
- LIMIT ' . $substep . ' 500'; |
|
410 |
+ LIMIT ' . $substep . ' ' . $step_size; |
|
405 | 411 |
|
406 | 412 |
foreach ($this->db->query($sql) as $row) |
407 | 413 |
$this->db->query(' |
408 | 414 |
INSERT INTO ' . $this->tbg_db_prefix . 'comments (id, target_id, updated, posted, updated_by, posted_by, content) |
409 | 415 |
VALUES (' . $row['id'] . ', ' . $row['target_id'] . ', ' . $row['updated'] . ', ' . $row['posted'] . ', ' . $row['updated_by'] . ', ' . $row['posted_by'] . ', "' . $row['content'] . '")'); |
410 | 416 |
|
411 |
- $this->updateSubStep($substep + 500); |
|
417 |
+ $this->updateSubStep($substep + $step_size); |
|
412 | 418 |
$this->checkTimeout(__FUNCTION__); |
413 | 419 |
} |
420 |
+ |
|
421 |
+ /** |
|
422 |
+ * Relationships are great. |
|
423 |
+ * |
|
424 |
+ */ |
|
425 |
+ function doStep7() |
|
426 |
+ { |
|
427 |
+ $step_size = 500; |
|
428 |
+ $substep = $this->getSubStep(__FUNCTION__); |
|
429 |
+ |
|
430 |
+ $query = ' |
|
431 |
+ SELECT |
|
432 |
+ source_bug_id AS parent_id, destination_bug_id AS child_id |
|
433 |
+ FROM ' . $this->mbt_db_prefix . 'bug_relationships_table |
|
434 |
+ LIMIT ' . $substep . ' ' . $step_size; |
|
435 |
+ |
|
436 |
+ foreach ($this->db->query($sql) as $row) |
|
437 |
+ $this->db->query(' |
|
438 |
+ INSERT INTO ' . $this->tbg_db_prefix . 'issuerelations (parent_id, child_id) |
|
439 |
+ VALUES (' . $row['parent_id'] . ', ' . $row['child_id'] . ')'); |
|
440 |
+ |
|
441 |
+ |
|
442 |
+ $this->updateSubStep($substep + $step_size); |
|
443 |
+ $this->checkTimeout(__FUNCTION__); |
|
444 |
+ } |
|
445 |
+ |
|
446 |
+ /** |
|
447 |
+ * Attachments, the pain of our every existence) |
|
448 |
+ * |
|
449 |
+ */ |
|
450 |
+ function doStep8 |
|
451 |
+ { |
|
452 |
+ $step_size = 100; |
|
453 |
+ $substep = $this->getSubStep(__FUNCTION__); |
|
454 |
+ |
|
455 |
+ // @TODO: GET THE ATTACHMENT LOCATION |
|
456 |
+ /* |
|
457 |
+ // TGB appears to allow storage of files in the database. The source code appears to work it out properly whether it is in the database or local storage. |
|
458 |
+ $result = $this->db->query('SELECT upload_localpath FROM ' . $this->tbg_db_prefix . 'settings WHERE name = "upload_localpath" AND scope = 1'); |
|
459 |
+ $attachment_path = $result['upload_localpath']; |
|
460 |
+ */ |
|
461 |
+ |
|
462 |
+ $query = ' |
|
463 |
+ SELECT |
|
464 |
+ id, user_id AS uid, 1 AS scope, filename AS real_filename, filename AS original_filename, |
|
465 |
+ file_type AS content_type, content, date_added AS uploaded_at, description |
|
466 |
+ FROM ' . $this->mbt_db_prefix . 'bug_file_table |
|
467 |
+ LIMIT ' . $substep . ' ' . $step_size; |
|
468 |
+ |
|
469 |
+ foreach ($this->db->query($sql) as $row) |
|
470 |
+ $this->db->query(' |
|
471 |
+ INSERT INTO ' . $this->tbg_db_prefix . 'files (id, uid, scope, real_filename, original_filename, content_type, content, uploaded_at, description) |
|
472 |
+ VALUES (' . $row['id'] . ', ' . $row['uid'] . ', ' . $row['scope'] . ', "' . $row['real_filename'] . '", "' . $row['original_filename'] . '", "' . $row['content_type'] . '", "' . $row['content'] . '", ' . $row['uploaded_at'] . ', "' . $row['description'] . '")'); |
|
473 |
+ |
|
474 |
+ $this->updateSubStep($substep + $step_size); |
|
475 |
+ $this->checkTimeout(__FUNCTION__); |
|
476 |
+ |
|
477 |
+ } |
|
414 | 478 |
} |
415 | 479 |
|
416 | 480 |
|
417 | 481 |