Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report #10

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")]
}
Loading