From 2eb10140de0759425f6219376a7a2aad7526cb9c Mon Sep 17 00:00:00 2001 From: YujithIsura Date: Wed, 16 Oct 2024 10:12:41 +0530 Subject: [PATCH 1/4] lint --- api/Dependencies.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/Dependencies.toml b/api/Dependencies.toml index 9584a93..588f7a5 100644 --- a/api/Dependencies.toml +++ b/api/Dependencies.toml @@ -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"}, From 8f2bc6ab18a26995a0456c2d425aca149ae95cce Mon Sep 17 00:00:00 2001 From: YujithIsura Date: Thu, 24 Oct 2024 10:18:34 +0530 Subject: [PATCH 2/4] lint --- api/Dependencies.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/Dependencies.toml b/api/Dependencies.toml index 588f7a5..fcfd962 100644 --- a/api/Dependencies.toml +++ b/api/Dependencies.toml @@ -112,7 +112,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.10.16" +version = "2.10.17" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, From cd5d0b72000d447556193b26923af44a378c194d Mon Sep 17 00:00:00 2001 From: YujithIsura Date: Thu, 5 Dec 2024 13:16:39 +0530 Subject: [PATCH 3/4] nic uniqed for each batch --- api/main.bal | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/main.bal b/api/main.bal index 9c1825c..ddbd131 100644 --- a/api/main.bal +++ b/api/main.bal @@ -5761,9 +5761,10 @@ AND p.organization_id IN ( Person|error? personRaw = db_client->queryRow( `SELECT * - FROM person - WHERE - nic_no = ${person.nic_no};` + FROM person p + left join organization o on o.id = p.organization_id + WHERE o.id = ${person.organization_id} and + p.nic_no = ${person.nic_no};` ); if (personRaw is Person) { From 10f5a55182c0a406059bd4cb0e0e08a5138d8ecc Mon Sep 17 00:00:00 2001 From: YujithIsura Date: Thu, 2 Jan 2025 15:41:55 +0530 Subject: [PATCH 4/4] removed old batch restrictions from child_organizations --- api/Dependencies.toml | 6 ++-- api/organization_data.bal | 66 +++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/api/Dependencies.toml b/api/Dependencies.toml index 6867e2a..810e23b 100644 --- a/api/Dependencies.toml +++ b/api/Dependencies.toml @@ -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"}, @@ -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"} @@ -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"}, diff --git a/api/organization_data.bal b/api/organization_data.bal index dabeccb..a9cb176 100644 --- a/api/organization_data.bal +++ b/api/organization_data.bal @@ -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; } @@ -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; } @@ -53,12 +53,12 @@ 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); } @@ -66,11 +66,11 @@ public isolated service class OrganizationData { 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); } @@ -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"] ?: "" }; } } @@ -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 = []; @@ -166,32 +167,31 @@ public isolated service class OrganizationData { // Get list of people in the organization stream 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 = []; @@ -238,7 +238,7 @@ lock{ } isolated resource function get organization_metadata() returns OrganizationMetaData[]|error? { - + stream org_meta_data; lock { org_meta_data = db_client->query( @@ -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); }