Skip to content

Commit

Permalink
Merge pull request #355 from avinyafoundation/main
Browse files Browse the repository at this point in the history
attendance dashboard changes added
  • Loading branch information
YujithIsura authored May 15, 2024
2 parents c6d3277 + a61383a commit b84c666
Show file tree
Hide file tree
Showing 28 changed files with 3,337 additions and 797 deletions.
2 changes: 1 addition & 1 deletion campus/bffs/attendance/api/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http"
version = "2.8.5"
version = "2.8.6"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down
12 changes: 9 additions & 3 deletions campus/bffs/attendance/api/attendance_client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,16 @@ log:printInfo("Formatted Response: " + formattedJson);
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetTotalAttendanceCountByParentOrgResponse> check performDataBinding(graphqlResponse, GetTotalAttendanceCountByParentOrgResponse);
}
remote isolated function getDailyAttendanceSummaryReport(string from_date, string to_date, int parent_organization_id) returns GetDailyAttendanceSummaryReportResponse|graphql:ClientError {
string query = string `query getDailyAttendanceSummaryReport($parent_organization_id:Int!,$from_date:String!,$to_date:String!) {daily_attendance_summary_report(parent_organization_id:$parent_organization_id,from_date:$from_date,to_date:$to_date) {sign_in_date present_count late_count total_count present_attendance_percentage late_attendance_percentage}}`;
map<anydata> variables = {"from_date": from_date, "to_date": to_date, "parent_organization_id": parent_organization_id};
remote isolated function getDailyAttendanceSummaryReport(string from_date, string to_date, int organization_id, int avinya_type_id) returns GetDailyAttendanceSummaryReportResponse|graphql:ClientError {
string query = string `query getDailyAttendanceSummaryReport($organization_id:Int!,$avinya_type_id:Int!,$from_date:String!,$to_date:String!) {daily_attendance_summary_report(organization_id:$organization_id,avinya_type_id:$avinya_type_id,from_date:$from_date,to_date:$to_date) {sign_in_date present_count late_count total_count present_attendance_percentage late_attendance_percentage}}`;
map<anydata> variables = {"from_date": from_date, "to_date": to_date, "organization_id": organization_id, "avinya_type_id": avinya_type_id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetDailyAttendanceSummaryReportResponse> check performDataBinding(graphqlResponse, GetDailyAttendanceSummaryReportResponse);
}
remote isolated function getOrganizationsByAvinyaType(int avinya_type) returns GetOrganizationsByAvinyaTypeResponse|graphql:ClientError {
string query = string `query getOrganizationsByAvinyaType($avinya_type:Int!) {organizations_by_avinya_type(avinya_type:$avinya_type) {id name {name_en} description organization_metadata {key_name value}}}`;
map<anydata> variables = {"avinya_type": avinya_type};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetOrganizationsByAvinyaTypeResponse> check performDataBinding(graphqlResponse, GetOrganizationsByAvinyaTypeResponse);
}
}
28 changes: 26 additions & 2 deletions campus/bffs/attendance/api/service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ service / on new http:Listener(9091) {
}
}

resource function get daily_attendance_summary_report/[int parent_organization_id]/[string from_date]/[string to_date]() returns ActivityParticipantAttendanceSummary[]|error {
GetDailyAttendanceSummaryReportResponse|graphql:ClientError getDailyAttendanceSummaryReportResponse = globalDataClient->getDailyAttendanceSummaryReport(from_date,to_date,parent_organization_id);
resource function get daily_attendance_summary_report/[int organization_id]/[int avinya_type_id]/[string from_date]/[string to_date]() returns ActivityParticipantAttendanceSummary[]|error {
GetDailyAttendanceSummaryReportResponse|graphql:ClientError getDailyAttendanceSummaryReportResponse = globalDataClient->getDailyAttendanceSummaryReport(from_date,to_date,organization_id,avinya_type_id);
if(getDailyAttendanceSummaryReportResponse is GetDailyAttendanceSummaryReportResponse) {
ActivityParticipantAttendanceSummary[] activityParticipantAttendances = [];
foreach var attendance_record in getDailyAttendanceSummaryReportResponse.daily_attendance_summary_report {
Expand All @@ -856,4 +856,28 @@ service / on new http:Listener(9091) {
":: Detail: " + getDailyAttendanceSummaryReportResponse.detail().toString());
}
}

resource function get organizations_by_avinya_type/[int avinya_type_id]() returns Organization[]|error {
GetOrganizationsByAvinyaTypeResponse|graphql:ClientError getOrganizationsByAvinyaTypeResponse = globalDataClient->getOrganizationsByAvinyaType(avinya_type_id);
if(getOrganizationsByAvinyaTypeResponse is GetOrganizationsByAvinyaTypeResponse) {
Organization[] organizations = [];
foreach var organization_record in getOrganizationsByAvinyaTypeResponse.organizations_by_avinya_type {
Organization|error organization = organization_record.cloneWithType(Organization);
if(organization is Organization) {
organizations.push(organization);
} else {
log:printError("Error while processing Application record received", organization);
return error("Error while processing Application record received: " + organization.message() +
":: Detail: " + organization.detail().toString());
}
}

return organizations;

} else {
log:printError("Error while creating application", getOrganizationsByAvinyaTypeResponse);
return error("Error while creating application: " + getOrganizationsByAvinyaTypeResponse.message() +
":: Detail: " + getOrganizationsByAvinyaTypeResponse.detail().toString());
}
}
}
15 changes: 15 additions & 0 deletions campus/bffs/attendance/api/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -789,4 +789,19 @@ public type GetDailyAttendanceSummaryReportResponse record {|
anydata? present_attendance_percentage;
anydata? late_attendance_percentage;
|}[] daily_attendance_summary_report;
|};

public type GetOrganizationsByAvinyaTypeResponse record {|
map<json?> __extensions?;
record {|
int? id;
record {|
string name_en;
|} name;
string? description;
record {|
string? key_name;
string? value;
|}[]? organization_metadata;
|}[] organizations_by_avinya_type;
|};
18 changes: 16 additions & 2 deletions campus/bffs/attendance/graphql_client/activity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,27 @@ query getTotalAttendanceCountByParentOrg($parent_organization_id: Int!, $from_da
}
}

query getDailyAttendanceSummaryReport($parent_organization_id: Int!, $from_date: String!, $to_date: String!) {
daily_attendance_summary_report(parent_organization_id: $parent_organization_id, from_date: $from_date, to_date: $to_date) {
query getDailyAttendanceSummaryReport($organization_id: Int!,$avinya_type_id: Int!, $from_date: String!, $to_date: String!) {
daily_attendance_summary_report(organization_id: $organization_id, avinya_type_id: $avinya_type_id,from_date: $from_date, to_date: $to_date) {
sign_in_date
present_count
late_count
total_count
present_attendance_percentage
late_attendance_percentage
}
}

query getOrganizationsByAvinyaType($avinya_type: Int!) {
organizations_by_avinya_type(avinya_type:$avinya_type) {
id
name{
name_en
}
description
organization_metadata{
key_name
value
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,16 @@ public isolated client class GraphqlClient {
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetTotalAttendanceCountByParentOrgResponse> check performDataBinding(graphqlResponse, GetTotalAttendanceCountByParentOrgResponse);
}
remote isolated function getDailyAttendanceSummaryReport(string from_date, string to_date, int parent_organization_id) returns GetDailyAttendanceSummaryReportResponse|graphql:ClientError {
string query = string `query getDailyAttendanceSummaryReport($parent_organization_id:Int!,$from_date:String!,$to_date:String!) {daily_attendance_summary_report(parent_organization_id:$parent_organization_id,from_date:$from_date,to_date:$to_date) {sign_in_date present_count late_count total_count present_attendance_percentage late_attendance_percentage}}`;
map<anydata> variables = {"from_date": from_date, "to_date": to_date, "parent_organization_id": parent_organization_id};
remote isolated function getDailyAttendanceSummaryReport(string from_date, string to_date, int organization_id, int avinya_type_id) returns GetDailyAttendanceSummaryReportResponse|graphql:ClientError {
string query = string `query getDailyAttendanceSummaryReport($organization_id:Int!,$avinya_type_id:Int!,$from_date:String!,$to_date:String!) {daily_attendance_summary_report(organization_id:$organization_id,avinya_type_id:$avinya_type_id,from_date:$from_date,to_date:$to_date) {sign_in_date present_count late_count total_count present_attendance_percentage late_attendance_percentage}}`;
map<anydata> variables = {"from_date": from_date, "to_date": to_date, "organization_id": organization_id, "avinya_type_id": avinya_type_id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetDailyAttendanceSummaryReportResponse> check performDataBinding(graphqlResponse, GetDailyAttendanceSummaryReportResponse);
}
remote isolated function getOrganizationsByAvinyaType(int avinya_type) returns GetOrganizationsByAvinyaTypeResponse|graphql:ClientError {
string query = string `query getOrganizationsByAvinyaType($avinya_type:Int!) {organizations_by_avinya_type(avinya_type:$avinya_type) {id name {name_en} description organization_metadata {key_name value}}}`;
map<anydata> variables = {"avinya_type": avinya_type};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetOrganizationsByAvinyaTypeResponse> check performDataBinding(graphqlResponse, GetOrganizationsByAvinyaTypeResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -876,3 +876,18 @@ public type GetDailyAttendanceSummaryReportResponse record {|
anydata? late_attendance_percentage;
|}[]? daily_attendance_summary_report;
|};

public type GetOrganizationsByAvinyaTypeResponse record {|
map<json?> __extensions?;
record {|
int? id;
record {|
string name_en;
|} name;
string? description;
record {|
string? key_name;
string? value;
|}[]? organization_metadata;
|}[]? organizations_by_avinya_type;
|};
10 changes: 9 additions & 1 deletion campus/bffs/attendance/graphql_client/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,14 @@ type OrganizationData {
parent_organizations: [OrganizationData!]
people: [PersonData!]
vacancies: [VacancyData!]
organization_metadata: [OrganizationMetaData!]
}

type OrganizationMetaData {
id: Int
organization_id: Int
key_name: String
value: String
}

type OrganizationStructureData {
Expand Down Expand Up @@ -869,7 +877,7 @@ type Query {
attendance_missed_by_security(organization_id: Int, parent_organization_id: Int, from_date: String = "", to_date: String = ""): [ActivityParticipantAttendanceMissedBySecurityData!]
daily_students_attendance_by_parent_org(parent_organization_id: Int): [DailyActivityParticipantAttendanceByParentOrgData!]
total_attendance_count_by_date(organization_id: Int, parent_organization_id: Int, from_date: String = "", to_date: String = ""): [TotalActivityParticipantAttendanceCountByDateData!]
daily_attendance_summary_report(parent_organization_id: Int, from_date: String = "", to_date: String = ""): [DailyActivityParticipantAttendanceSummaryReportData!]
daily_attendance_summary_report(organization_id: Int, avinya_type_id: Int, from_date: String = "", to_date: String = ""): [DailyActivityParticipantAttendanceSummaryReportData!]
}

input ResourceAllocation {
Expand Down
84 changes: 83 additions & 1 deletion campus/bffs/attendance/graphql_client/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2728,7 +2728,16 @@
"name": "daily_attendance_summary_report",
"args": [
{
"name": "parent_organization_id",
"name": "organization_id",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "avinya_type_id",
"type": {
"kind": "SCALAR",
"name": "Int",
Expand Down Expand Up @@ -5448,6 +5457,25 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "organization_metadata",
"args": [],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "OrganizationMetaData",
"ofType": null
}
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
Expand Down Expand Up @@ -5798,6 +5826,60 @@
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "OrganizationMetaData",
"fields": [
{
"name": "id",
"args": [],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "organization_id",
"args": [],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "key_name",
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "value",
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "InventoryData",
Expand Down
2 changes: 1 addition & 1 deletion campus/bffs/profile/api/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http"
version = "2.8.5"
version = "2.8.6"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down
4 changes: 2 additions & 2 deletions campus/bffs/profile/api/person_client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public isolated client class GraphqlClient {
name_en
}
description
child_organizations {
}
child_organizations_for_dashboard {
id
name {
name_en
}
description
}
}
parent_organizations {
id
name {
Expand Down
7 changes: 7 additions & 0 deletions campus/bffs/profile/api/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,13 @@ public type GetOrganizationResponse record {|
|} name;
string? description;
|}[]? child_organizations;
record {|
int? id;
record {|
string name_en;
|} name;
string? description;
|}[]? child_organizations_for_dashboard;
record {|
int? id;
record {|
Expand Down
Binary file modified campus/bffs/profile/graphql_client/schema.graphql
Binary file not shown.
Loading

0 comments on commit b84c666

Please sign in to comment.