Skip to content

Commit

Permalink
Fix json encoder issues and nested queries
Browse files Browse the repository at this point in the history
  • Loading branch information
HemanthSai7 committed Aug 21, 2023
1 parent 0fdd243 commit a54a11c
Show file tree
Hide file tree
Showing 9 changed files with 1,247 additions and 215 deletions.
2 changes: 1 addition & 1 deletion API/services/auth/AuthServices.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def signup(response_result: FrontendResponseModel, data: Union[UserAuth,BulkSign
passwords=[Auth.get_password_hash(passwd) for passwd in data.passwords]
village_name=data.village_name

users=DBQueries.filtered_db_search("Auth",role_manager.user,["_id","password","village_name"],AADHAR={"$in":AADHAR_NOS})
users=DBQueries.filtered_db_search("Auth",role_manager.user,["_id","password","village_name"],search_idxs={"AADHAR":{"$in":AADHAR_NOS}})
users=[user["AADHAR"] for user in users]

invalid_users=[]
Expand Down
2 changes: 1 addition & 1 deletion API/services/db/DBManipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def fetch_from_db(response_result: dict, resp_data: str)->dict:
result = DBQueries.retrieve_documents(db,collection_names["fam_data"])
return result


@json_encoder({ObjectId: str})
def fetch_familydata(response_result: dict, village_name: str, respondent_id: str)->dict:
"""Wrapper function to fetch family data from the database.
Args:
Expand Down
291 changes: 118 additions & 173 deletions tests/intended_responses/fetch_fam_data.json
Original file line number Diff line number Diff line change
@@ -1,176 +1,31 @@
{
"status": "success",
"message": [
"Authenticated"
],
"message": ["Authenticated"],
"data": {
"gen_ho_info": [
{
"ho_id": "A1",
"hoh_name": "Dada",
"hoh_gender": "Male",
"category": "OBC",
"pov_status": "BPL",
"own_house": true,
"house_type": "pucca",
"toilet": "Private",
"drainage_status": "open",
"waste_collection_sys": "doorstep",
"compost_pit": "Individual",
"biogas_plant": "Group",
"annual_income": 120000
}
],
"agri_inputs": [
{
"is_chemical_fertilizer_used": [
true,
5
],
"is_chemical_insecticide_used": [
false,
0
],
"is_chemical_weedicide_used": [
false,
0
],
"is_chemical_organic_manures": [
false,
0
],
"irrigation": "Open",
"irrigation_sys": "Open"
}
],
"source_of_energy": [
{
"electricity_conn": true,
"elec_avail_perday_hour": 12,
"lighting": [
"electricity"
],
"cooking": [
"LPG"
],
"cook_chullah": "Smokeless",
"appliances": [
{
"appliance_name": "fan",
"appliance_nos": 2,
"appliance_dur": 5
},
{
"appliance_name": "bulb",
"appliance_nos": 2,
"appliance_dur": 5
}
]
}
],
"land_holding_info": [
{
"total_land": 2,
"irrigated_area": 0.5,
"barren_or_wasteland": 0.1,
"cultivable_area": 0.4,
"unirrigated_area": 0.3,
"uncultivable_area": 0.2
}
],
"water_source": [
{
"piped_water": [
true,
10
],
"hand_pump": [
true,
20
],
"comm_water": [
false,
0
],
"open_well": [
true,
40
],
"mode_of_water_storage": "individual",
"other_water_source": "None"
}
],
"agri_products": [
{
"crop_name": "rice",
"crop_area_prev_yr_acre": 0.2,
"productivity_in_quintals_per_acre": 3
}
],
"livestock_nos": [
{
"cows": 2,
"buffalo": 2,
"goats_and_sheeps": 0,
"calves": 1,
"bullocks": 1,
"poultry_and_ducks": 0,
"livestock_shelter": [
"open"
],
"avg_daily_milk_prod_litres": 5,
"animal_waste_or_cow_dung_kgs": 1
}
],
"major_problems": [
{
"problems": [
"None"
],
"Suggestions_by_villagers": [
"None"
]
}
],
"govt_schemes": [
{
"PM_jan_dhan_yojana": 2,
"PM_ujjawala_yojana": 3,
"PM_awas_yojana": 2,
"sukanya_samriddhi_yojana": 3,
"mudra_yojana": 0,
"PM_jivan_jyoti_yojana": 0,
"PM_suraksha_bima_yojana": 0,
"atal_pension_yojana": 0,
"fasal_bima_yojana": 0,
"kaushal_vikas_yojana": 0,
"krishi_sinchai_yojana": 0,
"jan_aushadhi_yojana": 0,
"SBM_toilet": 0,
"soil_health_card": 0,
"ladli_lakshmi_yojana": 0,
"janni_suraksha_yojana": 0,
"kisan_credit_card": 0
}
],
"respondent_prof": [
{
"respondents_name": "Hemanth",
"respondents_age": 20,
"relation_w_hoh": "Son",
"respondents_contact": "8479239724",
"id_type": "AC",
"id_no": "test"
}
],
"mig_status": [
{
"are_migrants": false,
"num_migrants": 0,
"migration_period_months": 0,
"years_since_migration": 0
}
],
"_id": "64e37e96588d2c453b5694e4",
"respondent_prof": {
"respondents_name": "Hemanth",
"respondents_age": 20,
"relation_w_hoh": "Son",
"respondents_contact": "8479239724",
"id_type": "AC",
"id_no": "test"
},
"gen_ho_info": {
"ho_id": "A1",
"hoh_name": "Dada",
"hoh_gender": "Male",
"category": "OBC",
"pov_status": "BPL",
"own_house": true,
"house_type": "pucca",
"toilet": "Private",
"drainage_status": "open",
"waste_collection_sys": "doorstep",
"compost_pit": "Individual",
"biogas_plant": "Group",
"annual_income": 120000
},
"fam_info": [
{
"name": "Mayuresh",
Expand Down Expand Up @@ -237,7 +92,97 @@
"occupations": "Student"
}
],
"filled_by": "5734219582373335",
"filled_time": "2023-02-17T13:16:37.888000"
"mig_status": {
"are_migrants": false,
"num_migrants": 0,
"migration_period_months": 0,
"years_since_migration": 0
},
"govt_schemes": {
"PM_jan_dhan_yojana": 2,
"PM_ujjawala_yojana": 3,
"PM_awas_yojana": 2,
"sukanya_samriddhi_yojana": 3,
"mudra_yojana": 0,
"PM_jivan_jyoti_yojana": 0,
"PM_suraksha_bima_yojana": 0,
"atal_pension_yojana": 0,
"fasal_bima_yojana": 0,
"kaushal_vikas_yojana": 0,
"krishi_sinchai_yojana": 0,
"jan_aushadhi_yojana": 0,
"SBM_toilet": 0,
"soil_health_card": 0,
"ladli_lakshmi_yojana": 0,
"janni_suraksha_yojana": 0,
"kisan_credit_card": 0
},
"water_source": {
"piped_water": [true, 10],
"hand_pump": [true, 20],
"comm_water": [false, 0],
"open_well": [true, 40],
"mode_of_water_storage": "individual",
"other_water_source": "None"
},
"source_of_energy": {
"electricity_conn": true,
"elec_avail_perday_hour": 12,
"lighting": ["electricity"],
"cooking": ["LPG"],
"cook_chullah": "Smokeless",
"appliances": [
{
"appliance_name": "fan",
"appliance_nos": 2,
"appliance_dur": 5
},
{
"appliance_name": "bulb",
"appliance_nos": 2,
"appliance_dur": 5
}
]
},
"land_holding_info": {
"total_land": 2,
"irrigated_area": 0.5,
"barren_or_wasteland": 0.1,
"cultivable_area": 0.4,
"unirrigated_area": 0.3,
"uncultivable_area": 0.2
},
"agri_inputs": {
"is_chemical_fertilizer_used": [true, 5],
"is_chemical_insecticide_used": [false, 0],
"is_chemical_weedicide_used": [false, 0],
"is_chemical_organic_manures": [false, 0],
"irrigation": "Open",
"irrigation_sys": "Open"
},
"agri_products": [
{
"crop_name": "rice",
"crop_area_prev_yr_acre": 0.2,
"productivity_in_quintals_per_acre": 3
}
],
"livestock_nos": {
"cows": 2,
"buffalo": 2,
"goats_and_sheeps": 0,
"calves": 1,
"bullocks": 1,
"poultry_and_ducks": 0,
"livestock_shelter": ["open"],
"avg_daily_milk_prod_litres": 5,
"animal_waste_or_cow_dung_kgs": 1
},
"major_problems": {
"problems": ["None"],
"Suggestions_by_villagers": ["None"]
},
"volunteer_id": "5734219582373335",
"timestamp": "2023-08-21T15:11:18.182000"
}
}
}
Loading

0 comments on commit a54a11c

Please sign in to comment.