Merge pull request #328 from Oloodi/311-fix-today-status---check-in-display-for-zero-check-ins

solving the problem of bad information in live today
This commit is contained in:
José Salazar
2026-01-29 21:48:51 -05:00
committed by GitHub
7 changed files with 18352 additions and 18362 deletions

View File

@@ -1,16 +1,16 @@
# Basic Usage # Basic Usage
```dart ```dart
ExampleConnector.instance.createInvoiceTemplate(createInvoiceTemplateVariables).execute(); ExampleConnector.instance.getWorkforceById(getWorkforceByIdVariables).execute();
ExampleConnector.instance.updateInvoiceTemplate(updateInvoiceTemplateVariables).execute(); ExampleConnector.instance.getWorkforceByVendorAndStaff(getWorkforceByVendorAndStaffVariables).execute();
ExampleConnector.instance.deleteInvoiceTemplate(deleteInvoiceTemplateVariables).execute(); ExampleConnector.instance.listWorkforceByVendorId(listWorkforceByVendorIdVariables).execute();
ExampleConnector.instance.listOrders(listOrdersVariables).execute(); ExampleConnector.instance.listWorkforceByStaffId(listWorkforceByStaffIdVariables).execute();
ExampleConnector.instance.getOrderById(getOrderByIdVariables).execute(); ExampleConnector.instance.getWorkforceByVendorAndNumber(getWorkforceByVendorAndNumberVariables).execute();
ExampleConnector.instance.getOrdersByBusinessId(getOrdersByBusinessIdVariables).execute(); ExampleConnector.instance.createEmergencyContact(createEmergencyContactVariables).execute();
ExampleConnector.instance.getOrdersByVendorId(getOrdersByVendorIdVariables).execute(); ExampleConnector.instance.updateEmergencyContact(updateEmergencyContactVariables).execute();
ExampleConnector.instance.getOrdersByStatus(getOrdersByStatusVariables).execute(); ExampleConnector.instance.deleteEmergencyContact(deleteEmergencyContactVariables).execute();
ExampleConnector.instance.getOrdersByDateRange(getOrdersByDateRangeVariables).execute(); ExampleConnector.instance.listStaffAvailabilities(listStaffAvailabilitiesVariables).execute();
ExampleConnector.instance.getRapidOrders(getRapidOrdersVariables).execute(); ExampleConnector.instance.listStaffAvailabilitiesByStaffId(listStaffAvailabilitiesByStaffIdVariables).execute();
``` ```
@@ -23,8 +23,8 @@ Optional fields can be discovered based on classes that have `Optional` object t
This is an example of a mutation with an optional field: This is an example of a mutation with an optional field:
```dart ```dart
await ExampleConnector.instance.filterAttireOptions({ ... }) await ExampleConnector.instance.listStaffCoursesByCourseId({ ... })
.itemId(...) .offset(...)
.execute(); .execute();
``` ```

View File

@@ -116,12 +116,14 @@ class ListStaffsApplicationsByBusinessForDayApplicationsShiftRole {
final ListStaffsApplicationsByBusinessForDayApplicationsShiftRoleShift shift; final ListStaffsApplicationsByBusinessForDayApplicationsShiftRoleShift shift;
final int count; final int count;
final int? assigned; final int? assigned;
final double? hours;
final ListStaffsApplicationsByBusinessForDayApplicationsShiftRoleRole role; final ListStaffsApplicationsByBusinessForDayApplicationsShiftRoleRole role;
ListStaffsApplicationsByBusinessForDayApplicationsShiftRole.fromJson(dynamic json): ListStaffsApplicationsByBusinessForDayApplicationsShiftRole.fromJson(dynamic json):
shift = ListStaffsApplicationsByBusinessForDayApplicationsShiftRoleShift.fromJson(json['shift']), shift = ListStaffsApplicationsByBusinessForDayApplicationsShiftRoleShift.fromJson(json['shift']),
count = nativeFromJson<int>(json['count']), count = nativeFromJson<int>(json['count']),
assigned = json['assigned'] == null ? null : nativeFromJson<int>(json['assigned']), assigned = json['assigned'] == null ? null : nativeFromJson<int>(json['assigned']),
hours = json['hours'] == null ? null : nativeFromJson<double>(json['hours']),
role = ListStaffsApplicationsByBusinessForDayApplicationsShiftRoleRole.fromJson(json['role']); role = ListStaffsApplicationsByBusinessForDayApplicationsShiftRoleRole.fromJson(json['role']);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
@@ -136,11 +138,12 @@ class ListStaffsApplicationsByBusinessForDayApplicationsShiftRole {
return shift == otherTyped.shift && return shift == otherTyped.shift &&
count == otherTyped.count && count == otherTyped.count &&
assigned == otherTyped.assigned && assigned == otherTyped.assigned &&
hours == otherTyped.hours &&
role == otherTyped.role; role == otherTyped.role;
} }
@override @override
int get hashCode => Object.hashAll([shift.hashCode, count.hashCode, assigned.hashCode, role.hashCode]); int get hashCode => Object.hashAll([shift.hashCode, count.hashCode, assigned.hashCode, hours.hashCode, role.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -150,6 +153,9 @@ class ListStaffsApplicationsByBusinessForDayApplicationsShiftRole {
if (assigned != null) { if (assigned != null) {
json['assigned'] = nativeToJson<int?>(assigned); json['assigned'] = nativeToJson<int?>(assigned);
} }
if (hours != null) {
json['hours'] = nativeToJson<double?>(hours);
}
json['role'] = role.toJson(); json['role'] = role.toJson();
return json; return json;
} }
@@ -158,6 +164,7 @@ class ListStaffsApplicationsByBusinessForDayApplicationsShiftRole {
required this.shift, required this.shift,
required this.count, required this.count,
this.assigned, this.assigned,
this.hours,
required this.role, required this.role,
}); });
} }

View File

@@ -26,10 +26,11 @@ class CoverageDashboard extends StatelessWidget {
final int needed = s['workersNeeded'] as int? ?? 0; final int needed = s['workersNeeded'] as int? ?? 0;
final int confirmed = s['filled'] as int? ?? 0; final int confirmed = s['filled'] as int? ?? 0;
final double rate = s['hourlyRate'] as double? ?? 0.0; final double rate = s['hourlyRate'] as double? ?? 0.0;
final double hours = s['hours'] as double? ?? 0.0;
totalNeeded += needed; totalNeeded += needed;
totalConfirmed += confirmed; totalConfirmed += confirmed;
todayCost += rate * 8 * confirmed; todayCost += rate * hours;
} }
final int coveragePercent = totalNeeded > 0 final int coveragePercent = totalNeeded > 0
@@ -104,15 +105,13 @@ class CoverageDashboard extends StatelessWidget {
icon: UiIcons.warning, icon: UiIcons.warning,
isWarning: unfilledPositions > 0, isWarning: unfilledPositions > 0,
), ),
if (lateWorkersCount > 0) ...<Widget>[ const SizedBox(height: UiConstants.space2),
const SizedBox(height: UiConstants.space2), _StatusCard(
_StatusCard( label: 'Running Late',
label: 'Running Late', value: '$lateWorkersCount',
value: '$lateWorkersCount', icon: UiIcons.error,
icon: UiIcons.error, isError: true,
isError: true, ),
),
],
], ],
), ),
), ),
@@ -122,7 +121,7 @@ class CoverageDashboard extends StatelessWidget {
children: <Widget>[ children: <Widget>[
_StatusCard( _StatusCard(
label: 'Checked In', label: 'Checked In',
value: '$checkedInCount/$totalConfirmed', value: '$checkedInCount/$totalNeeded',
icon: UiIcons.success, icon: UiIcons.success,
isInfo: true, isInfo: true,
), ),

View File

@@ -31,6 +31,15 @@ class _LiveActivityWidgetState extends State<LiveActivityWidget> {
final DateTime now = DateTime.now(); final DateTime now = DateTime.now();
final DateTime start = DateTime(now.year, now.month, now.day); final DateTime start = DateTime(now.year, now.month, now.day);
final DateTime end = DateTime(now.year, now.month, now.day, 23, 59, 59, 999); final DateTime end = DateTime(now.year, now.month, now.day, 23, 59, 59, 999);
final fdc.QueryResult<dc.ListShiftRolesByBusinessAndDateRangeData,
dc.ListShiftRolesByBusinessAndDateRangeVariables> shiftRolesResult =
await dc.ExampleConnector.instance
.listShiftRolesByBusinessAndDateRange(
businessId: businessId,
start: _toTimestamp(start),
end: _toTimestamp(end),
)
.execute();
final fdc.QueryResult<dc.ListStaffsApplicationsByBusinessForDayData, final fdc.QueryResult<dc.ListStaffsApplicationsByBusinessForDayData,
dc.ListStaffsApplicationsByBusinessForDayVariables> result = dc.ListStaffsApplicationsByBusinessForDayVariables> result =
await dc.ExampleConnector.instance await dc.ExampleConnector.instance
@@ -41,33 +50,20 @@ class _LiveActivityWidgetState extends State<LiveActivityWidget> {
) )
.execute(); .execute();
if (result.data.applications.isEmpty) { if (shiftRolesResult.data.shiftRoles.isEmpty &&
result.data.applications.isEmpty) {
return _LiveActivityData.empty(); return _LiveActivityData.empty();
} }
final Map<String, _LiveShiftAggregate> aggregates =
<String, _LiveShiftAggregate>{};
for (final dc.ListStaffsApplicationsByBusinessForDayApplications app
in result.data.applications) {
final String key = '${app.shiftId}:${app.roleId}';
final _LiveShiftAggregate aggregate = aggregates[key] ??
_LiveShiftAggregate(
workersNeeded: app.shiftRole.count,
assigned: app.shiftRole.assigned ?? 0,
cost: app.shiftRole.shift.cost ?? 0,
);
aggregates[key] = aggregate;
}
int totalNeeded = 0; int totalNeeded = 0;
int totalAssigned = 0;
double totalCost = 0; double totalCost = 0;
for (final _LiveShiftAggregate aggregate in aggregates.values) { for (final dc.ListShiftRolesByBusinessAndDateRangeShiftRoles shiftRole
totalNeeded += aggregate.workersNeeded; in shiftRolesResult.data.shiftRoles) {
totalAssigned += aggregate.assigned; totalNeeded += shiftRole.count;
totalCost += aggregate.cost; totalCost += shiftRole.totalValue ?? 0;
} }
final int totalAssigned = result.data.applications.length;
int lateCount = 0; int lateCount = 0;
int checkedInCount = 0; int checkedInCount = 0;
for (final dc.ListStaffsApplicationsByBusinessForDayApplications app for (final dc.ListStaffsApplicationsByBusinessForDayApplications app
@@ -137,9 +133,8 @@ class _LiveActivityWidgetState extends State<LiveActivityWidget> {
<String, Object>{ <String, Object>{
'workersNeeded': data.totalNeeded, 'workersNeeded': data.totalNeeded,
'filled': data.totalAssigned, 'filled': data.totalAssigned,
'hourlyRate': data.totalAssigned == 0 'hourlyRate': 1.0,
? 0.0 'hours': data.totalCost,
: data.totalCost / data.totalAssigned,
'status': 'OPEN', 'status': 'OPEN',
'date': DateTime.now().toIso8601String().split('T')[0], 'date': DateTime.now().toIso8601String().split('T')[0],
}, },
@@ -193,15 +188,3 @@ class _LiveActivityData {
); );
} }
} }
class _LiveShiftAggregate {
_LiveShiftAggregate({
required this.workersNeeded,
required this.assigned,
required this.cost,
});
final int workersNeeded;
final int assigned;
final double cost;
}

View File

@@ -429,6 +429,7 @@ query listStaffsApplicationsByBusinessForDay(
} }
count count
assigned assigned
hours
role{ role{
name name