tloubrieu-jpl commented on a change in pull request #104:
URL: 
https://github.com/apache/incubator-sdap-nexus/pull/104#discussion_r451855059



##########
File path: analysis/webservice/algorithms/NexusCalcHandler.py
##########
@@ -0,0 +1,70 @@
+import time
+import types
+
+from nexustiles.nexustiles import NexusTileService
+
+
+class NexusCalcHandler(object):
+    @classmethod
+    def validate(cls):
+        if "calc" not in cls.__dict__ or not type(cls.__dict__["calc"]) == 
types.FunctionType:
+            raise Exception("Method 'calc' has not been declared")
+
+        if "path" not in cls.__dict__:
+            raise Exception("Property 'path' has not been defined")
+
+        if "name" not in cls.__dict__:
+            raise Exception("Property 'name' has not been defined")
+
+        if "description" not in cls.__dict__:
+            raise Exception("Property 'description' has not been defined")
+
+        if "params" not in cls.__dict__:
+            raise Exception("Property 'params' has not been defined")
+
+    def __init__(self, skipCassandra=False, skipSolr=False):
+
+        self._tile_service = NexusTileService(skipCassandra, skipSolr)
+
+    def calc(self, computeOptions, **args):
+        raise Exception("calc() not yet implemented")
+
+    def _mergeDicts(self, x, y):
+        z = x.copy()
+        z.update(y)
+        return z
+
+    def _now(self):
+        millis = int(round(time.time() * 1000))
+        return millis
+
+    def _mergeDataSeries(self, resultsData, dataNum, resultsMap):
+
+        for entry in resultsData:
+
+            # frmtdTime = datetime.fromtimestamp(entry["time"] 
).strftime("%Y-%m")
+            frmtdTime = entry["time"]
+
+            if not frmtdTime in resultsMap:
+                resultsMap[frmtdTime] = []
+            entry["ds"] = dataNum
+            resultsMap[frmtdTime].append(entry)
+
+    def _resultsMapToList(self, resultsMap):
+        resultsList = []
+        for key, value in resultsMap.iteritems():
+            resultsList.append(value)
+
+        resultsList = sorted(resultsList, key=lambda entry: entry[0]["time"])
+        return resultsList

Review comment:
       Good question. I don't know. I would not change that as part of this 
pull request.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to