cbickel closed pull request #2763: Remove old views
URL: https://github.com/apache/incubator-openwhisk/pull/2763
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ansible/files/whisks_design_document_for_actions_db.json 
b/ansible/files/whisks_design_document_for_actions_db.json
deleted file mode 100644
index 2949be53f2..0000000000
--- a/ansible/files/whisks_design_document_for_actions_db.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
-  "_id": "_design/whisks",
-  "views": {
-    "all": {
-      "map": "function (doc) {\n  var PATHSEP = \"/\";\n\n  var isPackage = 
function (doc) {  return (doc.binding !== undefined) };\n  var isAction = 
function (doc) { return (doc.exec !== undefined) };\n  var isTrigger = function 
(doc) { return (doc.exec === undefined && doc.binding === undefined && 
doc.parameters !== undefined) };\n  var isRule = function (doc) {  return 
(doc.trigger !== undefined) };\n  \n  var collection = function (doc) {\n    if 
(isPackage(doc)) return \"packages\";\n    if (isAction(doc)) return 
\"actions\";\n    if (isTrigger(doc)) return \"triggers\";\n    if 
(isRule(doc)) return \"rules\";\n    return \"??\";\n  };\n\n  try {\n    var 
ns = doc.namespace.split(PATHSEP);\n    var root = ns[0]; ns.shift();\n    var 
type = collection(doc);\n    var date = new Date(doc.start || doc.updated);\n   
 var value = {collection: type, namespace: doc.namespace, name: doc.name, 
version: doc.version, publish: doc.publish, annotations: doc.annotations};\n    
if (isPackage(doc)) {\n      value.binding = Object.keys(doc.binding).length 
!== 0;\n    }\n    emit([root, date], value);\n  } catch (e) {}\n}"
-    },
-    "entities": {
-      "map": "function (doc) {\n  var PATHSEP = \"/\";\n\n  var isPackage = 
function (doc) {  return (doc.binding !== undefined) };\n  var isAction = 
function (doc) { return (doc.exec !== undefined) };\n  var isTrigger = function 
(doc) { return (doc.exec === undefined && doc.binding === undefined && 
doc.parameters !== undefined) };\n  var isRule = function (doc) {  return 
(doc.trigger !== undefined) };\n  \n  var collection = function (doc) {\n    if 
(isPackage(doc)) return \"packages\";\n    if (isAction(doc)) return 
\"actions\";\n    if (isTrigger(doc)) return \"triggers\";\n    if 
(isRule(doc)) return \"rules\";\n    return \"??\";\n  };\n\n  try {\n    var 
ns = doc.namespace.split(PATHSEP);\n    var root = ns[0]; ns.shift();\n    var 
type = collection(doc);\n    var date = new Date(doc.start || doc.updated);\n   
 var value = {collection: type, namespace: doc.namespace, name: doc.name, 
version: doc.version, publish: doc.publish, annotations: doc.annotations};\n    
if (isPackage(doc)) {\n      value.binding = Object.keys(doc.binding).length 
!== 0;\n    }\n    emit([root, date], value);\n  } catch (e) {}\n}"
-    },
-    "packages": {
-      "map": "function (doc) {\n  var PATHSEP = \"/\";\n\n  var isPackage = 
function (doc) {  return (doc.binding !== undefined) };\n  var isAction = 
function (doc) { return (doc.exec !== undefined) };\n  var isTrigger = function 
(doc) { return (doc.exec === undefined && doc.binding === undefined && 
doc.parameters !== undefined) };\n  var isRule = function (doc) {  return 
(doc.trigger !== undefined) };\n\n  if (isPackage(doc)) try {\n    var date = 
new Date(doc.start || doc.updated);\n    emit([doc.namespace, date.getTime(), 
doc.name], {namespace: doc.namespace, name: doc.name, version: doc.version, 
publish: doc.publish, annotations: doc.annotations, binding: 
Object.keys(doc.binding).length !== 0});\n  } catch (e) {}\n}"
-    },
-    "packages-all": {
-      "reduce": "function (keys, values, rereduce) {\n  var isPublicPackage = 
function(p) { return p.publish && !p.binding; };\n\n  if (rereduce) {\n    
return [].concat.apply([], values);\n  } else {\n    return 
values.filter(isPublicPackage);\n  }\n}",
-      "map": "function (doc) {\n  var PATHSEP = \"/\";\n\n  var isPackage = 
function (doc) {  return (doc.binding !== undefined) };\n  var isAction = 
function (doc) { return (doc.exec !== undefined) };\n  var isTrigger = function 
(doc) { return (doc.exec === undefined && doc.binding === undefined && 
doc.parameters !== undefined) };\n  var isRule = function (doc) {  return 
(doc.trigger !== undefined) };\n\n  if (isPackage(doc)) try {\n    var date = 
new Date(doc.start || doc.updated);\n    emit([date.getTime(), doc.name], 
{namespace: doc.namespace, name: doc.name, version: doc.version, publish: 
doc.publish, annotations: doc.annotations, binding: 
Object.keys(doc.binding).length !== 0});\n  } catch (e) {}\n}"
-    },
-    "actions": {
-      "map": "function (doc) {\n  var PATHSEP = \"/\";\n\n  var isPackage = 
function (doc) {  return (doc.binding !== undefined) };\n  var isAction = 
function (doc) { return (doc.exec !== undefined) };\n  var isTrigger = function 
(doc) { return (doc.exec === undefined && doc.binding === undefined && 
doc.parameters !== undefined) };\n  var isRule = function (doc) {  return 
(doc.trigger !== undefined) };\n\n  if (isAction(doc)) try {\n    var ns = 
doc.namespace.split(PATHSEP);\n    var root = ns[0]; ns.shift();\n    var date 
= new Date(doc.start || doc.updated);\n    emit([doc.namespace, date.getTime(), 
doc.name], {namespace: doc.namespace, name: doc.name, version: doc.version, 
publish: doc.publish, annotations: doc.annotations});\n    if (root !== 
doc.namespace) {\n      emit([root, date.getTime(), doc.name], {namespace: 
doc.namespace, name: doc.name, version: doc.version, publish: doc.publish, 
annotations: doc.annotations});\n    }\n  } catch (e) {}\n}"
-    },
-    "triggers": {
-      "map": "function (doc) {\n  var PATHSEP = \"/\";\n\n  var isPackage = 
function (doc) {  return (doc.binding !== undefined) };\n  var isAction = 
function (doc) { return (doc.exec !== undefined) };\n  var isTrigger = function 
(doc) { return (doc.exec === undefined && doc.binding === undefined && 
doc.parameters !== undefined) };\n  var isRule = function (doc) {  return 
(doc.trigger !== undefined) };\n\n  if (isTrigger(doc)) try {\n    var ns = 
doc.namespace.split(PATHSEP);\n    var root = ns[0]; ns.shift();\n    var date 
= new Date(doc.start || doc.updated);\n    emit([doc.namespace, date.getTime(), 
doc.name], {namespace: doc.namespace, name: doc.name, version: doc.version, 
publish: doc.publish, annotations: doc.annotations});\n    if (root !== 
doc.namespace) {\n      emit([root, date.getTime(), doc.name], {namespace: 
doc.namespace, name: doc.name, version: doc.version, publish: doc.publish, 
annotations: doc.annotations});\n    }\n  } catch (e) {}\n}"
-    },
-    "rules": {
-      "map": "function (doc) {\n  var PATHSEP = \"/\";\n\n  var isPackage = 
function (doc) {  return (doc.binding !== undefined) };\n  var isAction = 
function (doc) { return (doc.exec !== undefined) };\n  var isTrigger = function 
(doc) { return (doc.exec === undefined && doc.binding === undefined && 
doc.parameters !== undefined) };\n  var isRule = function (doc) {  return 
(doc.trigger !== undefined) };\n\n  if (isRule(doc)) try {\n    var ns = 
doc.namespace.split(PATHSEP);\n    var root = ns[0]; ns.shift();\n    var date 
= new Date(doc.start || doc.updated);\n    emit([doc.namespace, date.getTime(), 
doc.name], {namespace: doc.namespace, name: doc.name, version: doc.version, 
publish: doc.publish, annotations: doc.annotations});\n    if (root !== 
doc.namespace) {\n      emit([root, date.getTime(), doc.name], {namespace: 
doc.namespace, name: doc.name, version: doc.version, publish: doc.publish, 
annotations: doc.annotations});\n    }\n  } catch (e) {}\n}"
-    }
-  },
-  "language": "javascript"
-}
diff --git a/ansible/files/whisks_design_document_for_activations_db.json 
b/ansible/files/whisks_design_document_for_activations_db.json
deleted file mode 100644
index 5bd0c606db..0000000000
--- a/ansible/files/whisks_design_document_for_activations_db.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
-  "_id": "_design/whisks",
-  "views": {
-    "all": {
-      "map": "function (doc) {\n  var PATHSEP = \"/\";\n  var isActivation = 
function (doc) { return (doc.activationId !== undefined) };\n  var collection = 
function (doc) {\n    if (isActivation(doc)) return \"activations\";\n    
return \"??\";\n  };\n\n  if (isActivation(doc)) try {\n    var ns = 
doc.namespace.split(PATHSEP);\n    var root = ns[0]; ns.shift();\n    var type 
= collection(doc);\n    var date = new Date(doc.start || doc.updated);\n    var 
value = {collection: type, namespace: doc.namespace, name: doc.name, version: 
doc.version, publish: doc.publish, annotations: doc.annotations};\n    
value.activationId = doc.activationId;\n    emit([root, date], value);\n  } 
catch (e) {}\n}\n"
-    },
-    "activations": {
-      "map": "function (doc) {\n  var PATHSEP = \"/\";\n  var isActivation = 
function (doc) { return (doc.activationId !== undefined) };\n\n  if 
(isActivation(doc)) try {\n    var date = new Date(doc.start || doc.updated);\n 
   emit([doc.namespace, date.getTime(), doc.name], {namespace: doc.namespace, 
name: doc.name, version: doc.version, publish: doc.publish, annotations: 
doc.annotations, activationId: doc.activationId});\n    
emit([doc.namespace+PATHSEP+doc.name, date.getTime()], {namespace: 
doc.namespace, name: doc.name, version: doc.version, publish: doc.publish, 
annotations: doc.annotations, activationId: doc.activationId});\n  } catch (e) 
{}\n}\n"
-    }
-  },
-  "language": "javascript"
-}
diff --git a/ansible/tasks/recreateViews.yml b/ansible/tasks/recreateViews.yml
index 682ca94e39..a5b6048140 100644
--- a/ansible/tasks/recreateViews.yml
+++ b/ansible/tasks/recreateViews.yml
@@ -6,7 +6,6 @@
     dbName: "{{ db.whisk.actions }}"
     doc: "{{ lookup('file', '{{ item }}') }}"
   with_items:
-    - "{{ openwhisk_home 
}}/ansible/files/whisks_design_document_for_actions_db.json"
     - "{{ openwhisk_home 
}}/ansible/files/whisks_design_document_for_entities_db_v2.json"
     - "{{ openwhisk_home }}/ansible/files/filter_design_document.json"
 
@@ -15,7 +14,6 @@
     dbName: "{{ db.whisk.activations }}"
     doc: "{{ lookup('file', '{{ item }}') }}"
   with_items:
-    - "{{ openwhisk_home 
}}/ansible/files/whisks_design_document_for_activations_db.json"
     - "{{ openwhisk_home 
}}/ansible/files/whisks_design_document_for_activations_db_v2.json"
     - "{{ openwhisk_home 
}}/ansible/files/whisks_design_document_for_activations_db_filters_v2.json"
     - "{{ openwhisk_home }}/ansible/files/filter_design_document.json"
diff --git 
a/common/scala/src/main/scala/whisk/core/entity/WhiskActivation.scala 
b/common/scala/src/main/scala/whisk/core/entity/WhiskActivation.scala
index 596a5ecbc0..1e04b11dd3 100644
--- a/common/scala/src/main/scala/whisk/core/entity/WhiskActivation.scala
+++ b/common/scala/src/main/scala/whisk/core/entity/WhiskActivation.scala
@@ -79,7 +79,6 @@ case class WhiskActivation(namespace: EntityPath,
   /** This the activation summary as computed by the database view. Strictly 
used for testing. */
   override def summaryAsJson = {
     import WhiskActivation.instantSerdes
-    val summary = JsObject(super.summaryAsJson.fields + ("activationId" -> 
activationId.toJson))
 
     def actionOrNot() = {
       if (end != Instant.EPOCH) {
@@ -90,13 +89,12 @@ case class WhiskActivation(namespace: EntityPath,
       } else Map.empty
     }
 
-    if (WhiskActivation.mainDdoc.endsWith(".v2")) {
-      JsObject(
-        summary.fields +
-          ("start" -> start.toJson) ++
-          cause.map(("cause" -> _.toJson)) ++
-          actionOrNot())
-    } else summary
+    JsObject(
+      super.summaryAsJson.fields +
+        ("activationId" -> activationId.toJson) +
+        ("start" -> start.toJson) ++
+        cause.map(("cause" -> _.toJson)) ++
+        actionOrNot())
   }
 
   def resultAsJson = response.result.toJson.asJsObject


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to