add arcology-feeds table which will contain ARCOLOGY_FEEDs and nearby data

main
Ryan Rix 2022-12-28 16:12:25 -08:00
parent 9693b4871e
commit ad96066e52
2 changed files with 97 additions and 6 deletions

View File

@ -757,6 +757,61 @@ A page has any number of refs according to the file primary key:
(vector file (format "%s:%s" type ref) node-id))))
#+end_src
* Arcology Feeds
:PROPERTIES:
:ID: arcology/arroyo/feed
:END:
#+NAME: arcology.arroyo.Feed
#+begin_src python
class Feed(SQLModel, table=True):
__tablename__ = "arcology_feeds"
file: str = Field(primary_key=True, foreign_key="arcology_pages.file")
key: str = Field(primary_key=True, description="The routing key for the feed.")
title: str = Field(description="Title of the page which the feed is embedded in")
site: str = Field(description="Arcology Site which the feed resides on.")
post_visibility: str = Field(description="Visibility of the feed's posts in feed2toot, etc")
def get_key(self):
return parse_sexp(self.key)
def get_arcology_key(self):
return ArcologyKey(self.get_key())
def get_title(self):
return parse_sexp(self.title)
def get_site(self):
return parse_sexp(self.site)
def get_post_visibility(self):
return parse_sexp(self.post_visibility)
#+end_src
A page has any number of feeds according to the file primary key:
#+begin_src emacs-lisp
(add-to-list 'arroyo-db--schemata
'(arcology-feeds
[(file :not-null)
(key :not-null)
(title :not-null)
(site :not-null)
(post-visibility :not-null)]))
(defun arroyo-arcology--insert-feeds (file)
(arroyo-db-query [:delete :from arcology-feeds
:where (= file $s1)]
file)
(if-let* ((key (car (arroyo-db-get "ARCOLOGY_FEED" file)))
(site (replace-regexp-in-string "/.*" "" key)))
(let* ((title (arroyo-db--get-file-title-from-org-roam file))
(post-visibility (car (arroyo-db-get "ARCOLOGY_TOOT_VISIBILITY" file))))
(arroyo-db-query [:insert :into arcology-feeds
:values $v1]
(vector file key title site post-visibility)))))
#+end_src
* Arcology Keywords
:PROPERTIES:
:ID: arcology/arroyo/keyword
@ -830,13 +885,20 @@ Putting all those update functions together in an [[id:arroyo/system-cache][arro
(arroyo-arcology--insert-nodes file page-nodes)
(arroyo-arcology--insert-tags file all-node-tags)
(arroyo-arcology--insert-refs file all-node-refs)
(arroyo-arcology--insert-feeds file)
(arroyo-arcology--insert-links file level-0-title links))))
(defun arroyo-arcology-update-db (&optional _wut)
(interactive)
(-map (lambda (file)
(arroyo-arcology-update-file file))
(-map #'car (arroyo-db-get "ARCOLOGY_KEY"))))
(->>
(arroyo-db-get "ARCOLOGY_KEY")
(-map #'car)
(-uniq)
;; this runs *after* db is updated... what to do here?
;; (-filter #'arroyo-db-file-updated-p)
(-map #'arroyo-arcology-update-file)
)
)
(add-function :after (symbol-function 'arroyo-db-update-all-roam-files) #'arroyo-arcology-update-db)
;; (add-to-list 'arroyo-db-update-functions #'arroyo-arcology-update-file)

View File

@ -118,6 +118,28 @@
(vector file (format "%s:%s" type ref) node-id))))
;; Arcology References:2 ends here
;; [[file:arcology-arroyo.org::*Arcology Feeds][Arcology Feeds:2]]
(add-to-list 'arroyo-db--schemata
'(arcology-feeds
[(file :not-null)
(key :not-null)
(title :not-null)
(site :not-null)
(post-visibility :not-null)]))
(defun arroyo-arcology--insert-feeds (file)
(arroyo-db-query [:delete :from arcology-feeds
:where (= file $s1)]
file)
(if-let* ((key (car (arroyo-db-get "ARCOLOGY_FEED" file)))
(site (replace-regexp-in-string "/.*" "" key)))
(let* ((title (arroyo-db--get-file-title-from-org-roam file))
(post-visibility (car (arroyo-db-get "ARCOLOGY_TOOT_VISIBILITY" file))))
(arroyo-db-query [:insert :into arcology-feeds
:values $v1]
(vector file key title site post-visibility)))))
;; Arcology Feeds:2 ends here
;; [[file:arcology-arroyo.org::*Arcology \[\[id:arroyo/arroyo\]\[Arroyo System\]\] Database Generator][Arcology [[id:arroyo/arroyo][Arroyo System]] Database Generator:1]]
(defun arroyo-arcology-update-file (&optional file)
(interactive)
@ -150,13 +172,20 @@
(arroyo-arcology--insert-nodes file page-nodes)
(arroyo-arcology--insert-tags file all-node-tags)
(arroyo-arcology--insert-refs file all-node-refs)
(arroyo-arcology--insert-feeds file)
(arroyo-arcology--insert-links file level-0-title links))))
(defun arroyo-arcology-update-db (&optional _wut)
(interactive)
(-map (lambda (file)
(arroyo-arcology-update-file file))
(-map #'car (arroyo-db-get "ARCOLOGY_KEY"))))
(->>
(arroyo-db-get "ARCOLOGY_KEY")
(-map #'car)
(-uniq)
;; this runs *after* db is updated... what to do here?
;; (-filter #'arroyo-db-file-updated-p)
(-map #'arroyo-arcology-update-file)
)
)
(add-function :after (symbol-function 'arroyo-db-update-all-roam-files) #'arroyo-arcology-update-db)
;; (add-to-list 'arroyo-db-update-functions #'arroyo-arcology-update-file)