Skip to content
Snippets Groups Projects
Commit d4f8f48c authored by Sirieam Marie Hunke's avatar Sirieam Marie Hunke
Browse files

Merge branch 'dev' into 'main'

New: Data Publication KPIs

See merge request !39
parents f242345c 59b36a7a
No related branches found
No related tags found
1 merge request!39New: Data Publication KPIs
Pipeline #1467772 passed
Showing
with 204 additions and 104 deletions
# Development container for dotnet
FROM mcr.microsoft.com/devcontainers/dotnet:8.0 as develop
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Remove any existing user with the same UID (if it's not the specified user)
RUN if id -u $USER_UID >/dev/null 2>&1; then \
existing_user=$(getent passwd $USER_UID | cut -d: -f1); \
if [ "$existing_user" != "$USERNAME" ]; then \
userdel -f $existing_user; \
fi; \
fi
# Change the user's GID and UID
RUN groupmod -g $USER_GID $USERNAME \
&& usermod -u $USER_UID -g $USER_GID $USERNAME
# Change user folder owner and group
RUN chown -R $USER_GID:$USER_GID /home/$USERNAME
# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
# Add nuget sources for private packages (here: api-client)
RUN dotnet nuget add source "https://git.rwth-aachen.de/api/v4/projects/88930/packages/nuget/index.json" -n "api-client"
\ No newline at end of file
version: "3.9"
services:
app:
build:
target: develop
user: vscode
userns_mode: keep-id:uid=1000,gid=1000
environment:
SSH_AUTH_SOCK: /.ssh/ssh-agent.sock
command: /bin/sh -c "while sleep 2s; do :; done"
volumes:
- ..:/workspace/kpi-generator:cached
- ./.vscode-server:/home/vscode/.vscode-server/:cached
- ${SSH_AUTH_SOCK}:/.ssh/ssh-agent.sock
networks:
- default
networks:
default:
driver: bridge
{
"name": "KPI Reporting Generator",
"dockerComposeFile": [
"compose.yml"
],
"service": "app",
"workspaceFolder": "/workspace/kpi-generator",
"updateRemoteUserUID": false,
"remoteUser": "vscode",
"containerUser": "vscode",
"postAttachCommand": "bash",
"customizations": {
"vscode": {
"settings": {
"NugetGallery.sources": [
"{\"name\":\"nuget.org\",\"url\":\"https://api.nuget.org/v3/index.json\"}",
"{\"name\":\"api-client\",\"url\":\"https://git.rwth-aachen.de/api/v4/projects/88930/packages/nuget/index.json\"}"
],
"nuget.includePrereleasePackageVersions": true
},
"extensions": [
"ms-dotnettools.csdevkit",
"ms-azuretools.vscode-docker",
"ms-dotnettools.csharp",
"mhutchie.git-graph",
"mutantdino.resourcemonitor",
"patcx.vscode-nuget-gallery"
]
}
},
"forwardPorts": []
}
\ No newline at end of file
/.devcontainer/.vscode-server/*
!/.devcontainer/.vscode-server/.gitkeep
/.devcontainer/.data/*
!/.devcontainer/.data/.gitkeep
.logs/
Output/*
internallog.txt
## Ignore the secrets settings
appsettings.Development.json
appsettings.Staging.json
appsettings.Production.json
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
......
......@@ -2,14 +2,14 @@ include:
- project: coscine/tools/gitlab-ci-templates
file:
- /dotnet.yml
- /container.yml
stages:
- build
- publish
variables:
DOTNET_MAIN_PROJECT_FOLDER: "KPI Generator"
DOTNET_MAIN_PROJECT_FOLDER: "KpiGenerator"
build-branch:
extends: .build-branch
......@@ -22,3 +22,8 @@ publish-gitlab-release:
publish:
extends: .publish-artifact-release
publish-container:
variables:
CONTAINER_CONTEXT_FOLDER_PATH: $CI_PROJECT_DIR/src/$DOTNET_MAIN_PROJECT_FOLDER
extends: .publish-container-gitlab
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "C#: KPI Reporting Generator Debug",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "dotnet: build",
"program": "${workspaceFolder}/src/KpiGenerator/bin/Debug/net8.0/Coscine.KpiGenerator.dll",
"args": [],
"cwd": "${workspaceFolder}/src/KpiGenerator",
"stopAtEntry": false,
"console": "internalConsole",
"env": {
"DOTNET_ENVIRONMENT": "Development"
}
}
]
}
\ No newline at end of file
{}
\ No newline at end of file
using System.Text.Json.Serialization;
namespace Coscine.KpiGenerator.Models;
public record PublicationRequestReport
{
[JsonPropertyName("Timestamp")]
public DateTime Timestamp { get; set; }
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
throwConfigExceptions="true"
throwExceptions="false"
internalLogFile="Logs/internal-nlog.txt"
internalLogLevel="Trace">
<targets>
<!-- Write logs to File -->
<target xsi:type="FallbackGroup"
name="fileGroup">
<target
xsi:type="File"
name="fileLogD"
fileName="D:/coscine/logs/${assembly-name}/${assembly-version}/log-${shortdate}.log"
maxArchiveFiles="7"
>
<layout xsi:type="CompoundLayout">
<layout xsi:type="JsonLayout" EscapeForwardSlash="true">
<attribute layout="${longdate}" name="Timestamp"/>
<attribute layout="${level:upperCase=true}" name="Level"/>
<attribute layout="${message}" name="Message"/>
<attribute layout="${exception:format=tostring,StackTrace}" name="Exception"/>
<attribute layout="${ndlc}" name="Context"/>
<attribute layout="${event-properties:item=Metric}" name="Alarm" encode="false"/>
<attribute name="EventProperties" encode="false" >
<layout xsi:type='JsonLayout' includeAllProperties="true" maxRecursionLimit="2"/>
</attribute>
</layout>
<layout xsi:type='SimpleLayout' text="," />
</layout>
</target>
<target
xsi:type="File"
name="fileLogC"
fileName="C:/coscine/logs/${assembly-name}/${assembly-version}/log-${shortdate}.log"
maxArchiveFiles="7"
>
<layout xsi:type="CompoundLayout">
<layout xsi:type="JsonLayout" EscapeForwardSlash="true">
<attribute layout="${longdate}" name="Timestamp"/>
<attribute layout="${level:upperCase=true}" name="Level"/>
<attribute layout="${message}" name="Message"/>
<attribute layout="${exception:format=tostring,StackTrace}" name="Exception"/>
<attribute layout="${ndlc}" name="Context"/>
<attribute layout="${event-properties:item=Metric}" name="Alarm" encode="false"/>
<attribute name="EventProperties" encode="false" >
<layout xsi:type='JsonLayout' includeAllProperties="true" maxRecursionLimit="2"/>
</attribute>
</layout>
<layout xsi:type='SimpleLayout' text="," />
</layout>
</target>
</target>
<!-- Write colored logs to Console -->
<target name="consoleLog" xsi:type="ColoredConsole" layout="[${uppercase:${level}}]: ${message}">
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" />
<highlight-row condition="level == LogLevel.Info" foregroundColor="White" />
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="DarkRed" />
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" />
</target>
</targets>
<rules>
<!--All logs, including from Microsoft, Level Trace-->
<logger name="*" minlevel="Trace" writeTo="fileGroup">
</logger>
<!--All logs, including from Microsoft, Level Info-->
<logger name="*" minlevel="Info" writeTo="consoleLog">
<filters defaultAction="Log">
<when condition="contains('${ndlc}','/api/heartbeat')" action="Ignore"/>
</filters>
</logger>
</rules>
</nlog>
\ No newline at end of file
......@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32526.322
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KPI Generator", "KPI Generator\KPI Generator.csproj", "{2B402E93-467B-49C1-8350-9277BDEDA9C3}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KpiGenerator", "KpiGenerator\KpiGenerator.csproj", "{2B402E93-467B-49C1-8350-9277BDEDA9C3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /App
# Copy everything
COPY . ./
# Add nuget sources for private packages (here: api-client)
RUN dotnet nuget add source "https://git.rwth-aachen.de/api/v4/projects/88930/packages/nuget/index.json" -n "api-client"
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
# Install cron and other necessary packages
RUN apt-get update && \
apt-get install -y cron && \
apt-get clean
WORKDIR /App
COPY --from=build-env /App/out .
# Set the build-time argument and default environment variable
ENV DOTNET_ENVIRONMENT=Development
# Create the log file
RUN touch /var/log/cron.log
ENTRYPOINT /bin/sh -c "/App/Coscine.KpiGenerator all"
\ No newline at end of file
......@@ -21,7 +21,7 @@
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Coscine.ApiClient" Version="1.6.0" />
<PackageReference Include="Coscine.ApiClient" Version="1.9.2" />
<PackageReference Include="dotNetRdf.Core" Version="3.1.1" />
<PackageReference Include="GitLabApiClient" Version="1.8.1-beta.5" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
......@@ -35,6 +35,12 @@
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
......
......@@ -17,7 +17,8 @@ public class MappingProfiles : Profile
.ForMember(pr => pr.Deleted, opt => opt.MapFrom(dto => dto.Deleted))
.ForMember(pr => pr.ProjectVisibility, opt => opt.MapFrom(dto => dto.Visibility))
.ForMember(pr => pr.Users, opt => opt.MapFrom(dto => dto.ProjectRoles.Count))
.ForMember(pr => pr.ResourceTypeQuota, opt => opt.MapFrom(dto => dto.ProjectQuota));
.ForMember(pr => pr.ResourceTypeQuota, opt => opt.MapFrom(dto => dto.ProjectQuota))
.ForMember(pr => pr.PublicationRequests, opt => opt.MapFrom(dto => dto.PublicationRequests));
CreateMap<ResourceAdminDto, ResourceReport>()
.ForMember(rr => rr.Id, opt => opt.MapFrom(dto => dto.Id))
......@@ -50,12 +51,12 @@ public class MappingProfiles : Profile
.ForMember(lp => lp.DisplayName, opt => opt.MapFrom(dto => dto.DisplayName));
CreateMap<UserInstituteDto, Organization>()
.ForMember(o => o.ReadOnly, opt => opt.MapFrom(dto => dto.VarReadOnly))
.ForMember(o => o.ReadOnly, opt => opt.MapFrom(dto => dto.ReadOnly))
.ForMember(o => o.Name, opt => opt.MapFrom(dto => dto.DisplayName))
.ForMember(o => o.RorUrl, opt => opt.MapFrom(dto => dto.Uri));
CreateMap<UserOrganizationDto, Organization>()
.ForMember(o => o.ReadOnly, opt => opt.MapFrom(dto => dto.VarReadOnly))
.ForMember(o => o.ReadOnly, opt => opt.MapFrom(dto => dto.ReadOnly))
.ForMember(o => o.Name, opt => opt.MapFrom(dto => dto.DisplayName))
.ForMember(o => o.RorUrl, opt => opt.MapFrom(dto => dto.Uri));
......@@ -93,7 +94,9 @@ public class MappingProfiles : Profile
.ForMember(rtq => rtq.Allocated, opt => opt.MapFrom(dto => dto.Allocated))
.ForMember(rtq => rtq.Maximum, opt => opt.MapFrom(dto => dto.Maximum));
CreateMap<ActivityLogDto, PublicationRequestReport>()
.ForMember(pr => pr.Timestamp, opt => opt.MapFrom(dto => dto.ActivityTimestamp));
CreateMap<ProjectPublicationRequestDto, PublicationRequestReport>()
.ForMember(prr => prr.PublicationServiceRorId, opt => opt.MapFrom(dto => dto.PublicationServiceRorId))
.ForMember(prr => prr.DateCreated, opt => opt.MapFrom(dto => dto.DateCreated))
.ForMember(prr => prr.Resources, opt => opt.MapFrom(dto => dto.Resources));
}
}
......@@ -5,7 +5,7 @@
/// </summary>
public class ApplicationProfileReport
{
public List<string> Titles { get; set; } = new();
public IReadOnlyList<string> Titles { get; set; } = [];
public string Uri { get; set; } = null!;
public string? Publisher { get; set; } = null!;
public string? Rights { get; set; } = null!;
......
......@@ -15,6 +15,17 @@ public class ReportingConfiguration
/// </summary>
public bool IsEnabled { get; init; }
/// <summary>
/// API token for the coscine API.
/// Requires the administrator role.
/// </summary>
public string ApiKey { get; set; } = null!;
/// <summary>
/// Address of the Coscine API.
/// </summary>
public string Endpoint { get; set; } = null!;
/// <summary>
/// Local storage configuration settings.
/// </summary>
......@@ -23,6 +34,14 @@ public class ReportingConfiguration
/// </value>
public LocalStorageConfiguration? Local { get; init; }
/// <summary>
/// Logger configuration settings.
/// </summary>
/// <value>
/// The logger storage configuration settings, or <c>null</c> if not configured.
/// </value>
public LoggerConfiguration? Logger { get; init; }
/// <summary>
/// GitLab configuration settings.
/// </summary>
......@@ -67,4 +86,9 @@ public class ReportingConfiguration
/// </summary>
public Organization? OtherOrganization { get; init; }
}
/// <summary>
/// Represents the configuration settings for the logger.
/// </summary>
public record LoggerConfiguration(string? LogLevel, string? LogHome);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment