Skip to content

Commit

Permalink
refactor: tidy minor code edits & lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jan 11, 2024
1 parent b173063 commit 4e489f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
20 changes: 10 additions & 10 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
shape,
)
from shapely.ops import unary_union
from sqlalchemy import and_, column, inspect, select, table, text
from sqlalchemy import and_, column, func, inspect, select, table, text
from sqlalchemy.dialects.postgresql import insert
from sqlalchemy.orm import Session

Expand Down Expand Up @@ -147,7 +147,6 @@ async def get_project_by_id(db: Session, project_id: int):
db_project = (
db.query(db_models.DbProject)
.filter(db_models.DbProject.id == project_id)
.order_by(db_models.DbProject.id)
.first()
)
return await convert_to_app_project(db_project)
Expand Down Expand Up @@ -578,7 +577,7 @@ async def get_data_extract_from_osm_rawdata(
return data_extract
except Exception as e:
log.error(e)
raise HTTPException(status_code=400, detail=str(e))
raise HTTPException(status_code=400, detail=str(e)) from e


async def get_data_extract_url(
Expand Down Expand Up @@ -628,7 +627,7 @@ async def get_data_extract_url(
shape(feature.get("geometry")) for feature in aoi.get("features", [])
]
merged_geom = unary_union(geometries)
elif geom_type := aoi.get("type") == "Feature":
elif geom_type == aoi.get("type") == "Feature":
merged_geom = shape(aoi.get("geometry"))
else:
merged_geom = shape(aoi)
Expand Down Expand Up @@ -2336,15 +2335,13 @@ def is_valid_coordinate(coord):
else input_geojson.get("geometry", {}).get("type", "")
)
if geometry_type == "MultiPolygon":
first_coordinate = (
coordinates[0][0] if coordinates and coordinates[0] else None
)
first_coordinate = coordinates[0][0] if coordinates and coordinates[0] else None
elif geometry_type == "Point":
first_coordinate = coordinates if coordinates else None

elif geometry_type == "LineString":
first_coordinate = coordinates[0] if coordinates else None

else:
first_coordinate = coordinates[0][0] if coordinates else None

Expand Down Expand Up @@ -2440,7 +2437,9 @@ async def get_project_users(db: Session, project_id: int):
project_id (int): The ID of the project.
Returns:
List[Dict[str, Union[str, int]]]: A list of dictionaries containing the username and the number of contributions made by each user for the specified project.
List[Dict[str, Union[str, int]]]: A list of dictionaries containing
the username and the number of contributions made by each user
for the specified project.
"""
contributors = (
db.query(db_models.DbTaskHistory)
Expand Down Expand Up @@ -2470,7 +2469,8 @@ def count_user_contributions(db: Session, user_id: int, project_id: int) -> int:
project_id (int): The ID of the project.
Returns:
int: The number of contributions made by the user for the specified project.
int: The number of contributions made by the user for the specified
project.
"""
contributions_count = (
db.query(func.count(db_models.DbTaskHistory.user_id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ const ProjectDetailsForm: React.FC = () => {
const organizationListData: any = useAppSelector((state) => state.createproject.organizationList);
//we use use selector from redux to get all state of projectDetails from createProject slice

useEffect(() => {
// dispatch(OrganisationService(`${import.meta.env.VITE_API_URL}/organization/`));
}, []);

const submission = () => {
// submitForm();
dispatch(CreateProjectActions.SetIndividualProjectDetailsData(values));
Expand Down

0 comments on commit 4e489f2

Please sign in to comment.