Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename attributes #1370

Merged
merged 6 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Changed

- Renamed technical attributes `kind_id_cli` to `borehole_type_id`, `top_bedrock` to `top_bedrock_fresh` and `qt_top_bedrock` to `top_bedrock_weathered`.

## v2.1.772 - 2024-06-27

### Added
Expand Down
46 changes: 23 additions & 23 deletions src/api-legacy/v1/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def getordering(self, orderby, direction):
_orderby = 'total_depth'

elif orderby == 'borehole_type':
_orderby = 'kind_id_cli'
_orderby = 'borehole_type_id'

elif orderby == 'restriction_until':
_orderby = 'restriction_until_bho'
Expand All @@ -75,7 +75,7 @@ def getordering(self, orderby, direction):
_orderby = 'purpose_id_cli'

elif orderby == 'elevation_z':
_orderby = 'elevation_z_bho'
_orderby = 'elevation_z_bho'

# there are inconsitencies in the client code, that sometimes the translation key is send to the api. Therefore some duplicate keys are mapped here.
elif orderby == 'boreholestatus':
Expand All @@ -86,13 +86,13 @@ def getordering(self, orderby, direction):

elif orderby == 'creationdate':
_orderby = 'created_bho'

elif orderby == 'totaldepth':
_orderby = 'total_depth'
elif orderby == 'top_bedrock':
_orderby = 'top_bedrock_bho'

elif orderby == 'top_bedrock_fresh_md':
_orderby = 'top_bedrock_fresh_md'

else:
orderby = 'original_name'

Expand Down Expand Up @@ -141,7 +141,7 @@ def filterProfileLayers(self, filter={}):

keys = filter.keys()


key_to_table_column = {
'grain_shape': {'table': 'bdms.layer_grain_shape_codelist', 'column': 'grain_shape_id'},
'grain_granularity': {'table': 'bdms.layer_grain_angularity_codelist', 'column': 'grain_angularity_id'},
Expand Down Expand Up @@ -368,7 +368,7 @@ def filterBorehole(self, filter={}):
""" % self.getIdx())

if 'borehole_identifier' in keys:
if filter['borehole_identifier'] == 0:
if filter['borehole_identifier'] == 0:
if 'identifier_value' in keys and filter['identifier_value'] not in ['', None]:
params.append(int(filter['identifier_value']))
where.append("""
Expand Down Expand Up @@ -434,7 +434,7 @@ def filterBorehole(self, filter={}):
if 'borehole_type' in keys and filter['borehole_type'] not in ['', None]:
params.append(int(filter['borehole_type']))
where.append("""
kind_id_cli = %s
borehole_type_id = %s
""" % self.getIdx())

if 'restriction' in keys and filter[
Expand Down Expand Up @@ -596,28 +596,28 @@ def filterBorehole(self, filter={}):
total_depth_bho <= %s
""" % self.getIdx())

if 'top_bedrock_from' in keys and filter['top_bedrock_from'] not in ['', None]:
params.append(float(filter['top_bedrock_from']))
if 'top_bedrock_fresh_md_from' in keys and filter['top_bedrock_fresh_md_from'] not in ['', None]:
params.append(float(filter['top_bedrock_fresh_md_from']))
where.append("""
top_bedrock_bho >= %s
top_bedrock_fresh_md >= %s
""" % self.getIdx())

if 'top_bedrock_to' in keys and filter['top_bedrock_to'] not in ['', None]:
params.append(float(filter['top_bedrock_to']))
if 'top_bedrock_fresh_md_to' in keys and filter['top_bedrock_fresh_md_to'] not in ['', None]:
params.append(float(filter['top_bedrock_fresh_md_to']))
where.append("""
top_bedrock_bho <= %s
top_bedrock_fresh_md <= %s
""" % self.getIdx())

if 'qt_top_bedrock_from' in keys and filter['qt_top_bedrock_from'] not in ['', None]:
params.append(float(filter['qt_top_bedrock_from']))
if 'top_bedrock_weathered_md_from' in keys and filter['top_bedrock_weathered_md_from'] not in ['', None]:
params.append(float(filter['top_bedrock_weathered_md_from']))
where.append("""
qt_top_bedrock >= %s
top_bedrock_weathered_md >= %s
""" % self.getIdx())

if 'qt_top_bedrock_to' in keys and filter['qt_top_bedrock_to'] not in ['', None]:
params.append(float(filter['qt_top_bedrock_to']))
if 'top_bedrock_weathered_md_to' in keys and filter['top_bedrock_weathered_md_to'] not in ['', None]:
params.append(float(filter['top_bedrock_weathered_md_to']))
where.append("""
qt_top_bedrock <= %s
top_bedrock_weathered_md <= %s
""" % self.getIdx())

if 'lithology_top_bedrock' in keys and filter[
Expand Down Expand Up @@ -703,4 +703,4 @@ def filterLithostratigraphy(self, filter={}):
lithostratigraphy_id = %s
""" % self.getIdx())

return where, params, joins
return where, params, joins
2 changes: 1 addition & 1 deletion src/api-legacy/v1/borehole/editinglist.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def execute(
)
END AS lock,
original_name_bho as original_name,
kind_id_cli as borehole_type,
borehole_type_id as borehole_type,
restriction_id_cli as restriction,
to_char(
restriction_until_bho,
Expand Down
2 changes: 1 addition & 1 deletion src/api-legacy/v1/borehole/geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async def execute(self, filter={}, user=None):
LEFT JOIN
bdms.codelist kd
ON
kind_id_cli = kd.id_cli
borehole_type_id = kd.id_cli

LEFT JOIN
bdms.codelist rs
Expand Down
14 changes: 7 additions & 7 deletions src/api-legacy/v1/borehole/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_sql(sql_lock='', file_permission=''):
) t2
) as creator,
{sql_lock}
kind_id_cli as borehole_type,
borehole_type_id as borehole_type,
restriction_id_cli as restriction,
to_char(
restriction_until_bho,
Expand Down Expand Up @@ -76,7 +76,7 @@ def get_sql(sql_lock='', file_permission=''):
) as original_name,
purpose_id_cli as purpose,
status_id_cli as status,
top_bedrock_bho as top_bedrock,
top_bedrock_fresh_md as top_bedrock_fresh_md,
groundwater_bho as groundwater
) t
) as extended,
Expand All @@ -95,7 +95,7 @@ def get_sql(sql_lock='', file_permission=''):
canton_bho as canton,
municipality_bho as municipality,
qt_depth_id_cli as qt_depth,
qt_top_bedrock,
top_bedrock_weathered_md,
lithology_top_bedrock_id_cli as lithology_top_bedrock,
lithostrat_id_cli as lithostratigraphy_top_bedrock,
chronostrat_id_cli AS chronostratigraphy_top_bedrock,
Expand Down Expand Up @@ -156,7 +156,7 @@ def get_sql(sql_lock='', file_permission=''):
id_fil_fk = id_fil

{file_permission}

GROUP BY
id_bho_fk
) AS atc
Expand Down Expand Up @@ -271,7 +271,7 @@ def get_sql(sql_lock='', file_permission=''):

FROM
bdms.stratigraphy

LEFT JOIN bdms.layer
ON layer.id_sty_fk = id_sty

Expand All @@ -289,15 +289,15 @@ async def execute(self, id, with_lock = True, user=None):

permission = ''
file_permission = ''


if user is not None:
permission = """
AND {}
""".format(
self.filterPermission(user)
)

if (
user['workgroups'] is None or
len(user['workgroups']) == 0
Expand Down
24 changes: 12 additions & 12 deletions src/api-legacy/v1/borehole/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_sql_geolcode(cols=None, join=None, where=None):
precision_location_x_lv03,
precision_location_y_lv03,
srd.geolcode as spatial_reference_system,

qtloc.geolcode as location_precision,
elevation_z_bho as elevation_z,
height_reference_system.geolcode as height_reference_system,
Expand All @@ -64,11 +64,11 @@ def get_sql_geolcode(cols=None, join=None, where=None):
total_depth_bho as total_depth,
qt_len.geolcode as qt_depth,

top_bedrock_bho as top_bedrock,
qt_tbed.geolcode as qt_top_bedrock,
top_bedrock_fresh_md as top_bedrock_fresh_md,
qt_tbed.geolcode as top_bedrock_weathered_md,

groundwater_bho as groundwater,

ids.identifiers,
ids.identifiers_value,
remarks_bho as remarks,
Expand All @@ -93,7 +93,7 @@ def get_sql_geolcode(cols=None, join=None, where=None):
) as ids
ON
ids.borehole_id = id_bho

LEFT JOIN (
SELECT
borehole_id,
Expand All @@ -118,7 +118,7 @@ def get_sql_geolcode(cols=None, join=None, where=None):
ON rest.id_cli = restriction_id_cli

LEFT JOIN bdms.codelist as knd
ON knd.id_cli = kind_id_cli
ON knd.id_cli = borehole_type_id

LEFT JOIN bdms.codelist as srd
ON srd.id_cli = srs_id_cli
Expand Down Expand Up @@ -170,7 +170,7 @@ def get_sql():
) t
) as creator,
original_name_bho as original_name,
kind_id_cli as borehole_type,
borehole_type_id as borehole_type,
restriction_id_cli as restriction,
to_char(
restriction_until_bho,
Expand All @@ -195,7 +195,7 @@ def get_sql():
SELECT
status_id_cli as status,
purpose_id_cli as purpose,
top_bedrock_bho as top_bedrock
top_bedrock_fresh_md as top_bedrock_fresh_md
) t
) as extended,
status[array_length(status, 1)] as workflow,
Expand All @@ -208,7 +208,7 @@ def get_sql():
) t
) as custom


FROM
bdms.borehole

Expand Down Expand Up @@ -391,18 +391,18 @@ async def execute(

FROM
bdms.stratigraphy

INNER JOIN
bdms.layer
ON
id_sty_fk = id_sty

{}

{}

) as strt2
ON
ON
borehole.id_bho = strt2.id_bho_fk
""".format(
joins_string, where_string
Expand Down
Loading
Loading