Skip to content
Snippets Groups Projects

Development

Merged Christoffer Stoll requested to merge development into master
3 files
+ 4
40
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 2
19
@@ -94,9 +94,9 @@ class Mean:
@staticmethod
def Aggregate(cursor: any, meanType: MeanType, ids: tuple, fromTime: str, toTime: str, coverage: int = 75, verificationFlag: int = 3, fraction: int = 10, addMetadata: bool = False, useInvalidValues: bool = False):
tz = Mean.timezone(cursor, ids)
sql = ""
params = {"ids": ids, "fromTime": fromTime, "toTime": toTime, "verificationFlag": verificationFlag, "coverage": coverage, "fraction": fraction, "useInvalidValues": useInvalidValues, "tz": tz}
params = {"ids": ids, "fromTime": fromTime, "toTime": toTime, "verificationFlag": verificationFlag, "coverage": coverage, "fraction": fraction, "useInvalidValues": useInvalidValues}
if meanType == MeanType.Original:
sql = Mean.Original()
@@ -922,20 +922,3 @@ class Mean:
WHERE C.sampling_point_id = TS.sampling_point_id
"""
return sql
@staticmethod
def timezone(cursor: any, ids: tuple):
# This is a workaround to get the timezone of the sampling point.
# Because from_time/to_time doesnt store the timezone we need to get it from the last value
# The import should make sure there is only one timezone in observations
sql = """
select substr(o.end_position,20) as tz
from sampling_points sp, observations o
where sp.id = o.sampling_point_id
and sp.id IN %(ids)s
and sp.to_time = o.to_time
limit 1
"""
cursor.execute(sql, {"ids": ids})
row = cursor.fetchone()
return "Z" if row is None else row["tz"]
Loading