Skip to main content
Sign in
Snippets Groups Projects
Commit 1ea1a12f authored by Sirieam Marie Hunke's avatar Sirieam Marie Hunke
Browse files

WIP

parent 256b0db1
No related branches found
No related tags found
1 merge request!7Update: KPI generator for Project
Pipeline #818572 passed
......@@ -24,7 +24,6 @@ public abstract class Reporting<O> where O : class
private static string InstanceName { get; set; } = null!;
public virtual string ReportingFileName { get; init; } = null!;
public readonly Organization _otherOrganization = new()
{
Name = "Other",
......@@ -37,7 +36,6 @@ public abstract class Reporting<O> where O : class
/// <remarks>https://git.rwth-aachen.de/coscine/reporting/reporting-database</remarks>
private static readonly int ReportingDatabaseProjectId = 75304;
public Reporting(O options)
{
InstanceName = this.GetType().Name;
......@@ -71,14 +69,13 @@ public abstract class Reporting<O> where O : class
return success;
}
private async Task<bool> PublishAsync(IEnumerable<ReportingFileObject> files)
{
try
{
// Retrieve Reporting Database project
var reportingDatabaseProject = await GitLabClient.Projects.GetAsync(ReportingDatabaseProjectId);
var commitBranch = reportingDatabaseProject.DefaultBranch;
var commitBranch = "projectReport";
var commitMessage = $"{InstanceName} Generated - {DateTime.Now:dd.MM.yyyy HH:mm}"; // CompleteReporting Generated - 31.08.2022 10:25
var projectTree = await GitLabClient.Trees.GetAsync(reportingDatabaseProject, o =>
......@@ -180,6 +177,7 @@ public abstract class Reporting<O> where O : class
{
return string.Format("General/{0}", fileName);
}
public static string GetReportingPathOrganization(string organizationRor, string fileName)
{
return string.Format("Organizations/{0}/{1}", organizationRor, fileName);
......
......
......@@ -5,6 +5,7 @@ using Newtonsoft.Json;
using KPIGenerator.Utils;
using static KPIGenerator.Utils.CommandLineOptions;
using Coscine.Database.DataModel;
using Coscine.ResourceTypes;
namespace KPIGenerator.Reportings.Project;
......@@ -13,7 +14,7 @@ public class ProjectReporting : Reporting<ProjectReportingOptions>
private readonly ProjectModel _projectModel;
private readonly ResourceModel _resourceModel;
private readonly ProjectRoleModel _projectRoleModel;
private readonly ProjectInstituteModel _projectInstituteModel;
private readonly ResourceTypeModel _resourceTypeModel;
public ProjectReporting(ProjectReportingOptions options) : base(options)
{
......@@ -21,7 +22,7 @@ public class ProjectReporting : Reporting<ProjectReportingOptions>
_projectModel = new ProjectModel();
_projectRoleModel = new ProjectRoleModel();
_resourceModel = new ResourceModel();
_projectInstituteModel = new ProjectInstituteModel();
_resourceTypeModel = new ResourceTypeModel();
}
public override IEnumerable<ReportingFileObject> GenerateReporting()
......@@ -60,7 +61,7 @@ public class ProjectReporting : Reporting<ProjectReportingOptions>
ProjectVisibilityId = projectReturnObject.Visibility.Id,
GrantId = projectReturnObject.GrantId,
Members = _projectRoleModel.GetAllWhere(x => x.ProjectId == projectReturnObject.Id).Count(),
ResourceQuota = GetResourceQuota(project)
ResourceTypeQuota = GetResourceTypeQuota(projectReturnObject.Id)
};
}
return returnObjects;
......@@ -89,9 +90,11 @@ public class ProjectReporting : Reporting<ProjectReportingOptions>
return reportingFilesPerOrganization;
}
private ResourceQuotaReturnObject GetResourceQuota(object resource)
private IEnumerable<ProjectQuotaReturnObject> GetResourceTypeQuota(Guid projectId)
{
throw new NotImplementedException();
var resourceTypes = _resourceTypeModel.GetAllWhere(x => x.Enabled == true);
return resourceTypes.Select(x => Helpers.CreateProjectQuotaReturnObject(x, projectId));
}
private List<Organization> GetOrganizations(Guid projectID)
......
......
......@@ -16,7 +16,5 @@ public class ReturnObject
public Guid ProjectVisibilityId { get; set; }
public string? GrantId { get; set; }
public int? Members { get; set; } = null;
public ResourceQuotaReturnObject? ResourceQuota { get; set; } = null!;
public IEnumerable<ProjectQuotaReturnObject> ResourceTypeQuota { get; set; } = null!;
}
\ No newline at end of file
......@@ -85,7 +85,7 @@ public class UserReporting : Reporting<UserReportingOptions>
reportingFilesPerOrganization.Add(new ReportingFileObject
{
Path = GetReportingPathOrganization(organization.Ror.Replace("https://ror.org/", "").ToLower(), ReportingFileName),
Path = GetReportingPathOrganization(organization.RorUrl.Replace("https://ror.org/", "").ToLower(), ReportingFileName),
Content = ConvertStringContentsToStream(JsonConvert.SerializeObject(returnObjectsForOrganization, Formatting.Indented))
});
}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment