Skip to content

Instantly share code, notes, and snippets.

@ninjudd
Created May 29, 2012 20:09
Show Gist options
  • Select an option

  • Save ninjudd/2830413 to your computer and use it in GitHub Desktop.

Select an option

Save ninjudd/2830413 to your computer and use it in GitHub Desktop.
src/gedcom_importer/core.clj | 6 +++---
src/gedcom_importer/indi.clj | 13 ++++++++-----
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/gedcom_importer/core.clj b/src/gedcom_importer/core.clj
index 8eaa08f..9ccea9f 100644
--- a/src/gedcom_importer/core.clj
+++ b/src/gedcom_importer/core.clj
@@ -19,8 +19,8 @@
:when (not (contains? (:profiles processing) profile-id))]
(if-let [processed-id (geni-id (get-in processed [:profiles (keyword profile-id)]))]
[[profile-id processed-id]]
- (let [[fams record] (indi/indi (get records profile-id))]
- [[profile-id record] (remove #{fam-id} fams)])))]
+ (let [record (indi/indi (get records profile-id))]
+ [[profile-id record] (remove #{fam-id} (indi/fams record))])))]
[{:profiles (into {} (map first results))
:unions {fam-id fam}}
(mapcat second results)]))
@@ -74,7 +74,7 @@
[file label token]
(let [records (ged/parse-gedcom file)]
(loop [processed {:profiles {(keyword label) (:id (geni/read "/profile" {:token token}))}}
- fams-to-process (-> (get records label) indi/indi first)]
+ fams-to-process (indi/fams (indi/indi (get records label)))]
(when (seq fams-to-process)
(let [fam-groups (unions records fams-to-process)
[done unprocessed] (import-groups records token processed fam-groups)]
diff --git a/src/gedcom_importer/indi.clj b/src/gedcom_importer/indi.clj
index a4cd916..097fb98 100644
--- a/src/gedcom_importer/indi.clj
+++ b/src/gedcom_importer/indi.clj
@@ -144,9 +144,12 @@
"Parse an INDI record and return a map suitable for passing
to the Geni API."
[records]
- (let [parsed (reduce merge (map to-geni records))
- final (if (contains? parsed :is_alive)
+ (let [parsed (reduce merge (map to-geni records))]
+ (if (contains? parsed :is_alive)
parsed
- (assoc parsed :is_alive true))]
- [(apply concat ((juxt :child :spouse) final))
- (dissoc final :child :spouse)]))
+ (assoc parsed :is_alive true))))
+
+(defn fams
+ "Return the FAM links for an already parsed INDI record."
+ [indi]
+ (mapcat indi [:child :spouse]))
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment