aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2026-01-28 19:52:42 +0300
committerMunyoki Kilyungi2026-01-28 19:52:42 +0300
commitd406077de178ac74776e998b70be323baa9a8384 (patch)
treea82aa72ac140f40d75aaa97cbe844dde49f322b9
parent42b7ce31eb86551fa55c50bbc6a252fc172771c6 (diff)
downloadgn-transform-databases-d406077de178ac74776e998b70be323baa9a8384.tar.gz
Move fix-email-id/investigator-attributes->id to string.scm
* examples/dataset-metadata.scm (fix-email-id, investigator-attributes->id): Move this ... * transform/strings.scm: here. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rwxr-xr-xexamples/dataset-metadata.scm18
-rw-r--r--transform/strings.scm31
2 files changed, 25 insertions, 24 deletions
diff --git a/examples/dataset-metadata.scm b/examples/dataset-metadata.scm
index 53ff2d7..783b90c 100755
--- a/examples/dataset-metadata.scm
+++ b/examples/dataset-metadata.scm
@@ -12,24 +12,6 @@
(transform special-forms))
-
-;; One email ID in the Investigators table has spaces in it. This
-;; function fixes that.
-(define (fix-email-id email)
- (string-delete #\space email))
-
-(define (investigator-attributes->id first-name last-name email)
- ;; There is just one record corresponding to "Evan Williams" which
- ;; does not have an email ID. To accommodate that record, we
- ;; construct the investigator ID from not just the email ID, but
- ;; also the first and the last names. It would be preferable to just
- ;; find Evan Williams' email ID and insert it into the database.
- (string->identifier "investigator"
- (string-join
- (list first-name last-name (fix-email-id email))
- "_")
- #:separator "_"))
-
(define-transformer investigators
;; There are a few duplicate entries. We group by email to
;; deduplicate.
diff --git a/transform/strings.scm b/transform/strings.scm
index aba554a..7544399 100644
--- a/transform/strings.scm
+++ b/transform/strings.scm
@@ -15,15 +15,34 @@
snake->lower-camel
lower-case-and-replace-spaces
string-capitalize-first
- normalize-string-field))
+ normalize-string-field
+ fix-email-id
+ investigator-attributes->id))
+
+;; One email ID in the Investigators table has spaces in it. This
+;; function fixes that.
+(define (fix-email-id email)
+ (string-delete #\space email))
+
+(define (investigator-attributes->id first-name last-name email)
+ ;; There is just one record corresponding to "Evan Williams" which
+ ;; does not have an email ID. To accommodate that record, we
+ ;; construct the investigator ID from not just the email ID, but
+ ;; also the first and the last names. It would be preferable to just
+ ;; find Evan Williams' email ID and insert it into the database.
+ (string->identifier "investigator"
+ (string-join
+ (list first-name last-name (fix-email-id email))
+ "_")
+ #:separator "_"))
(define (lower-case-and-replace-spaces str)
(string-map
- (lambda (c)
- (if (char=? c #\space)
- #\- ; replace space with hyphen
- c)) ; convert character to lower case
- (string-downcase str)))
+ (lambda (c)
+ (if (char=? c #\space)
+ #\- ; replace space with hyphen
+ c)) ; convert character to lower case
+ (string-downcase str)))
(define (time-unix->string seconds . maybe-format)
"Given an integer saying the number of seconds since the Unix