Browse Source

Redis get resource

master
Christian Fischer 10 months ago
parent
commit
3551946380
3 changed files with 39 additions and 18 deletions
  1. +1
    -1
      server/db.rkt
  2. +1
    -1
      server/groups.rkt
  3. +37
    -16
      server/resource.rkt

+ 1
- 1
server/db.rkt View File

@@ -5,7 +5,7 @@
json
threading)

;; (provide )
(provide connect-redis)

(define (connect-redis)
(make-redis))


+ 1
- 1
server/groups.rkt View File

@@ -41,7 +41,7 @@
(~> (dict-ref group-json k)
(string->jsexpr)
(list->set)))
(group id
(group id ;;parse to number? does it matter?
(parse "admins")
(parse "members"))))



+ 37
- 16
server/resource.rkt View File

@@ -1,6 +1,7 @@
#lang racket

(require db
redis
json
threading
"db.rkt"
@@ -21,22 +22,34 @@
; actions. The `type` designates what kind of resource it is, e.g.
; dataset, collection, etc. The actions available depend on the
; resource type.
(struct resource (name owner data type group-masks))

(define (select-resources dbc)
(query-rows dbc
"select * from resources"))

(define (insert-resource dbc name owner data type)
(query-exec dbc
"insert into resources (name, owner_id, resource_data, resource_type)
values (?,?,?,?)"
name
owner
data
type))


(struct resource (name owner data type default-mask group-masks))

(define (get-resource dbc id)
(let ((res-json (string->jsexpr (redis-hash-get dbc "resources" id))))
(resource (dict-ref res-json "name")
(dict-ref res-json "owner")
(dict-ref res-json "data") ;; may change
(dict-ref res-json "type")
(~> (dict-ref res-json "default_mask")
;; not sure if these conversions are necessary, but
;; i think it is
(string->jsexpr))
(~> (dict-ref res-json "group_masks")
(string->jsexpr)))))


;; (define (select-resources dbc)
;; (query-rows dbc
;; "select * from resources"))

;; (define (insert-resource dbc name owner data type)
;; (query-exec dbc
;; "insert into resources (name, owner_id, resource_data, resource_type)
;; values (?,?,?,?)"
;; name
;; owner
;; data
;; type))

(define resource-types
'(dataset-publish
@@ -45,6 +58,14 @@
dataset-temp
collection))



(define dataset-publish
#hash(("data" . ("no-access" "view" "edit") )
("metadata" . ("no-access" "view" "edit"))
("admin" . ("no-access" "edit-access" "edit-admins"))))


(define (select-publish dbc dataset-id trait-name)
(query-row dbc
"SELECT


Loading…
Cancel
Save