Skip to content

d12frosted/vulpea-test-notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vulpea test notes

A set of generated notes for testing purposes. Used by vulpea library. This repository contains the following items.

  1. Scripts to generate notes and database.
  2. 9k+ generated notes.
  3. org-roam.db for these notes. It is included along with notes, because it takes few minutes to build it. In order to make it usable, all file paths are converted into org-roam-directory relative file paths. See usage instructions to learn how to restore database. Also keep in mind that this database also contains extra tables defined by vulpea library.

Rebuild org-roam.db

If you wish to simply update/synchronise org-roam.db file, use the following command.

$ make db

Generate notes

In case you wish to generate a new set of notes, use the following command. Please note that it might take more than an hour (because it uses vino library to create semi-real notes).

$ make generate

Using in tests

Since org-roam uses absolute file paths, generally org-roam.db is not portable. So in order to achieve this, all file paths in org-roam.db are turned into org-roam-directory relative file paths. In order to restore them, use the following code in your tests.

(when (file-exists-p org-roam-db-location)
  (let ((db (emacsql-sqlite org-roam-db-location)))
    (message "Count of notes: %s"
             (caar (emacsql db "select count(*) from nodes")))
    (emacsql db [:pragma (= foreign_keys 0)])
    (emacsql db (format "update nodes set file = '\"' || '%s' || replace(file, '\"', '') || '\"'"
                        (file-name-as-directory org-roam-directory)))
    (emacsql db (format "update files set file = '\"' || '%s' || replace(file, '\"', '') || '\"'"
                        (file-name-as-directory org-roam-directory)))
    (emacsql db (format "update notes set path = '\"' || '%s' || replace(path, '\"', '') || '\"'"
                        (file-name-as-directory org-roam-directory)))))

Full example of initialization can be found in vulpea-perf-test.el. Just for future-proof reference:

(cl-defun vulpea-perf--init (&key db-file-name
                                  disable-org-roam-autosync
                                  disable-vulpea-autosync)
  "Initialize performance testing environment.

DB-FILE-NAME allows to override default file name of
`org-roam-db-location'.

When DISABLE-ORG-ROAM-AUTOSYNC is non-nil,
`org-roam-db-autosync-mode' will not be enabled.

When DISABLE-VULPEA-AUTOSYNC is non-nil,
`vulpea-db-autosync-mode' will not be enabled."
  (let* ((temp-loc (expand-file-name (make-temp-name "note-files") temporary-file-directory))
         (zip-file-loc (concat temp-loc ".zip"))
         (_ (url-copy-file vulpea-perf-zip-url zip-file-loc))
         (_ (shell-command (format "mkdir -p %s && unzip -qq %s -d %s" temp-loc zip-file-loc temp-loc)))
         (test-notes-dir (expand-file-name
                          (format "vulpea-test-notes-%s/"
                                  vulpea-perf-zip-branch)
                          temp-loc))
         (db-file-name (or db-file-name "org-roam.db")))
    (setq org-roam-directory (expand-file-name "notes/" test-notes-dir)
          org-roam-db-location (expand-file-name db-file-name org-roam-directory))
    (message "Initializing vulpea in %s" org-roam-directory)
    ;; fix file path values
    (when (file-exists-p org-roam-db-location)
      (let ((db (emacsql-sqlite org-roam-db-location)))
        (message "Count of notes: %s"
                 (caar (emacsql db "select count(*) from nodes")))
        (emacsql db [:pragma (= foreign_keys 0)])
        (emacsql db (format "update nodes set file = '\"' || '%s' || replace(file, '\"', '') || '\"'"
                            (file-name-as-directory org-roam-directory)))
        (emacsql db (format "update files set file = '\"' || '%s' || replace(file, '\"', '') || '\"'"
                            (file-name-as-directory org-roam-directory)))
        (emacsql db (format "update notes set path = '\"' || '%s' || replace(path, '\"', '') || '\"'"
                            (file-name-as-directory org-roam-directory)))))
    (unless disable-vulpea-autosync
      (vulpea-db-autosync-enable))
    (unless disable-org-roam-autosync
      (org-roam-db-autosync-enable))))

About

Just some generated notes to test performance

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published