def mapping(self): offset = 0 mapping = {} identity_parts = [] for axis in self.cube.axes: mapping[axis.name] = self.row[offset] identity_parts.append(self.row[offset]) offset += 1 for time in self.cube.times: time_from, time_until = parse_date(self.row[offset]) identity_parts.append(self.row[offset]) mapping[time.name] = { 'value': self.row[offset], 'from': time_from, 'until': time_until } offset += 1 for measure in self.cube.measures: m = {} if measure.data_type == 'GANZ': m['value'] = int(self.row[offset]) else: m['value'] = float(self.row[offset]) m['quality'] = self.row[offset+1] m['locked'] = self.row[offset+2] m['error'] = self.row[offset+3] mapping[measure.name] = m offset += 4 mapping['fact_id'] = make_key(*identity_parts) return mapping
def mapping(self): offset = 0 mapping = {} identity_parts = [] for axis in self.cube.axes: mapping[axis.name] = self.row[offset].lower() identity_parts.append(self.row[offset]) offset += 1 for time in self.cube.times: time_from, time_until = parse_date(self.row[offset]) identity_parts.append(self.row[offset]) mapping[time.name] = { 'value': self.row[offset], 'from': time_from, 'until': time_until } offset += 1 for measure in self.cube.measures: m = {} if measure.data_type == 'GANZ': m['value'] = int(self.row[offset]) else: m['value'] = float(self.row[offset]) m['quality'] = self.row[offset+1] m['locked'] = self.row[offset+2] m['error'] = self.row[offset+3] mapping[measure.name] = m offset += 4 mapping['fact_id'] = make_key(*identity_parts) return mapping
def compute_fact_id(fact): """ create an id that describes the unique combination of dimensions for a fact needed for elasticsearch doc_id and for de-duplication """ # FIXME make sure this is really working as expected xD parts = [] for key, value in fact.items(): if key.lower() not in EXCLUDE_FACT_ID_KEYS: if isinstance(value, dict): value = '' # the actual value is not an indicator for uniqueness parts.append('%s:%s' % (key, value)) return make_key(sorted(parts))
def id(self): return make_key(self.dimension.name, self.data.get('name'), self.data.get('valid_from'), self.data.get('valid_until'))