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

batch selection added for attendance #181

Merged
merged 3 commits into from
Nov 22, 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
81 changes: 59 additions & 22 deletions api/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,30 @@ service /graphql on new graphql:Listener(4000) {
return new (name, id);
}

isolated resource function get organizations_by_avinya_type(int? avinya_type) returns OrganizationData[]|error? {
isolated resource function get organizations_by_avinya_type(int? avinya_type, int? active = 0) returns OrganizationData[]|error? {

stream<Organization, error?> org_list;
lock {
org_list = db_client->query(

if (active == 1) {

lock {
org_list = db_client->query(
`SELECT *
FROM organization
WHERE avinya_type = ${avinya_type} and active = ${active}`);
}

} else {

lock {
org_list = db_client->query(
`SELECT *
FROM organization
WHERE avinya_type = ${avinya_type}
`
);
}

}

OrganizationData[] organizationListDatas = [];
Expand Down Expand Up @@ -6046,30 +6060,53 @@ AND p.organization_id IN (
isolated resource function get monthly_leave_dates_record_by_id(int organization_id, int year, int month) returns MonthlyLeaveDatesData|error? {
if ((organization_id is int) && (year is int) && (month is int)) {

MonthlyLeaveDates|error? monthly_leave_dates_raw = db_client->queryRow(
MonthlyLeaveDates|error? monthly_leave_dates_raw = db_client->queryRow(
`SELECT *
FROM monthly_leave_dates
WHERE organization_id = ${organization_id} and
year = ${year} and month = ${month} ;`);

if (monthly_leave_dates_raw is MonthlyLeaveDates) {
return new (0,monthly_leave_dates_raw);
}else{
// Return a new empty MonthlyLeaveDates object if no record is found
MonthlyLeaveDates emptyLeaveDates = {
id: null,
year: null,
month: null,
organization_id: null,
leave_dates_list: [],
daily_amount: null,
created: null,
updated: null,
total_days_in_month: null,
leave_dates: null
};
return new(0,emptyLeaveDates);
}
if (monthly_leave_dates_raw is MonthlyLeaveDates) {
return new (0, monthly_leave_dates_raw);
} else {
// Return a new empty MonthlyLeaveDates object if no record is found
MonthlyLeaveDates emptyLeaveDates = {
id: null,
year: null,
month: null,
organization_id: null,
leave_dates_list: [],
daily_amount: null,
created: null,
updated: null,
total_days_in_month: null,
leave_dates: null
};
return new (0, emptyLeaveDates);
}
}
}

isolated resource function get calendar_metadata_by_org_id(int organization_id) returns CalendarMetaData|error? {

if (organization_id is int) {

CalendarMetadata|error? calendar_metadata_raw = db_client->queryRow(
`SELECT *
FROM calendar_metadata
WHERE organization_id = ${organization_id} ;`);

if (calendar_metadata_raw is CalendarMetadata) {
return new (0, calendar_metadata_raw);
} else {
// Return a new empty Calendar Metadata object if no record is found
CalendarMetadata emptyCalendarMetadata = {
id: null,
organization_id: organization_id,
monthly_payment_amount: 0.0
};
return new (0, emptyCalendarMetadata);
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions api/organization_data.bal
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,10 @@ lock{
return org_meta_data_details;
}

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

}
1 change: 1 addition & 0 deletions api/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public type Organization record {|
int? phone;
string? description;
string? notes;
int? active;
|};

type ParentChildOrganization record {|
Expand Down
Loading