Skip to content

Commit

Permalink
Adjustments to getting data for ReportNotification for ResourceOwner
Browse files Browse the repository at this point in the history
  • Loading branch information
aleklundeq committed Nov 30, 2023
1 parent 5628120 commit e214ba5
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public interface IResourcesApiClient
Task<bool> ReassignRequestAsync(ResourceAllocationRequest item, string? department);
Task<IEnumerable<ResourceAllocationRequest>> GetAllRequestsForDepartment(string departmentIdentifier);
Task<IEnumerable<InternalPersonnelPerson>> GetAllPersonnelForDepartment(string departmentIdentifier);
Task<IEnumerable<ApiPersonAbsence>> GetLeaveForPersonnel(string personId);

#region Models

Expand All @@ -30,6 +31,13 @@ public class ResourceAllocationRequest
public bool HasProposedPerson => ProposedPerson?.Person.AzureUniquePersonId is not null;
public string? State { get; set; }
public Workflow? workflow { get; set; }
public DateTimeOffset Created { get; set; }
public InternalPersonnelPerson? CreatedBy { get; set; }

public DateTimeOffset? Updated { get; set; }
public InternalPersonnelPerson? UpdatedBy { get; set; }
public DateTimeOffset? LastActivity { get; set; }
public bool IsDraft { get; set; }
}

public enum RequestState
Expand All @@ -42,7 +50,7 @@ public class Workflow
public string LogicAppName { get; set; }

Check warning on line 50 in src/backend/function/Fusion.Resources.Functions/ApiClients/IResourcesApiClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'LogicAppName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string LogicAppVersion { get; set; }

Check warning on line 51 in src/backend/function/Fusion.Resources.Functions/ApiClients/IResourcesApiClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'LogicAppVersion' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))]
[JsonConverter(typeof(JsonStringEnumConverter))]
public ApiWorkflowState State { get; set; }

public IEnumerable<WorkflowStep> Steps { get; set; }

Check warning on line 56 in src/backend/function/Fusion.Resources.Functions/ApiClients/IResourcesApiClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Steps' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
Expand All @@ -61,7 +69,7 @@ public class WorkflowStep
/// <summary>
/// Pending, Approved, Rejected, Skipped
/// </summary>
[System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))]
[JsonConverter(typeof(JsonStringEnumConverter))]
public ApiWorkflowStepState State { get; set; }

public DateTimeOffset? Started { get; set; }
Expand All @@ -79,9 +87,8 @@ public enum ApiWorkflowStepState { Pending, Approved, Rejected, Skipped, Unknown

public class ProposedPerson
{
public Person Person { get; set; } = null!;
public InternalPersonnelPerson Person { get; set; } = null!;
}

public class Person
{
public Guid? AzureUniquePersonId { get; set; }
Expand All @@ -98,7 +105,6 @@ public class ProjectReference

public class InternalPersonnelPerson
{

public Guid? AzureUniquePersonId { get; set; }
public string? Mail { get; set; } = null!;
public string? Name { get; set; } = null!;
Expand All @@ -110,6 +116,7 @@ public class InternalPersonnelPerson
public bool IsResourceOwner { get; set; }
public string? AccountType { get; set; }
public List<PersonnelPosition> PositionInstances { get; set; } = new List<PersonnelPosition>();
public List<ApiPersonAbsence> ApiPersonAbsences { get; set; } = new List<ApiPersonAbsence>();
}

public class PersonnelPosition
Expand All @@ -127,6 +134,32 @@ public class PersonnelPosition
public double Workload { get; set; }
public ProjectReference? Project { get; set; }
}

public class ApiPersonAbsence
{
public Guid Id { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DateTimeOffset? Created { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public InternalPersonnelPerson? CreatedBy { get; set; }
public bool IsPrivate { get; set; }
public string? Comment { get; set; }
//public ApiTaskDetails? TaskDetails { get; set; } // Trengs denne?
public DateTimeOffset? AppliesFrom { get; set; }
public DateTimeOffset? AppliesTo { get; set; }
public ApiAbsenceType? Type { get; set; }
public double? AbsencePercentage { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool IsActive => AppliesFrom <= DateTime.UtcNow.Date && AppliesTo >= DateTime.UtcNow.Date;

}

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum ApiAbsenceType { Absence, Vacation, OtherTasks }



#endregion Models
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public async Task<IEnumerable<InternalPersonnelPerson>> GetAllPersonnelForDepart
return response.Value.ToList();
}

public async Task<IEnumerable<ApiPersonAbsence>> GetLeaveForPersonnel(string personId)
{
var response = await resourcesClient.GetAsJsonAsync<InternalCollection<ApiPersonAbsence>>(
$"persons/{personId}/absence");

return response.Value.ToList();
}

public async Task<bool> ReassignRequestAsync(ResourceAllocationRequest item, string? department)
{
var content = JsonConvert.SerializeObject(new { AssignedDepartment = department });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ public AdaptiveCardBuilder AddListContainer(string headerText, IEnumerable<Perso
return this;
}

public AdaptiveCardBuilder AddActionButton(string title, string url)
{
var actionButton = new AdaptiveOpenUrlAction
{

Title = title,
Url = new Uri(url)
};

_adaptiveCard.Actions.Add(actionButton);
return this;
}
public AdaptiveCard Build()
{
return _adaptiveCard;
Expand All @@ -96,7 +108,7 @@ public AdaptiveCardColumn(string numberText, string headerText, string? customTe
{
new AdaptiveTextBlock
{
Text = $"{numberText} - {customText ?? ""}",
Text = $"{numberText} {customText ?? ""}",
Wrap = true,
HorizontalAlignment = AdaptiveHorizontalAlignment.Center,
Size = AdaptiveTextSize.ExtraLarge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ namespace Fusion.Resources.Functions.Functions.Notifications.Models.AdaptiveCard

public class ResourceOwnerAdaptiveCardData
{
public int TotalNumberOfRequests { get; set; }
public int NumberOfOlderRequests { get; set; }
public int NumberOfNewRequestsWithNoNomination { get; set; }
public int TotalNumberOfPersonnel { get; set; }
public int TotalCapacityInUsePercentage { get; set; }
public int NumberOfRequestsLastWeek { get; set; }
public int NumberOfOpenRequests { get; set; }
public int NumberOfRequestsStartingInMoreThanThreeMonths { get; set; }
public int NumberOfRequestsStartingInLessThanThreeMonths { get; set; }
public int AverageTimeToHandleRequests { get; set; }
public int AllocationChangesAwaitingTaskOwnerAction { get; set; }
public int ProjectChangesAffectingNextThreeMonths { get; set; }
internal IEnumerable<PersonnelContent> PersonnelPositionsEndingWithNoFutureAllocation { get; set; }
public int PercentAllocationOfTotalCapacity { get; set; }

internal IEnumerable<PersonnelContent> PersonnelAllocatedMoreThan100Percent { get; set; }
public int NumberOfExtContractsEnding { get; set; }
}
Loading

0 comments on commit e214ba5

Please sign in to comment.