Skip to content

Instantly share code, notes, and snippets.

@natecostello
Created April 25, 2023 15:21
Show Gist options
  • Save natecostello/2b39e8bd990b55bdbc7191239d45b4ae to your computer and use it in GitHub Desktop.
Save natecostello/2b39e8bd990b55bdbc7191239d45b4ae to your computer and use it in GitHub Desktop.
Project Queries

These are the queries that I add to each new Project page

The easiest way to do this is to capture them in a single template that you can run for each new project.

#+BEGIN_QUERY
{:title "WAITING"
 :query [:find (pull ?b [*])
       :in $ ?current-page
       :where
       [?p :block/name ?current-page]
       (or-join [?b ?p]
       [?b :block/refs ?p] 
       (and [?p :block/alias ?a] 
          [?b :block/refs ?a]))
       (task ?b #{"WAITING"})]
 :inputs [:query-page]
 :collapsed? false
 :breadcrumb-show? false
 :table-view? true
 :result-transform (fn [r] (map (fn [m] (update m :block/properties (fn [u] (assoc u :check-box (str "[:span {:is \"check-todo10\" :data-uuid \"" (get m :block/uuid) "\"}]"))))) r))
}
#+END_QUERY
#+BEGIN_QUERY
{:title "Next Action"
 :query [:find (pull ?b [*])
       :in $ ?current-page
       :where
       [?p :block/name ?current-page]
       (or-join [?b ?p]
       [?b :block/refs ?p] 
       (and [?p :block/alias ?a] ; this attribute is available only when alias:: has been specified as a page property.
          [?b :block/refs ?a]))
       [?b :block/ref-pages [:block/name "n"] ]
       (task ?b #{"TODO"})]
 :inputs [:query-page]
 :collapsed? false
 :breadcrumb-show? false
:table-view? true
:result-transform (fn [r] (map (fn [m] (update m :block/properties (fn [u] (assoc u :check-box (str "[:span {:is \"check-todo10\" :data-uuid \"" (get m :block/uuid) "\"}]"))))) r))
}
#+END_QUERY
#+BEGIN_QUERY
{:title "All Actions"
 :query [:find (pull ?b [*])
       :in $ ?current-page
       :where
       [?p :block/name ?current-page]
       (or-join [?b ?p]
       [?b :block/refs ?p] 
       (and [?p :block/alias ?a] ; this attribute is available only when alias:: has been specified as a page property.
          [?b :block/refs ?a]))
       (task ?b #{"TODO"})]
 :inputs [:query-page]
 :collapsed? true
 :breadcrumb-show? false
:table-view? true}
#+END_QUERY
#+BEGIN_QUERY
{:title "Complete Actions"
 :query [:find (pull ?b [*])
       :in $ ?current-page
       :where
       [?p :block/name ?current-page]
       (or-join [?b ?p]
       [?b :block/refs ?p] 
       (and [?p :block/alias ?a] ; this attribute is available only when alias:: has been specified as a page property.
          [?b :block/refs ?a]))
       (task ?b #{"DONE"})]
 :inputs [:query-page]
 :collapsed? true
 :breadcrumb-show? false
:table-view? true}
#+END_QUERY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment