Skip to content

Commit

Permalink
Merge pull request #175 from avinyafoundation/main
Browse files Browse the repository at this point in the history
fixed issues in student profile
  • Loading branch information
YujithIsura authored Oct 16, 2024
2 parents a03ad62 + 1670a7e commit 12555d5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "sql"
version = "1.12.2"
version = "1.12.3"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand Down
8 changes: 7 additions & 1 deletion api/geo_data.bal
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ public isolated service class DistrictData {
public isolated service class CityData {
private City city;

isolated function init(string? name, int? city_id) returns error? {
isolated function init(string? name, int? city_id,City? city = null) returns error? {

if (city != null) {
self.city = city.cloneReadOnly();
return;
}

City city_raw = check db_client->queryRow(
`SELECT *
FROM city
Expand Down
29 changes: 29 additions & 0 deletions api/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -5876,6 +5876,35 @@ AND p.organization_id IN (
return districtDatas;
}

isolated resource function get cities(int? district_id) returns CityData[]|error? {
stream<City, error?> cities_data;

if(district_id !=null && district_id != 0 && district_id > 0){

lock {
cities_data = db_client->query(
`SELECT *
from city
where district_id=${district_id};`);
}

CityData[] cityDatas = [];

check from City city_data_record in cities_data
do {
CityData|error cityData = new CityData(null, 0,city_data_record);
if !(cityData is error) {
cityDatas.push(cityData);
}
};

check cities_data.close();
return cityDatas;
}else{
return error("Provide valid value for district_id.");
}
}

isolated resource function get all_organizations() returns OrganizationData[]|error? {
stream<Organization, error?> organizations_data;

Expand Down

0 comments on commit 12555d5

Please sign in to comment.