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

Release VZ 1.43.0 - Vista Verde Dr #1396

Merged
merged 44 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2841b8f
Add vz-admin to tables through atd_txdot__injry_sev_lkp; revoke inser…
mddilley Feb 26, 2024
f006838
Add vz-admin to tables through atd_txdot__y_n_lkp
mddilley Feb 26, 2024
f749b49
Add vz-admin to tables through atd_txdot_locations
mddilley Feb 26, 2024
aa61639
Add vz-admin to tables through crash_notes
mddilley Feb 26, 2024
a0afb01
Add vz-admin to tables through view_vzv_header_totals
mddilley Feb 26, 2024
77ce847
Rein in role name strings
mddilley Feb 26, 2024
0eef025
Update admin role in VZ API
mddilley Feb 26, 2024
9794727
Update permissions to match UI rules for recommendations and people n…
mddilley Feb 26, 2024
afb39d7
Use the new role vars across the rules
mddilley Feb 26, 2024
8f4eabe
Add the primaryperson name update permissions for vz-admin too
mddilley Feb 26, 2024
f743238
Fix fatalities view permissions and people select for vz-admin on per…
mddilley Feb 26, 2024
e67885c
Merge branch 'master' into md-11893-vz-admin-role
mddilley Feb 27, 2024
146c3aa
Fix inconsistent numbers view permissions
mddilley Feb 27, 2024
e833f38
Newline
mddilley Feb 27, 2024
2351b4e
Bump Hasura
mddilley Feb 29, 2024
36c0217
rework initial date calc and only truncate data if we have new data
johnclary Feb 29, 2024
65cd6a2
remove newline
johnclary Feb 29, 2024
8c30485
Merge pull request #1388 from cityofaustin/jc-vz-socrata-leapyear
johnclary Mar 1, 2024
c36eb4e
remove edit coordinates button for readonly users
roseeichelmann Mar 1, 2024
234e046
click cell to edit, autofocus, show pointer cursor
johnclary Mar 4, 2024
9875c98
autofocus inputs on related records table
johnclary Mar 4, 2024
f446716
use Input component and rework editable styles, layout
johnclary Mar 4, 2024
8b0fbeb
use flexboxes instead of row/col
johnclary Mar 4, 2024
80e2a42
disable autocomplete and 1password on inputs
johnclary Mar 4, 2024
90fc5b3
nix hover style and clean up
johnclary Mar 4, 2024
110c0e3
add padding between input and buttons
johnclary Mar 4, 2024
ddb1b86
use styled buttons like related records table
johnclary Mar 4, 2024
e7de67e
use cache-and-network fetch policy for crashes, locations, and fatali…
johnclary Mar 5, 2024
26ce970
Merge pull request #1389 from cityofaustin/15456_remove_map_editing_r…
roseeichelmann Mar 5, 2024
610e7a2
Merge pull request #1390 from cityofaustin/jc-datatable-edit-enhancem…
johnclary Mar 6, 2024
745fa9a
Add person names to protected people fields
frankhereford Mar 7, 2024
24ff334
Align important fields between VZE & cris_import.py
frankhereford Mar 11, 2024
690e4c8
add comment about function import naming
frankhereford Mar 11, 2024
da6f5e8
add file to hold open the dev extract folder
frankhereford Mar 11, 2024
08bb44c
remove explicit table name
frankhereford Mar 11, 2024
d4fb09a
refine comment
frankhereford Mar 11, 2024
91cde9f
removing debug print statement
frankhereford Mar 11, 2024
5e4f07d
Merge pull request #1393 from cityofaustin/cris-import-investigation
frankhereford Mar 11, 2024
c6182c4
Merge branch 'master' into md-11893-vz-admin-role
mddilley Mar 14, 2024
d21b197
Merge master; Hasura metadata formatting
mddilley Mar 14, 2024
21a99b2
Merge pull request #1385 from cityofaustin/md-11893-vz-admin-role
mddilley Mar 14, 2024
92c261e
Merge pull request #1392 from cityofaustin/15884-jc-fatalities-fetch-…
johnclary Mar 14, 2024
5008afb
Version bumps
mddilley Mar 14, 2024
1fa0e17
Merge branch 'production' into 1.43.0-release-candidate
mddilley Mar 14, 2024
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
22 changes: 15 additions & 7 deletions atd-cr3-api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
AWS_S3_CR3_LOCATION = os.getenv("AWS_S3_CR3_LOCATION", "")
AWS_S3_BUCKET = os.getenv("AWS_S3_BUCKET", "")

ADMIN_ROLE_NAME = "vz-admin"


def get_api_token():
"""
Expand Down Expand Up @@ -327,8 +329,14 @@ def user_list_users():
user_dict = current_user._get_current_object()
page = request.args.get("page")
per_page = request.args.get("per_page")
if isValidUser(user_dict) and hasUserRole("admin", user_dict):
endpoint = f"https://{AUTH0_DOMAIN}/api/v2/users?page=" + page + "&per_page=" + per_page + "&include_totals=true"
if isValidUser(user_dict) and hasUserRole(ADMIN_ROLE_NAME, user_dict):
endpoint = (
f"https://{AUTH0_DOMAIN}/api/v2/users?page="
+ page
+ "&per_page="
+ per_page
+ "&include_totals=true"
)
headers = {"Authorization": f"Bearer {get_api_token()}"}
response = requests.get(endpoint, headers=headers).json()
return jsonify(response)
Expand All @@ -342,7 +350,7 @@ def user_list_users():
@requires_auth
def user_get_user(id):
user_dict = current_user._get_current_object()
if isValidUser(user_dict) and hasUserRole("admin", user_dict):
if isValidUser(user_dict) and hasUserRole(ADMIN_ROLE_NAME, user_dict):
endpoint = f"https://{AUTH0_DOMAIN}/api/v2/users/" + id
headers = {"Authorization": f"Bearer {get_api_token()}"}
response = requests.get(endpoint, headers=headers).json()
Expand All @@ -357,7 +365,7 @@ def user_get_user(id):
@requires_auth
def user_create_user():
user_dict = current_user._get_current_object()
if isValidUser(user_dict) and hasUserRole("admin", user_dict):
if isValidUser(user_dict) and hasUserRole(ADMIN_ROLE_NAME, user_dict):
json_data = request.json
endpoint = f"https://{AUTH0_DOMAIN}/api/v2/users"
headers = {"Authorization": f"Bearer {get_api_token()}"}
Expand All @@ -373,7 +381,7 @@ def user_create_user():
@requires_auth
def user_update_user(id):
user_dict = current_user._get_current_object()
if isValidUser(user_dict) and hasUserRole("admin", user_dict):
if isValidUser(user_dict) and hasUserRole(ADMIN_ROLE_NAME, user_dict):
json_data = request.json
endpoint = f"https://{AUTH0_DOMAIN}/api/v2/users/" + id
headers = {"Authorization": f"Bearer {get_api_token()}"}
Expand All @@ -389,7 +397,7 @@ def user_update_user(id):
@requires_auth
def user_unblock_user(id):
user_dict = current_user._get_current_object()
if isValidUser(user_dict) and hasUserRole("admin", user_dict):
if isValidUser(user_dict) and hasUserRole(ADMIN_ROLE_NAME, user_dict):
endpoint = f"https://{AUTH0_DOMAIN}/api/v2/user_blocks/" + id
headers = {"Authorization": f"Bearer {get_api_token()}"}
response = requests.delete(endpoint, headers=headers)
Expand All @@ -404,7 +412,7 @@ def user_unblock_user(id):
@requires_auth
def user_delete_user(id):
user_dict = current_user._get_current_object()
if isValidUser(user_dict) and hasUserRole("admin", user_dict):
if isValidUser(user_dict) and hasUserRole(ADMIN_ROLE_NAME, user_dict):
endpoint = f"https://{AUTH0_DOMAIN}/api/v2/users/" + id
headers = {"Authorization": f"Bearer {get_api_token()}"}
response = requests.delete(endpoint, headers=headers)
Expand Down
18 changes: 9 additions & 9 deletions atd-etl/socrata_export/process/helpers_socrata.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import json
from copy import deepcopy
from process.config import ATD_ETL_CONFIG
from datetime import date, timedelta
from datetime import date, timedelta, datetime

# Dict to translate modes to correlate with atd__mode_category_lkp table
mode_categories = {
Expand Down Expand Up @@ -88,9 +88,9 @@ def flatten_hasura_response(records):
)
else:
# Create key at top-level
formatted_record[
third_level_key
] = third_level_value
formatted_record[third_level_key] = (
third_level_value
)
# Copy non-nested key-values to top-level (if value is not null)
# Null records can create unwanted columns at top level of record
elif second_level_value is not None:
Expand Down Expand Up @@ -315,7 +315,7 @@ def format_person_data(data, formatter_config):
return formatted_records


def get_date_limit():
def two_weeks_ago():
"""
Returns a string with the date two weeks ago in iso format: yyyy-mm-dd
:return str:
Expand All @@ -327,13 +327,13 @@ def get_date_limit():
return (d - timedelta(days=14)).strftime("%Y-%m-%d")


def get_initial_date_limit():
def ten_years_ago():
"""
Returns a string with the date ten years ago in iso format: yyyy-mm-dd
Returns a string with the date on January 1st, ten years ago in format: yyyy-mm-dd.
:return str:
"""
d = date.today()
return d.replace(year=d.year - 10).strftime("%Y-%m-%d")
year = datetime.now().year
return f"{year - 10}-01-01"


def is_no_time_constraint():
Expand Down
13 changes: 9 additions & 4 deletions atd-etl/socrata_export/socrata_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
# For each config, get records from Hasura and upsert to Socrata until res is []
for config in query_configs:
print(f'Starting {config["table"]} table...')
print(f'Truncating {config["table"]} table...')
client.replace(config["dataset_uid"], [])
is_truncate_complete = False
records = None
offset = 0
limit = 1000
Expand All @@ -82,8 +81,8 @@
query = config["template"].substitute(
limit=limit,
offset=offset,
date_limit=get_date_limit(),
initial_date_limit=get_initial_date_limit(),
date_limit=two_weeks_ago(),
initial_date_limit=ten_years_ago(),
)
offset += limit
data = run_hasura_query(query)
Expand All @@ -96,6 +95,12 @@
# Format records
records = config["formatter"](data, config["formatter_config"])

# truncate the existing data set once we have records
if records and not is_truncate_complete:
print(f'Truncating {config["table"]} table...')
client.replace(config["dataset_uid"], [])
is_truncate_complete = True

# Upsert records to Socrata
client.upsert(config["dataset_uid"], records)
total_records += len(records)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ select_permissions:
- id
filter: {}
comment: ""
- role: vz-admin
permission:
columns:
- coord_partner_desc
- id
filter: {}
comment: ""
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ select_permissions:
- id
filter: {}
comment: ""
- role: vz-admin
permission:
columns:
- atd_mode_category_desc
- atd_mode_category_mode_name
- id
filter: {}
comment: ""
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ select_permissions:
- rec_status_desc
filter: {}
comment: ""
- role: vz-admin
permission:
columns:
- id
- rec_status_desc
filter: {}
comment: ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ insert_permissions:
- longitude
- position
- speed_mgmt_points
- role: vz-admin
permission:
check: {}
columns:
- address
- case_id
- date
- est_comp_cost
- est_comp_cost_crash_based
- est_econ_cost
- form_id
- hour
- latitude
- location_id
- longitude
- position
- speed_mgmt_points
select_permissions:
- role: editor
permission:
Expand Down Expand Up @@ -56,6 +73,24 @@ select_permissions:
- speed_mgmt_points
filter: {}
allow_aggregations: true
- role: vz-admin
permission:
columns:
- address
- case_id
- date
- est_comp_cost
- est_comp_cost_crash_based
- est_econ_cost
- form_id
- hour
- latitude
- location_id
- longitude
- position
- speed_mgmt_points
filter: {}
allow_aggregations: true
update_permissions:
- role: editor
permission:
Expand All @@ -75,3 +110,21 @@ update_permissions:
- speed_mgmt_points
filter: {}
check: null
- role: vz-admin
permission:
columns:
- address
- case_id
- date
- est_comp_cost
- est_comp_cost_crash_based
- est_econ_cost
- form_id
- hour
- latitude
- location_id
- longitude
- position
- speed_mgmt_points
filter: {}
check: null
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ select_permissions:
- total_crashes
- total_est_comp_cost
filter: {}
- role: vz-admin
permission:
columns:
- cr3_est_comp_cost
- cr3_total_crashes
- location_id
- noncr3_est_comp_cost
- noncr3_total_crashes
- total_crashes
- total_est_comp_cost
filter: {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ select_permissions:
- asmp_level_desc
- asmp_level_id
filter: {}
- role: vz-admin
permission:
columns:
- asmp_level_desc
- asmp_level_id
filter: {}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ select_permissions:
- eff_beg_date
- eff_end_date
filter: {}
- role: vz-admin
permission:
columns:
- city_id
- city_desc
- eff_beg_date
- eff_end_date
filter: {}
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
table:
name: atd_txdot__collsn_lkp
schema: public
insert_permissions:
- role: editor
permission:
check: {}
columns:
- collsn_id
- collsn_desc
- eff_beg_date
- eff_end_date
select_permissions:
- role: editor
permission:
Expand All @@ -27,13 +18,11 @@ select_permissions:
- eff_beg_date
- eff_end_date
filter: {}
update_permissions:
- role: editor
- role: vz-admin
permission:
columns:
- collsn_id
- collsn_desc
- eff_beg_date
- eff_end_date
filter: {}
check: null
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ select_permissions:
- eff_end_date
- other
filter: {}
- role: vz-admin
permission:
columns:
- contrib_factr_id
- contrib_factr_desc
- eff_beg_date
- eff_end_date
- other
filter: {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ select_permissions:
- est_comp_cost_amount
- est_comp_cost_id
filter: {}
- role: vz-admin
permission:
columns:
- est_comp_cost_amount
- est_comp_cost_id
filter: {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ select_permissions:
- est_comp_cost_amount
- est_comp_cost_desc
filter: {}
- role: vz-admin
permission:
columns:
- est_comp_cost_id
- est_comp_cost_amount
- est_comp_cost_desc
filter: {}
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
table:
name: atd_txdot__ethnicity_lkp
schema: public
insert_permissions:
- role: editor
permission:
check: {}
columns:
- ethnicity_desc
- ethnicity_id
select_permissions:
- role: editor
permission:
Expand All @@ -21,15 +14,9 @@ select_permissions:
- ethnicity_desc
- ethnicity_id
filter: {}
update_permissions:
- role: editor
- role: vz-admin
permission:
columns:
- ethnicity_desc
- ethnicity_id
filter: {}
check: null
delete_permissions:
- role: editor
permission:
filter: {}
Loading
Loading