Overview
Comment: | This seems to be working but it should not. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.80 |
Files: | files | file ages | folders |
SHA1: |
ab6d2aae1a1d77f90fa1daca9029d4f1 |
User & Date: | matt on 2023-03-11 17:12:45 |
Other Links: | branch diff | manifest | tags |
Context
2023-03-11
| ||
20:47 | Remove noise check-in: 49abec32c1 user: matt tags: v1.80 | |
17:12 | This seems to be working but it should not. check-in: ab6d2aae1a user: matt tags: v1.80 | |
14:40 | Bit better check-in: 3db414f444 user: matt tags: v1.80 | |
Changes
Modified dashboard.scm from [c294083769] to [97180e20b9].
︙ | ︙ | |||
1087 1088 1089 1090 1091 1092 1093 | ;; optimized to get runs constrained by what is visible on the screen ;; - not appropriate for where all the runs are needed ;; (define (update-buttons tabdat uidat numruns numtests) (let* ((runs (if (> (length (dboard:tabdat-allruns tabdat)) numruns) (take-right (dboard:tabdat-allruns tabdat) numruns) | | | 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | ;; optimized to get runs constrained by what is visible on the screen ;; - not appropriate for where all the runs are needed ;; (define (update-buttons tabdat uidat numruns numtests) (let* ((runs (if (> (length (dboard:tabdat-allruns tabdat)) numruns) (take-right (dboard:tabdat-allruns tabdat) numruns) (pad-list (dboard:tabdat-allruns tabdat) numruns))) (lftcol (dboard:uidat-get-lftcol uidat)) (tableheader (dboard:uidat-get-header uidat)) (table (dboard:uidat-get-runsvec uidat)) (coln 0) (all-test-names (make-hash-table)) (use-bgcolor (equal? (configf:lookup *configdat* "dashboard" "use-bgcolor") "yes")) ;; doesn't work ) |
︙ | ︙ |
Modified dbmod.scm from [afcc4b5172] to [78e6f0cb09].
︙ | ︙ | |||
170 171 172 173 174 175 176 177 178 179 180 181 182 183 | ;; direction: 'fromdest 'todest ;; (define (sync-gasket tables last-update inmem dbh dbfname direction) (case (dbfile:sync-method) ((none) #f) ((attach) (dbmod:attach-sync tables inmem dbfname direction)) (else (case direction ((todest) (dbmod:sync-tables tables last-update inmem dbh)) (else (dbmod:sync-tables tables last-update dbh inmem)))))) | > > | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | ;; direction: 'fromdest 'todest ;; (define (sync-gasket tables last-update inmem dbh dbfname direction) (case (dbfile:sync-method) ((none) #f) ((attach) (dbmod:attach-sync tables inmem dbfname direction)) ((newsync) (dbmod:new-sync tables inmem dbh dbfname direction)) (else (case direction ((todest) (dbmod:sync-tables tables last-update inmem dbh)) (else (dbmod:sync-tables tables last-update dbh inmem)))))) |
︙ | ︙ | |||
376 377 378 379 380 381 382 383 384 385 386 387 388 | ;; done (debug:print 0 *default-log-port* "Attaching "destdbfile" as auxdb") (sqlite3:execute dbh (conc "ATTACH '"destdbfile"' AS auxdb;")) (for-each (lambda (table) (let* ((tbldat (alist-ref table tables equal?)) (fields (map car tbldat)) (fields-str (string-intersperse fields ",")) (dir (eq? direction 'todest)) (fromdb (if dir "" "auxdb.")) (todb (if dir "auxdb." "")) (stmt1 (conc "INSERT OR IGNORE INTO "todb table " SELECT * FROM "fromdb table";")) | > > > > > > > < | < | < < < | | < < < < < > | > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | ;; done (debug:print 0 *default-log-port* "Attaching "destdbfile" as auxdb") (sqlite3:execute dbh (conc "ATTACH '"destdbfile"' AS auxdb;")) (for-each (lambda (table) (let* ((tbldat (alist-ref table tables equal?)) (fields (map car tbldat)) (no-id-fields (filter (lambda (x)(not (equal? x "id"))) fields)) (fields-str (string-intersperse fields ",")) (no-id-fields-str (string-intersperse no-id-fields ",")) (dir (eq? direction 'todest)) (fromdb (if dir "" "auxdb.")) (todb (if dir "auxdb." "")) (set-str (string-intersperse (map (lambda (field) (conc fromdb field"="todb field)) fields) ",")) (stmt1 (conc "INSERT OR IGNORE INTO "todb table " SELECT * FROM "fromdb table";")) (stmt8 (conc "UPDATE "todb table" SET ("no-id-fields-str") = (SELECT "no-id-fields-str" FROM "fromdb table" WHERE "todb table".id="fromdb table".id" (if (member "last_update" fields) (conc " AND "fromdb table".last_update > "todb table".last_update);") ");"))) (start-ms (current-milliseconds))) (debug:print 0 *default-log-port* "stmt8="stmt8) (if (sqlite3:auto-committing? dbh) (begin (sqlite3:with-transaction dbh (lambda () (sqlite3:execute dbh stmt1) ;; get all new rows #;(if (member "last_update" fields) (sqlite3:execute dbh stmt8)) ;; get all updated rows ;; (sqlite3:execute dbh stmt5) ;; (sqlite3:execute dbh stmt4) ;; if it worked this would be better for incremental up ;; (sqlite3:execute dbh stmt6) )) (debug:print 0 *default-log-port* "Synced table "table " in "(- (current-milliseconds) start-ms)"ms")) (debug:print 0 *default-log-port* "Skipping sync of table "table" due to transaction in flight.")))) table-names) (sqlite3:execute dbh "DETACH auxdb;")))) ;; FAILED ATTEMPTS ;; (if (not (has-last-update dbh table)) ;; (sqlite3:execute dbh (conc "ALTER TABLE "table" ADD COLUMN last_update INTEGER;"))) ;; (if (not (has-last-update dbh (conc "auxdb."table))) ;; (sqlite3:execute dbh (conc "ALTER TABLE auxdb."table" ADD COLUMN last_update INTEGER;"))) ;; (stmt2 (conc "INSERT OR REPLACE INTO "todb table ;; " SELECT * FROM "fromdb table" WHERE " ;; fromdb table".last_update > " ;; todb table".last_update;")) ;; (stmt3 (conc "INSERT OR REPLACE INTO "todb"."table ;; " SELECT * FROM "fromdb table";")) ;; (stmt4 (conc "DELETE FROM "todb table" WHERE "fromdb ;; table ".last_update > "todb table".last_update;")) ;; (stmt5 (conc "DELETE FROM "todb table";")) ;; (stmt6 (conc "INSERT OR REPLACE INTO "todb table" ("fields-str") SELECT "fields-str" FROM "fromdb table";")) ;; (stmt7 (conc "UPDATE "todb table" SET "set-str (if (member "last_update" fields) ;; (conc " WHERE "fromdb table".last_update > "todb table".last_update;") ;; ";"))) ;; prefix is "" or "auxdb." ;; ;; (define (dbmod:last-update-patch dbh prefix) ;; (let (( ;; tbls is ( ("tablename" ( "field1" [#f|proc1] ) ( "field2" [#f|proc2] ) .... ) ) ;; ;; direction = fromdest, todest ;; mode = 'full, 'incr ;; ;; Idea: youngest in dest is last_update time ;; (define (dbmod:new-sync tables dbh1 dbh2 destdbfile direction #!key (mode 'full)) (debug:print 0 *default-log-port* "Doing sync "direction" "destdbfile) (if (not (sqlite3:auto-committing? dbh1)) (debug:print 0 *default-log-port* "Skipping sync due to transaction in flight.") (let* ((table-names (map car tables)) (dest-exists (file-exists? destdbfile))) (assert dest-exists "FATAL: sync called with non-existant file, "destdbfile) (for-each (lambda (table) (let* ((tbldat (alist-ref table tables equal?)) (fields (map car tbldat)) (no-id-fields (filter (lambda (x)(not (equal? x "id"))) fields)) (questionmarks (string-intersperse (make-list (length no-id-fields) "?") ",")) (fields-str (string-intersperse fields ",")) (no-id-fields-str (string-intersperse no-id-fields ",")) (dir (eq? direction 'todest)) (fromdb (if dir dbh1 dbh2)) (todb (if dir dbh2 dbh1)) (set-str (string-intersperse (map (lambda (field) (conc fromdb field"="todb field)) fields) ",")) ;; (stmt1 (conc "INSERT OR IGNORE INTO "todb table ;; " SELECT * FROM "fromdb table";")) ;; (stmt8 (conc "UPDATE "todb table" SET ("no-id-fields-str") = (SELECT "no-id-fields-str" FROM "fromdb table " WHERE "todb table".id="fromdb table".id" ;; (if (member "last_update" fields) ;; (conc " AND "fromdb table".last_update > "todb table".last_update);") ;; ");"))) (stmt1 (conc "SELECT MAX(last_update) FROM "table";")) ;; use the highest last_update as your time reference (stmt2 (conc "SELECT no-id-fields-str FROM "table" WHERE last_update>?;")) (stmt3 (conc "UPDATE "table" SET ("no-id-fields-str") = ("questionmarks") WHERE id=?;")) (start-ms (current-milliseconds))) (debug:print 0 *default-log-port* "stmt3="stmt3) (if (sqlite3:auto-committing? dbh1) (begin (sqlite3:with-transaction dbh1 (lambda () (sqlite3:execute dbh1 stmt1) ;; get all new rows #;(if (member "last_update" fields) (sqlite3:execute dbh1 stmt8)) ;; get all updated rows ;; (sqlite3:execute dbh stmt5) ;; (sqlite3:execute dbh stmt4) ;; if it worked this would be better for incremental up ;; (sqlite3:execute dbh stmt6) )) (debug:print 0 *default-log-port* "Synced table "table " in "(- (current-milliseconds) start-ms)"ms")) (debug:print 0 *default-log-port* "Skipping sync of table "table" due to transaction in flight.")))) table-names) (sqlite3:execute dbh1 "DETACH auxdb;")))) ;;====================================================================== ;; Moved from dbfile ;;====================================================================== ) |