ahyatt / ekg

The emacs knowledge graph, app for notes and structured data.
GNU General Public License v3.0
224 stars 18 forks source link

logseq import not working for first run #131

Closed jayrajput closed 8 months ago

jayrajput commented 8 months ago

Got a new Mac mini and setting up things. My triples.db from windows was maintained locally, but the logseq files were backed up to a private repository which I am trying to import, which is not working. How to debug this more?

ekg-logseq-import: importing logseq files changed since the beginning of time itself
ekg-logseq-import: saving note from file /Users/jr/org/logseq/journals/2023_05_26.md
ekg-logseq-import: imported 1 notes
ekg-logseq-export: exporting all tags modified since 2024-01-06 18:02:10: ("date/2023_05_26")
ekg-logseq-export: exporting to file /Users/jr/org/logseq/journals/2023_05_26.org
ekg-logseq-export: deleted 0 files, modified 1 files
jayrajput commented 8 months ago

Checking more. (items (ekg-logseq--to-import-text) is returning nil. Probably it has to do something with moving files from windows to linux.

jayrajput commented 8 months ago

Tried dos2unix on all the files, no changes. No files getting imported. ekg-logseq--to-import-text is returning nil.

jayrajput commented 8 months ago

I can force import by making this change in ekg-logseq--to-import-text function. But after that my notes are seen in markdown-mode by ekg and C-c C-c when editing the notes does not work.

@@ -267,7 +267,7 @@ make less sense without it."
     (if (eq major-mode 'org-mode)
         (org-element-map (org-element-parse-buffer) 'headline
           (lambda (headline)
-            (unless (or (org-element-property :ekg_hash headline)
+            (when (or (org-element-property :ekg_hash headline)
                         (org-element-property :EKG_HASH headline)
                         (> (org-element-property :level headline) 1))
               (buffer-substring-no-properties
jayrajput commented 8 months ago

some test code. I need help on how to fix this. I manually marked the mode to org-mode from triples sqlite, but then realized two more problems 1. Heading are all demoted 2. Properties prefixes are added to all the heading.

(let ((file "~/org/logseq/pages/without-mouse.org"))
  (with-temp-buffer
    (insert-file-contents file)
    (when (equal "org" (file-name-extension file))
      (org-mode))

    (let ((items (org-element-map (org-element-parse-buffer) 'headline
           (lambda (headline)
             (when (or (org-element-property :ekg_hash headline)
                   (org-element-property :EKG_HASH headline)
                   (> (org-element-property :level headline) 1))
               (buffer-substring-no-properties
            (org-element-property :begin headline)
            (org-element-property :end headline))))
           nil nil 'headline)))
      (cl-loop for text in items
           do
           (message text)))))
ahyatt commented 8 months ago

Interesting, thanks for the report and investigation. Let me see if I can figure it out. Can you share an example file? I suppose any file should do, you can replace the text with "lorem ipsum" or something to preserve your privacy.

jayrajput commented 8 months ago

without-mouse.org.txt

ahyatt commented 8 months ago

Thanks!

So, we don't import things already exported by ekg. So if there is an ekg_hash property, we skip it. If your database is empty, though, you probably do want to import it. Ordinarily we wouldn't because we don't want to re-import a note from logseq that you deleted in ekg.

I could make a change to force it always import everything. I'd recommend, though, that if you can just re-use your ekg database, you should. What do you think?

Also, looking at your file, it is a bit weird , because it has two property drawers, and it should just have one. I looked over my logseq output and I see this on a few of my notes as well, but not the majority. This is something I'll look into.

jayrajput commented 8 months ago

I can re-use my triples database. Not a problem.

Interesting design choice though. I realise how allowing the notes to be updating both in ekg and logseq can be problem.

jayrajput commented 8 months ago

closing the issue as able to reuse my triples database.