Skip to contentSkip to conversation

[1.30] toaster: fix progress bar in MySQL environment

PATCH New Michael Wood 1 participant 1 message May 13, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 [1.30] toaster: fix progress bar in MySQL environment

From: Elliot Smith <[email protected]>

When using MySQL, the project builds info delivered by MySQL differs from that delivered by SQLite: the former returns text values from the enumeration for Build outcomes, while the latter returns the integer value. This causes the progress bar JS to break, as it is expecting outcome strings.

Modify the recent_build() method to include an outcomeText property for each Build object, then use this in the conditionals in the progress bar JS.

[YOCTO #9498]

---
 lib/toaster/orm/models.py                      | 1 +
 lib/toaster/toastergui/static/js/mrbsection.js | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
lib/toaster/orm/models.py +1 -0
index 0b83b99..dbdd060 100644
@@ -415,6 +415,7 @@ class Build(models.Model):
         # to show build progress in mrb_section.html
         for build in recent_builds:
             build.percentDone = build.completeper()
+            build.outcomeText = build.get_outcome_text()
 
         return recent_builds
 
lib/toaster/toastergui/static/js/mrbsection.js +2 -2
index 09117e1..9a76ee6 100644
@@ -57,12 +57,12 @@ function mrbSectionInit(ctx){
           for (var i in prjInfo.builds){
             var build = prjInfo.builds[i];
 
-            if (build.outcome === "In Progress" ||
+            if (build.outcomeText === "In Progress" ||
                $(".progress .bar").length > 0){
               /* Update the build progress */
               var percentDone;
 
-              if (build.outcome !== "In Progress"){
+              if (build.outcomeText !== "In Progress"){
                 /* We have to ignore the value when it's Succeeded because it
                 *   goes back to 0
                 */
Signature · 1 line
2.7.4