Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Including amenities and places to hashtag endpoint #178

Merged
merged 4 commits into from
May 18, 2022
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
3 changes: 2 additions & 1 deletion src/galaxy/query_builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ def generate_organization_hashtag_reports(cur,params):
hashtags.append("name = '"+str(p.strip()).lower()+"'" )
filter_hashtags = " or ".join(hashtags)
# filter_hashtags = cur.mogrify(sql.SQL(filter_hashtags), params.hashtags).decode()
t2_query= f"""select name as hashtag, type as frequency , start_date , end_date , total_new_buildings , total_uq_contributors as total_unique_contributors , total_new_road_m as total_new_road_meters
t2_query= f"""select name as hashtag, type as frequency , start_date , end_date , total_new_buildings , total_uq_contributors as total_unique_contributors , total_new_road_m as total_new_road_meters,
total_new_amenities as total_new_amenities, total_new_places as total_new_places
from hashtag_stats join t1 on hashtag_id=t1.id
where type='{params.frequency}'"""
month_time= f"""0:00:00"""
Expand Down
2 changes: 2 additions & 0 deletions src/galaxy/validation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ class OrganizationHashtag(BaseModel):
total_new_buildings : int
total_unique_contributors : int
total_new_road_meters : int
total_new_amenities: int
total_new_places: int


class TeamMemberFunction(Enum):
Expand Down
10 changes: 5 additions & 5 deletions tests/src/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ def test_organization_hashtag_weekly_query():
where name = 'msf'
),
t2 as (
select name as hashtag, type as frequency , start_date , end_date , total_new_buildings , total_uq_contributors as total_unique_contributors , total_new_road_m as total_new_road_meters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update will be needed on Assertion Step ! Replacement of existing query with updated query that will be generated from query builder

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed through 3e963b3 and 3c24122

select name as hashtag, type as frequency , start_date , end_date , total_new_buildings , total_uq_contributors as total_unique_contributors , total_new_road_m as total_new_road_meters,
total_new_amenities as total_new_amenities, total_new_places as total_new_places
from hashtag_stats join t1 on hashtag_id=t1.id
where type='w' and start_date >= '2020-10-22T12:00:00.000'::timestamp and end_date <= '2020-12-22T12:00:00.000'::timestamp
)
Expand Down Expand Up @@ -498,7 +499,8 @@ def test_organization_hashtag_monthly_query():
where name = 'msf'
),
t2 as (
select name as hashtag, type as frequency , start_date , end_date , total_new_buildings , total_uq_contributors as total_unique_contributors , total_new_road_m as total_new_road_meters
select name as hashtag, type as frequency , start_date , end_date , total_new_buildings , total_uq_contributors as total_unique_contributors , total_new_road_m as total_new_road_meters,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed through 3e963b3 and 3c24122

total_new_amenities as total_new_amenities, total_new_places as total_new_places
from hashtag_stats join t1 on hashtag_id=t1.id
where type='m' and start_date >= '2020-10-22T00:00:00.000'::timestamp and end_date <= '2020-12-22T00:00:00.000'::timestamp
)
Expand Down Expand Up @@ -625,6 +627,4 @@ def test_rawdata_current_snapshot_osm_elements_query() :
ST_intersects(ST_GEOMFROMGEOJSON('{"coordinates": [[[84.92431640625, 27.766190642387496], [85.31982421875, 27.766190642387496], [85.31982421875, 28.02592458049937], [84.92431640625, 28.02592458049937], [84.92431640625, 27.766190642387496]]], "type": "Polygon"}'), geom)) t3"""
query_result=raw_currentdata_extraction_query(validated_params,None,dumps(dict(validated_params.geometry)),100)
assert query_result.encode('utf-8') == expected_query.encode('utf-8')