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

fixed issues in student profile #175

Merged
merged 3 commits into from
Oct 16, 2024
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
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
Loading