Skip to content

Commit

Permalink
Merge pull request #184 from YujithIsura/main
Browse files Browse the repository at this point in the history
removed old batch restrictions from child_organizations
  • Loading branch information
YujithIsura authored Jan 2, 2025
2 parents e09b753 + d2c19d9 commit b213e49
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions api/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.17"
version = "2.10.19"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down Expand Up @@ -141,7 +141,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "io"
version = "1.6.1"
version = "1.6.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.value"}
Expand Down Expand Up @@ -395,7 +395,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "websocket"
version = "2.10.2"
version = "2.10.3"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "constraint"},
Expand Down
66 changes: 33 additions & 33 deletions api/organization_data.bal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public isolated service class OrganizationData {
private Organization organization;

isolated function init(string? name = null, int? organization_id = 0, Organization? organization = null) returns error? {
if(organization != null) { // if organization is provided, then use that and do not load from DB
if (organization != null) { // if organization is provided, then use that and do not load from DB
self.organization = organization.cloneReadOnly();
return;
}
Expand All @@ -13,37 +13,37 @@ public isolated service class OrganizationData {
int id = organization_id ?: 0;

Organization org_raw;
if(id > 0) { // organization_id provided, give precedance to that
org_raw = check db_client -> queryRow(
if (id > 0) { // organization_id provided, give precedance to that
org_raw = check db_client->queryRow(
`SELECT *
FROM organization
WHERE
id = ${id};`);
} else
} else
{
org_raw = check db_client -> queryRow(
org_raw = check db_client->queryRow(
`SELECT *
FROM organization
WHERE
name_en LIKE ${_name};`);
}

self.organization = org_raw.cloneReadOnly();
}

isolated resource function get id() returns int? {
lock {
return self.organization.id;
return self.organization.id;
}
}

isolated resource function get description() returns string?{
isolated resource function get description() returns string? {
lock {
return self.organization.description;
}
}

isolated resource function get notes() returns string?{
isolated resource function get notes() returns string? {
lock {
return self.organization.notes;
}
Expand All @@ -53,24 +53,24 @@ public isolated service class OrganizationData {
int id = 0;
lock {
id = self.organization.address_id ?: 0;
if( id == 0) {
if (id == 0) {
return null; // no point in querying if address id is null
}
}

}

return new AddressData(id);
}

isolated resource function get avinya_type() returns AvinyaTypeData|error? {
int id = 0;
lock {
id = self.organization.avinya_type ?: 0;
if( id == 0) {
if (id == 0) {
return null; // no point in querying if address id is null
}
}
}

return new AvinyaTypeData(id);
}

Expand All @@ -84,8 +84,8 @@ public isolated service class OrganizationData {
lock {
return {
"name_en": self.organization["name_en"],
"name_si": self.organization["name_si"]?:"", // handle null cases
"name_ta": self.organization["name_ta"]?:""
"name_si": self.organization["name_si"] ?: "", // handle null cases
"name_ta": self.organization["name_ta"] ?: ""
};
}
}
Expand All @@ -97,8 +97,9 @@ public isolated service class OrganizationData {
child_org_ids = db_client->query(
`SELECT *
FROM parent_child_organization
WHERE parent_org_id = ${self.organization.id} AND parent_org_id != 17 AND parent_org_id != 24 AND parent_org_id != 32`
WHERE parent_org_id = ${self.organization.id}`
);
// WHERE parent_org_id = ${self.organization.id} AND parent_org_id != 17 AND parent_org_id != 24 AND parent_org_id != 32`
}

OrganizationData[] child_orgs = [];
Expand Down Expand Up @@ -166,32 +167,31 @@ public isolated service class OrganizationData {
// Get list of people in the organization
stream<Person, error?> people;

lock{
int|error? avinya_type_id = db_client->queryRow(
lock {
int|error? avinya_type_id = db_client->queryRow(
`SELECT avinya_type FROM organization WHERE id = ${self.organization.id};`
);
io:println("Eval Criteria ID: ", (check avinya_type_id).toString());

if !(avinya_type_id is int) {
io:println("Eval Criteria ID: ", (check avinya_type_id).toString());
return error("AvinyaType ID does not exist");
}

if(avinya_type_id == 10 || avinya_type_id == 96){ // if organization is 10 or 96, get all vocational it students or cs students
if !(avinya_type_id is int) {
io:println("Eval Criteria ID: ", (check avinya_type_id).toString());
return error("AvinyaType ID does not exist");
}

if (avinya_type_id == 10 || avinya_type_id == 96) { // if organization is 10 or 96, get all vocational it students or cs students
people = db_client->query(
`SELECT *
FROM person
WHERE avinya_type_id=${avinya_type_id} AND organization_id = ${self.organization.id}`
);
}else{
people = db_client->query(
} else {
people = db_client->query(
`SELECT *
FROM person
WHERE organization_id = ${self.organization.id} AND avinya_type_id=37`
);
}
}

}

PersonData[] peopleData = [];

Expand Down Expand Up @@ -238,7 +238,7 @@ lock{
}

isolated resource function get organization_metadata() returns OrganizationMetaData[]|error? {

stream<OrganizationMetaDataDetails, error?> org_meta_data;
lock {
org_meta_data = db_client->query(
Expand All @@ -252,7 +252,7 @@ lock{

check from OrganizationMetaDataDetails orgmetdatadetails in org_meta_data
do {
OrganizationMetaData|error org_meta_data_det = new OrganizationMetaData((),(),orgmetdatadetails);
OrganizationMetaData|error org_meta_data_det = new OrganizationMetaData((), (), orgmetdatadetails);
if !(org_meta_data_det is error) {
org_meta_data_details.push(org_meta_data_det);
}
Expand Down

0 comments on commit b213e49

Please sign in to comment.