[ARVADOS-WORKBENCH2] updated: 1.2.0-189-gc798ba7

Git user git at public.curoverse.com
Wed Aug 29 08:43:50 EDT 2018


Summary of changes:
 src/store/processes/process.ts   | 16 ++++++++++++++++
 src/store/resources/resources.ts | 10 +++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

       via  c798ba784db88b406d27f3783501ab2800f5719a (commit)
      from  3bf48201c92fcb9827d134a96671f02035f544a6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit c798ba784db88b406d27f3783501ab2800f5719a
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Wed Aug 29 14:43:33 2018 +0200

    Create process selectors
    
    Feature #14099
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/processes/process.ts b/src/store/processes/process.ts
index 17ad695..b3935ed 100644
--- a/src/store/processes/process.ts
+++ b/src/store/processes/process.ts
@@ -5,6 +5,8 @@
 import { ContainerRequestResource } from '../../models/container-request';
 import { ContainerResource } from '../../models/container';
 import { ResourcesState, getResource } from '~/store/resources/resources';
+import { filterResources } from '../resources/resources';
+import { ResourceKind, Resource } from '~/models/resource';
 
 export interface Process {
     containerRequest: ContainerRequestResource;
@@ -24,3 +26,17 @@ export const getProcess = (uuid: string) => (resources: ResourcesState): Process
     }
     return;
 };
+
+export const getSubprocesses = (uuid: string) => (resources: ResourcesState) => {
+    const containerRequests = filterResources(isSubprocess(uuid)(resources))(resources) as ContainerRequestResource[];
+    return containerRequests.reduce((subprocesses, { uuid }) => {
+        const process = getProcess(uuid)(resources);
+        return process
+            ? [...subprocesses, process]
+            : subprocesses;
+    }, []);
+};
+
+const isSubprocess = (uuid: string) => (resources: ResourcesState) => (resource: Resource) =>
+    resource.kind === ResourceKind.CONTAINER_REQUEST
+    && (resource as ContainerRequestResource).requestingContainerUuid === uuid;
diff --git a/src/store/resources/resources.ts b/src/store/resources/resources.ts
index add4efe..10c82ff 100644
--- a/src/store/resources/resources.ts
+++ b/src/store/resources/resources.ts
@@ -19,7 +19,7 @@ export const setResource = <T extends Resource>(id: string, data: T) =>
 
 export const deleteResource = (id: string) =>
     (state: ResourcesState) => {
-        const newState = {...state};
+        const newState = { ...state };
         delete newState[id];
         return newState;
     };
@@ -28,10 +28,14 @@ export const filterResources = (filter: (resource: Resource) => boolean) =>
     (state: ResourcesState) =>
         Object
             .keys(state)
-            .map(id => getResource(id)(state))
+            .reduce((resources, id) => {
+                const resource = getResource(id)(state);
+                return resource
+                    ? [...resources, resource]
+                    : resources;
+            }, [])
             .filter(filter);
 
 export const filterResourcesByKind = (kind: ResourceKind) =>
     (state: ResourcesState) =>
         filterResources(resource => resource.kind === kind)(state);
-

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list