Migrated endpoints from user to member; Renamed membership to member

This commit is contained in:
Constantin Graf
2024-05-13 19:50:50 +02:00
parent ba335b4f05
commit b2365e2778
64 changed files with 853 additions and 456 deletions

View File

@@ -335,20 +335,22 @@ class DashboardService
}
/**
* Rhe 4 most recently active members of your team with user_id, name, description of the latest time entry, time_entry_id, task_id and a boolean status if the team member is currently working
* Rhe 4 most recently active members of your team with member_id, name, description of the latest time entry, time_entry_id, task_id and a boolean status if the team member is currently working
*
* @return array<int, array{user_id: string, name: string, description: string|null, time_entry_id: string, task_id: string|null, status: bool }>
* @return array<int, array{member_id: string, name: string, description: string|null, time_entry_id: string, task_id: string|null, status: bool }>
*/
public function latestTeamActivity(Organization $organization): array
{
$timeEntries = TimeEntry::query()
->select(DB::raw('distinct on (user_id) user_id, description, id, task_id, start, "end"'))
->select(DB::raw('distinct on (member_id) member_id, description, id, task_id, start, "end"'))
->whereBelongsTo($organization, 'organization')
->orderBy('user_id')
->orderBy('member_id')
->orderBy('start', 'desc')
// Note: limit here does not work because of the distinct on
->with([
'user',
'member' => [
'user',
],
])
->get()
->sortByDesc('start')
@@ -358,8 +360,8 @@ class DashboardService
foreach ($timeEntries as $timeEntry) {
$response[] = [
'user_id' => $timeEntry->user_id,
'name' => $timeEntry->user->name,
'member_id' => $timeEntry->member_id,
'name' => $timeEntry->member->user->name,
'description' => $timeEntry->description,
'time_entry_id' => $timeEntry->id,
'task_id' => $timeEntry->task_id,