Skip to content

Commit

Permalink
Merge pull request #10 from jubilee2/report
Browse files Browse the repository at this point in the history
Report
  • Loading branch information
jubilee2 authored Dec 19, 2024
2 parents 797c7e8 + f387459 commit de4e59b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
.github
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Version: 0.4.0
Author: Jubilee
Maintainer: Jubilee<[email protected]>
Description: A collection of reusable functions to streamline and enhance the functionality of REDCap projects. This package includes functions for parsing logging strings, converting data types, and more.
License: MIT
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Suggests:
Expand Down
26 changes: 17 additions & 9 deletions R/logReport.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
queryLogSummary <- function(logs) {
# Function implementation
o <- logDetailsParseDQ(logs$details)
logs$Action <- sapply(o, function(x) if (is.null(x$Action)) NA else x$Action)
logs$Record <- sapply(o, function(x) if (is.null(x$Record)) NA else x$Record)
logs$Event <- sapply(o, function(x) if (is.null(x$Event)) NA else x$Event)
logs$Field <- sapply(o, function(x) if (is.null(x$Field)) NA else x$Field)
logs$Comment <- sapply(o, function(x) if (is.null(x$Comment)) NA else x$Comment)
logs$`Data Quality Rule` <- sapply(o, function(x) if (is.null(x$`Data Quality Rule`)) NA else x$`Data Quality Rule`)
# Parse the log details for data quality
parsedDetails <- logDetailsParseDQ(logs$details)

selector <- sapply(o, length) > 0
# Function to extract a specific field from a list of details
# details: list of parsed log details
# field: the field to extract from each detail
applyExtractField <- function(details, field) {
vapply(details, function(x) ifelse(is.null(x[[field]]), NA_character_, x[[field]]), FUN.VALUE = character(1))
}

logs$Action <- applyExtractField(parsedDetails, "Action")
logs$Record <- applyExtractField(parsedDetails, "Record")
logs$Event <- applyExtractField(parsedDetails, "Event")
logs$Field <- applyExtractField(parsedDetails, "Field")
logs$Comment <- applyExtractField(parsedDetails, "Comment")
logs$`Data Quality Rule` <- applyExtractField(parsedDetails, "Data Quality Rule")

selector <- sapply(parsedDetails, length) > 0
logs[selector,c("timestamp", "username", "Action","Record","Event","Field","Data Quality Rule","Comment")]
}

0 comments on commit de4e59b

Please sign in to comment.