Skip to content
Snippets Groups Projects
Commit 7b05dc8e authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Fix: Other Organization handling and DateTime for System Maintenance

parent 39326837
Branches
Tags
No related merge requests found
Pipeline #885768 passed
......@@ -13,7 +13,7 @@
<PropertyGroup>
<Authors>RWTH Aachen University</Authors>
<Company>IT Center, RWTH Aachen University</Company>
<Copyright>©2022 IT Center, RWTH Aachen University</Copyright>
<Copyright>©2023 IT Center, RWTH Aachen University</Copyright>
<Description>KPI Generator is a part of the Coscine group.</Description>
</PropertyGroup>
......
......@@ -85,23 +85,15 @@ public class ProjectReporting : Reporting<ProjectReportingOptions>
var organizationsFromProjects = GetTopLevelOrganizationsFromEntries(returnObjects.SelectMany(ro => ro.Organizations));
foreach (var entry in organizationsFromProjects)
{
var organization = Organizations.Find(o => o.RorUrl.Equals(entry.RorUrl));
if (organization is null)
{
organization = _otherOrganization;
Console.WriteLine($" WARNING!: Organization \"{entry.RorUrl}\" could not be correctly identified. Will use \"{_otherOrganization.RorUrl}\".");
_logger.LogWarning("Organization {ror} could not be correctly identified.", entry.RorUrl);
}
var returnObjectsForOrganization = returnObjects.Where(ro => ro.Organizations.Select(o => o.RorUrl).Any(e => e.Contains(entry.RorUrl))).ToList();
var reportingFile = new ReportingFileObject
{
Path = GetReportingPathOrganization(organization.RorUrl, ReportingFileName),
Path = GetReportingPathOrganization(entry.RorUrl, ReportingFileName),
Content = ConvertStringContentsToStream(JsonConvert.SerializeObject(returnObjectsForOrganization, Formatting.Indented))
};
reportingFilesPerOrganization.Add(reportingFile);
Console.WriteLine($" - {GetType().Name}: \"{GetReportingPathOrganization(organization.RorUrl, ReportingFileName)}\" generated successfully");
Console.WriteLine($" - {GetType().Name}: \"{GetReportingPathOrganization(entry.RorUrl, ReportingFileName)}\" generated successfully");
_logger.LogInformation("{Name}: Generated successfully {ReportingFile}.", GetType().Name, reportingFile);
}
......
......@@ -84,22 +84,15 @@ public class ResourceReporting : Reporting<ResourceReportingOptions>
var organizationsFromResources = GetTopLevelOrganizationsFromEntries(returnObjects.SelectMany(ro => ro.Organizations));
foreach (var entry in organizationsFromResources)
{
var organization = Organizations.Find(o => o.RorUrl.Equals(entry.RorUrl));
if (organization is null)
{
organization = _otherOrganization;
Console.WriteLine($" WARNING!: Organization \"{entry.RorUrl}\" could not be correctly identified. Will use \"{_otherOrganization.RorUrl}\".");
_logger.LogWarning("Organization {ror} could not be correctly identified.", entry.RorUrl);
}
var returnObjectsForOrganization = returnObjects.Where(ro => ro.Organizations.Select(o => o.RorUrl).Any(e => e.Equals(entry.RorUrl))).ToList();
var reportingFile = new ReportingFileObject
{
Path = GetReportingPathOrganization(organization.RorUrl, ReportingFileName),
Path = GetReportingPathOrganization(entry.RorUrl, ReportingFileName),
Content = ConvertStringContentsToStream(JsonConvert.SerializeObject(returnObjectsForOrganization, Formatting.Indented))
};
reportingFilesPerOrganization.Add(reportingFile);
Console.WriteLine($" - {GetType().Name}: \"{GetReportingPathOrganization(organization.RorUrl, ReportingFileName)}\" generated successfully");
Console.WriteLine($" - {GetType().Name}: \"{GetReportingPathOrganization(entry.RorUrl, ReportingFileName)}\" generated successfully");
_logger.LogInformation("{Name}: Generated successfully {ReportingFile}.", GetType().Name, reportingFile);
}
return reportingFilesPerOrganization;
......
......@@ -15,8 +15,8 @@ public class MaintenanceBannerObject
[JsonProperty("status")]
public string Status { get; set; } = null!;
[JsonProperty("start_at")]
public DateTime StartAt { get; set; }
public DateTime? StartAt { get; set; } = null!;
[JsonProperty("end_at")]
public DateTime EndAt { get; set; }
public DateTime? EndAt { get; set; } = null!;
}
......@@ -230,12 +230,12 @@ public class UserReporting : Reporting<UserReportingOptions>
private List<Organization> CleanUpOther(List<Organization> affiliations)
{
// Special case until `https://ror.org/%20https://ror.org/` is moved to `https://ror.org/_other`
if (affiliations.Any(o => o.RorUrl.Equals("https://ror.org/%20https://ror.org/")))
if (affiliations.Any(o => o.RorUrl.Equals("https://ror.org/%20https://ror.org/") || o.RorUrl.Equals("https://ror.org/")))
{
var cleanedUpAffiliations = affiliations;
foreach (var entry in cleanedUpAffiliations)
{
if (entry.RorUrl.Equals("https://ror.org/%20https://ror.org/"))
if (entry.RorUrl.Equals("https://ror.org/%20https://ror.org/") || entry.RorUrl.Equals("https://ror.org/"))
{
cleanedUpAffiliations[cleanedUpAffiliations.IndexOf(entry)] = new()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment