[codeface] [PATCH 11/27] Fix figure of merit calculation for ML communication

  • From: <wolfgang.mauerer@xxxxxxxxxxxxxxxxx>
  • To: <codeface@xxxxxxxxxxxxx>
  • Date: Sun, 27 Sep 2015 02:28:07 +0200

From: Wolfgang Mauerer <wolfgang.mauerer@xxxxxxxxxxx>

Since we query a COUNT() of entries from table
mail_thread, we will always get a result (including 0
for empty tables). Checking with nrows() for an
empty result is therefore not suitable.

While at it, improve the readability of the code.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@xxxxxxxxxxxxxxxxx>
---
codeface/R/shiny/figures.of.merit.r | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/codeface/R/shiny/figures.of.merit.r
b/codeface/R/shiny/figures.of.merit.r
index d26f40e..b4ac5fb 100644
--- a/codeface/R/shiny/figures.of.merit.r
+++ b/codeface/R/shiny/figures.of.merit.r
@@ -110,9 +110,17 @@ figure.of.merit.collaboration <- function(pid) {
}

figure.of.merit.communication <- function(pid) {
- n.mail.threads <- dbGetQuery(conf$con, str_c("SELECT COUNT(*) FROM
mail_thread WHERE projectId=", pid))[[1]]
- ml.plots <- dbGetQuery(conf$con, str_c("SELECT id, name FROM plots WHERE
projectId=", pid, " AND releaseRangeId IS NULL AND name LIKE '%activity'"))
- if (nrow(n.mail.threads) == 0 || nrow(ml.plots) == 0) {
+ n.mail.threads <- dbGetQuery(conf$con,
+ str_c("SELECT COUNT(*) FROM mail_thread ",
+ "WHERE projectId=", pid))[[1]]
+
+ ml.plots <- dbGetQuery(conf$con,
+ str_c("SELECT id, name FROM plots ",
+ "WHERE projectId=", pid,
+ " AND releaseRangeId IS NULL ",
+ " AND name LIKE '% activity'"))
+
+ if (n.mail.threads == 0 || nrow(ml.plots) == 0) {
return(list(status=status.error, why="No mailing list to analyse."))
}

--
2.1.4


Other related posts:

  • » [codeface] [PATCH 11/27] Fix figure of merit calculation for ML communication - wolfgang.mauerer