Skip to content

Commit

Permalink
viewer add publication status column
Browse files Browse the repository at this point in the history
to do this we monkey patch the dataset api call so that it will return
the publication metadata in batch so we can do it in a single request
tgbugs committed Oct 26, 2023
1 parent 27a49e1 commit 6760794
Showing 4 changed files with 25 additions and 7 deletions.
3 changes: 2 additions & 1 deletion docs/developer-guide.org
Original file line number Diff line number Diff line change
@@ -4262,7 +4262,8 @@ def main(id=None, **kwargs):
f"{json.dumps(d.name)} "
f"{json.dumps(d.updated)} "
f"{json.dumps(d.owner.name_or_email)} "
f"{json.dumps(d.parent_id)}"
f"{json.dumps(d.parent_id)} "
f"{json.dumps(d.bfobject.publication_status)}"
")")
for d in sorted(datasets, key=key, reverse=True)])
dsmeta = f"({_dsmeta})"
13 changes: 13 additions & 0 deletions sparcur/monkey.py
Original file line number Diff line number Diff line change
@@ -558,3 +558,16 @@ def Dataset_meta(self):
@property
def Organization_teams(self):
return _get_json(self, f'{self._api._host}/organizations/{self.id}/teams')

def bind_dga(Dataset):
def insert_extra(ds, self):
d = Dataset.from_dict(ds, api=self.session)
d.publication_status = ds['publication']['status']
d.canPublish = ds['canPublish']
return d

def DatasetAPI_get_all(self):
resp = self._get(self._uri("/?includePublishedDataset=true"))
return [insert_extra(ds, self) for ds in resp]

return DatasetAPI_get_all
3 changes: 2 additions & 1 deletion sparcur/pennsieve_api.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
from pennsieve import Organization, Dataset, Collection, File
from pennsieve import base as pnb
from pennsieve.api import agent, transfers
from pennsieve.api.data import PackagesAPI
from pennsieve.api.data import PackagesAPI, DatasetsAPI
from sparcur import monkey
from sparcur.utils import ApiWrapper, PennsieveId, make_bf_cache_as_classes

@@ -67,6 +67,7 @@ class PNLocal(ApiWrapper):
Dataset.packages = monkey.packages
Dataset._packages = _packages
Pennsieve.get = monkey.Blackfynn_get
DatasetsAPI.get_all = monkey.bind_dga(Dataset)
#PackagesAPI.get = monkey.PackagesAPI_get


13 changes: 8 additions & 5 deletions sparcur_internal/sparcur/viewer.rkt
Original file line number Diff line number Diff line change
@@ -782,7 +782,7 @@ note of course that you don't get dynamic binding with version since it is not t
(export-dataset ds)
(is-current? ds))

(struct dataset (id title updated pi-name-lf id-project)
(struct dataset (id title updated pi-name-lf id-project publication-status)
#:methods gen:ds
[(define (populate-list ds list-box)
; FIXME annoyingly it looks like these things need to be set in
@@ -792,14 +792,16 @@ note of course that you don't get dynamic binding with version since it is not t
(dataset-pi-name-lf ds)
(dataset-title ds)
(id-short ds)
(updated-short ds))
(updated-short ds)
(dataset-publication-status ds))
ds))
(define (lb-cols ds)
(list
(dataset-pi-name-lf ds)
(dataset-title ds)
(id-short ds)
(updated-short ds)))
(updated-short ds)
(dataset-publication-status ds)))
(define (lb-data ds)
; TODO we may want to return more stuff here
ds)
@@ -1092,7 +1094,8 @@ note of course that you don't get dynamic binding with version since it is not t
[(0) (compose string-downcase dataset-pi-name-lf)]
[(1) (compose string-downcase dataset-title)]
[(2) id-uuid]
[(3) dataset-updated]))
[(3) dataset-updated]
[(4) dataset-publication-status]))
(lambda (ds1 ds2)
(operator (selector ds1) (selector ds2))))

@@ -1815,7 +1818,7 @@ switch to that"
[label ""]
[font (make-object font% 10 'modern)]
[choices '()]
[columns '("Owner" "Folder Name" "Identifier" "Updated")]
[columns '("Owner" "Folder Name" "Identifier" "Updated" "PubStat")]
; really is single selection though we want to be
; able to highlight and reorder multiple
[style '(single column-headers clickable-headers)]

0 comments on commit 6760794

Please sign in to comment.