diff --git a/Makefile b/Makefile index 69dd96a..ba12ace 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,16 @@ clean: ## Clean docker containers and volumes (causes act to break sometimes) docker rm -f $(shell docker ps -a -q) docker volume rm $(shell docker volume ls -q) -.PHONY: app +.PHONY: all all: ## Cleans up docker containers, and runs GitHub workflows with act $(MAKE) clean $(MAKE) push +.PHONY: db-run +db-run: ## Build and run the database container with Docker. This logic is replicated from the `push.yml` workflow. + docker build -f db/Dockerfile -t ghcr.io/avinya-foundation/global-data-db:latest . + docker run -d -e MYSQL_ROOT_PASSWORD=test -p 3306:3306 ghcr.io/avinya-foundation/global-data-db:latest + # Util ####### diff --git a/api/avinya_data.bal b/api/avinya_data.bal index e925671..3b585fa 100644 --- a/api/avinya_data.bal +++ b/api/avinya_data.bal @@ -16,7 +16,7 @@ public distinct service class AvinyaTypeData { return self.avinya_type.active; } - resource function get global_type() returns string? { + resource function get global_type() returns string { return self.avinya_type.global_type; } diff --git a/api/organization_data.bal b/api/organization_data.bal index 64f61d7..cb67dea 100644 --- a/api/organization_data.bal +++ b/api/organization_data.bal @@ -101,7 +101,7 @@ public distinct service class OrganizationData { } resource function get people() returns PersonData[]|error? { - // Get list of child organizations + // Get list of people in the organization stream people = db_client->query( `SELECT * FROM avinya_db.person diff --git a/api/tests/geo_data.bal b/api/tests/geo_data.bal new file mode 100644 index 0000000..0e2d498 --- /dev/null +++ b/api/tests/geo_data.bal @@ -0,0 +1,41 @@ +import ballerina/test; +import ballerina/graphql; + +graphql:Client test_client = check new ("http://localhost:4000/graphql"); + +@test:Config {} +public function testGetProvince() { + // Attempt to get geo information for Dehiwala + json|error? a = test_client->executeWithType(string ` + query test($name:String!) { + geo { + city(name: $name) { + name {name_en} + district { + name {name_en} + province { + name {name_en} + } + } + } + } + }`, + {"name": "Dehiwala"}); + + // Verify output + test:assertEquals(a, + { + "data": { + "geo": { + "city": { + "name": {"name_en": "Dehiwala"}, + "district": { + "name": {"name_en": "Colombo"}, + "province": {"name": {"name_en": "Western"}} + } + } + } + } + } + ); +} diff --git a/api/types.bal b/api/types.bal index d9b6afb..2f1a768 100644 --- a/api/types.bal +++ b/api/types.bal @@ -57,7 +57,7 @@ public type AvinyaType record{| readonly string record_type = "avinya_type"; int id?; boolean active; - string? global_type; + string global_type; string? name; string? foundation_type; string? focus; diff --git a/db/schema/2-avinya_types.sql b/db/schema/2-avinya_types.sql index ce84967..ddae133 100644 --- a/db/schema/2-avinya_types.sql +++ b/db/schema/2-avinya_types.sql @@ -3,26 +3,35 @@ USE avinya_db; CREATE TABLE IF NOT EXISTS avinya_type ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, active BOOLEAN NOT NULL, - global_type ENUM("Employee", "Customer", "Volunteer", "Applicant", "Organization", "Team") NOT NULL, + global_type ENUM( + "employee", + "consultant", + "customer", + "volunteer", + "applicant", + "team", + "advisor", + "director", + "donor" + ) NOT NULL, name VARCHAR(255), foundation_type ENUM( - "Executive", - "Advisor", - "Educator", - "Technology", - "Operations", - "HR", - "Parent", - "Student" + "executive", -- Foundation Level + "academic", -- specifically academic instruction + "staff", -- l.t. (<) Foundation Level + "parent", + "student" ), focus ENUM( - "Foundation", - "Vocational-IT", - "Vocational-Healthcare", - "Vocational-Hospitality", - "Operations", - "HR", - "Technology" + "bootcamp", + "information-technology", + "healthcare", + "hospitality", + "operations", + "human-resources", + "technology", + "marketing", + "finance" ), level INT );