[codeface] [PATCH 4/5] Add query to generate edgelist based on email communication

  • From: Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx>
  • To: codeface@xxxxxxxxxxxxx
  • Date: Thu, 29 Oct 2015 11:57:03 +0100

- Two people are joined together when they have contributed
to a common email thread

Signed-off-by: Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx>
---
codeface/R/query.r | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/codeface/R/query.r b/codeface/R/query.r
index 720e9b9..a7e2af9 100644
--- a/codeface/R/query.r
+++ b/codeface/R/query.r
@@ -544,13 +544,20 @@ query.top.contributors.changes <- function(con, range.id,
limit=20) {

## Compute edgelist for mailing list communication
query.mail.edgelist <- function(con, pid, start.date, end.date) {
- query <- str_c("SELECT who AS `from`, createdBy AS `to`, COUNT(*) AS
`weight`",
- "FROM mail_thread, thread_responses",
- "WHERE
mail_thread.mailThreadId=thread_responses.mailThreadId",
- "AND projectId=", pid,
- "AND mailDate >=", sq(start.date),
- "AND mailDate <", sq(end.date),
- "GROUP BY mail_thread.createdBy, thread_responses.who", sep="
")
+ query <- str_c("SELECT mail1.author as `from`, mail2.author as `to`,
+ COUNT(*) as `weight`",
+ "FROM mail mail1, mail mail2",
+ "WHERE mail1.projectId=", pid,
+ "AND mail1.projectId=mail2.projectId",
+ "AND mail1.threadId=mail2.threadId",
+ "AND mail1.mlId=mail2.mlId",
+ "AND mail1.author!=mail2.author",
+ "AND mail1.creationDate > mail2.creationDate",
+ "AND mail1.creationDate >=", sq(start.date),
+ "AND mail1.creationDate <", sq(end.date),
+ "AND mail2.creationDate >=", sq(start.date),
+ "AND mail2.creationDate <", sq(end.date),
+ "GROUP BY mail1.author, mail2.author", sep=" ")
dat <- dbGetQuery(con, query)

return(dat)
--
2.1.4


Other related posts: