mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Port over metrics.html
This commit is contained in:
parent
3bbc130cc0
commit
2ba331acee
@ -18,7 +18,6 @@ namespace Wabbajack.BuildServer.Test
|
||||
{
|
||||
private static string CONN_STR = @"Data Source=.\SQLEXPRESS;Integrated Security=True;";
|
||||
public string PublicConnStr => CONN_STR + $";Initial Catalog={DBName}";
|
||||
private AppSettings _appSettings;
|
||||
protected SqlService _sqlService;
|
||||
private bool _finishedSchema;
|
||||
private string DBName { get; }
|
||||
|
@ -38,7 +38,6 @@ namespace Wabbajack.BuildServer.Test
|
||||
{
|
||||
var sqlService = Fixture.GetService<SqlService>();
|
||||
var modId = long.MaxValue >> 1;
|
||||
var fileId = long.MaxValue >> 2;
|
||||
await sqlService.AddNexusModFiles(Game.SkyrimSpecialEdition, modId, DateTime.Now,
|
||||
new NexusApiClient.GetModFilesResponse {files = new List<NexusFileInfo>
|
||||
{
|
||||
|
32
Wabbajack.Server.Test/Wabbajack.Server.Test.csproj
Normal file
32
Wabbajack.Server.Test/Wabbajack.Server.Test.csproj
Normal file
@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.2.1" />
|
||||
<PackageReference Include="XunitContext" Version="1.9.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Wabbajack.Common\Wabbajack.Common.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Server\Wabbajack.Server.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="sql\NotifyStates\00e8bbbf591f61a3_6a5eb07c4b3c03fde38c9223a94a38c9076ef8fc8167f77c875c58db8f2aefd2.ini">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="sql\wabbajack_db.sql" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
615
Wabbajack.Server.Test/sql/wabbajack_db.sql
Normal file
615
Wabbajack.Server.Test/sql/wabbajack_db.sql
Normal file
@ -0,0 +1,615 @@
|
||||
USE [master]
|
||||
GO
|
||||
/****** Object: Database [wabbajack_prod] Script Date: 3/28/2020 4:58:58 PM ******/
|
||||
CREATE DATABASE [wabbajack_prod]
|
||||
CONTAINMENT = NONE
|
||||
WITH CATALOG_COLLATION = DATABASE_DEFAULT
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET COMPATIBILITY_LEVEL = 150
|
||||
GO
|
||||
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
|
||||
begin
|
||||
EXEC [wabbajack_prod].[dbo].[sp_fulltext_database] @action = 'enable'
|
||||
end
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET ANSI_NULL_DEFAULT OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET ANSI_NULLS OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET ANSI_PADDING OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET ANSI_WARNINGS OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET ARITHABORT OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET AUTO_CLOSE OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET AUTO_SHRINK OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET AUTO_UPDATE_STATISTICS ON
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET CURSOR_CLOSE_ON_COMMIT OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET CURSOR_DEFAULT GLOBAL
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET CONCAT_NULL_YIELDS_NULL OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET NUMERIC_ROUNDABORT OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET QUOTED_IDENTIFIER OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET RECURSIVE_TRIGGERS OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET DISABLE_BROKER
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET DATE_CORRELATION_OPTIMIZATION OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET TRUSTWORTHY OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET ALLOW_SNAPSHOT_ISOLATION OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET PARAMETERIZATION SIMPLE
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET READ_COMMITTED_SNAPSHOT OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET HONOR_BROKER_PRIORITY OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET RECOVERY FULL
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET MULTI_USER
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET PAGE_VERIFY CHECKSUM
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET DB_CHAINING OFF
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET TARGET_RECOVERY_TIME = 60 SECONDS
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET DELAYED_DURABILITY = DISABLED
|
||||
GO
|
||||
EXEC sys.sp_db_vardecimal_storage_format N'wabbajack_prod', N'ON'
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET QUERY_STORE = OFF
|
||||
GO
|
||||
USE [wabbajack_prod]
|
||||
GO
|
||||
/****** Object: Schema [test] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
CREATE SCHEMA [test]
|
||||
GO
|
||||
/****** Object: UserDefinedTableType [dbo].[ArchiveContentType] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
CREATE TYPE [dbo].[ArchiveContentType] AS TABLE(
|
||||
[Parent] [bigint] NOT NULL,
|
||||
[Child] [bigint] NOT NULL,
|
||||
[Path] [nvarchar](max) NOT NULL
|
||||
)
|
||||
GO
|
||||
/****** Object: UserDefinedTableType [dbo].[IndexedFileType] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
CREATE TYPE [dbo].[IndexedFileType] AS TABLE(
|
||||
[Hash] [bigint] NOT NULL,
|
||||
[Sha256] [binary](32) NOT NULL,
|
||||
[Sha1] [binary](20) NOT NULL,
|
||||
[Md5] [binary](16) NOT NULL,
|
||||
[Crc32] [int] NOT NULL,
|
||||
[Size] [bigint] NOT NULL
|
||||
)
|
||||
GO
|
||||
/****** Object: UserDefinedFunction [dbo].[Base64ToLong] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
-- =============================================
|
||||
-- Author: <Author,,Name>
|
||||
-- Create date: <Create Date, ,>
|
||||
-- Description: <Description, ,>
|
||||
-- =============================================
|
||||
CREATE FUNCTION [dbo].[Base64ToLong]
|
||||
(
|
||||
-- Add the parameters for the function here
|
||||
@Input varchar
|
||||
)
|
||||
RETURNS bigint
|
||||
AS
|
||||
BEGIN
|
||||
-- Declare the return variable here
|
||||
DECLARE @ResultVar bigint
|
||||
|
||||
-- Add the T-SQL statements to compute the return value here
|
||||
SELECT @ResultVar = CAST('string' as varbinary(max)) FOR XML PATH(''), BINARY BASE64
|
||||
|
||||
-- Return the result of the function
|
||||
RETURN @ResultVar
|
||||
|
||||
END
|
||||
GO
|
||||
/****** Object: UserDefinedFunction [dbo].[MaxMetricDate] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
-- =============================================
|
||||
-- Author: <Author,,Name>
|
||||
-- Create date: <Create Date, ,>
|
||||
-- Description: <Description, ,>
|
||||
-- =============================================
|
||||
CREATE FUNCTION [dbo].[MaxMetricDate]
|
||||
(
|
||||
)
|
||||
RETURNS date
|
||||
AS
|
||||
BEGIN
|
||||
-- Declare the return variable here
|
||||
DECLARE @Result date
|
||||
|
||||
-- Add the T-SQL statements to compute the return value here
|
||||
SELECT @Result = max(Timestamp) from dbo.Metrics where MetricsKey is not null
|
||||
|
||||
-- Return the result of the function
|
||||
RETURN @Result
|
||||
|
||||
END
|
||||
GO
|
||||
/****** Object: UserDefinedFunction [dbo].[MinMetricDate] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
-- =============================================
|
||||
-- Author: <Author,,Name>
|
||||
-- Create date: <Create Date, ,>
|
||||
-- Description: <Description, ,>
|
||||
-- =============================================
|
||||
CREATE FUNCTION [dbo].[MinMetricDate]
|
||||
(
|
||||
)
|
||||
RETURNS date
|
||||
AS
|
||||
BEGIN
|
||||
-- Declare the return variable here
|
||||
DECLARE @Result date
|
||||
|
||||
-- Add the T-SQL statements to compute the return value here
|
||||
SELECT @Result = min(Timestamp) from dbo.Metrics WHERE MetricsKey is not null
|
||||
|
||||
-- Return the result of the function
|
||||
RETURN @Result
|
||||
|
||||
END
|
||||
GO
|
||||
/****** Object: Table [dbo].[IndexedFile] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[IndexedFile](
|
||||
[Hash] [bigint] NOT NULL,
|
||||
[Sha256] [binary](32) NOT NULL,
|
||||
[Sha1] [binary](20) NOT NULL,
|
||||
[Md5] [binary](16) NOT NULL,
|
||||
[Crc32] [int] NOT NULL,
|
||||
[Size] [bigint] NOT NULL,
|
||||
CONSTRAINT [PK_IndexedFile] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[Hash] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[Jobs] ******/
|
||||
CREATE TABLE [dbo].[Jobs](
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Priority] [int] NOT NULL,
|
||||
[PrimaryKeyString] [nvarchar](max) NULL,
|
||||
[Started] [datetime] NULL,
|
||||
[Ended] [datetime] NULL,
|
||||
[Created] [datetime] NOT NULL,
|
||||
[Success] [tinyint] NULL,
|
||||
[ResultContent] [nvarchar](max) NULL,
|
||||
[Payload] [nvarchar](max) NULL,
|
||||
[OnSuccess] [nvarchar](max) NULL,
|
||||
[RunBy] [uniqueidentifier] NULL
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
|
||||
|
||||
/****** Object: Table [dbo].[ArchiveContent] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[ArchiveContent](
|
||||
[Parent] [bigint] NOT NULL,
|
||||
[Child] [bigint] NOT NULL,
|
||||
[Path] [nvarchar](max) NULL,
|
||||
[PathHash] AS (CONVERT([binary](32),hashbytes('SHA2_256',[Path]))) PERSISTED NOT NULL
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE STATISTICS [Child_Parent_Stat] ON [dbo].[ArchiveContent]([Child], [Parent])
|
||||
GO
|
||||
CREATE CLUSTERED INDEX [Child_Parent_IDX] ON [dbo].[ArchiveContent]
|
||||
(
|
||||
[Child] ASC,
|
||||
[Parent] ASC
|
||||
)WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY]
|
||||
GO
|
||||
/****** Object: Table [dbo].[AllFilesInArchive] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[AllFilesInArchive](
|
||||
[TopParent] [bigint] NOT NULL,
|
||||
[Child] [bigint] NOT NULL,
|
||||
CONSTRAINT [PK_AllFilesInArchive] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[TopParent] ASC,
|
||||
[Child] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
/****** Object: View [dbo].[AllArchiveContent] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
|
||||
CREATE VIEW [dbo].[AllArchiveContent]
|
||||
WITH SCHEMABINDING
|
||||
AS
|
||||
SELECT af.TopParent, ac.Parent, af.Child, ac.Path, idx.Size
|
||||
FROM
|
||||
dbo.AllFilesInArchive af
|
||||
LEFT JOIN dbo.ArchiveContent ac on af.Child = ac.Child
|
||||
LEFT JOIN dbo.IndexedFile idx on af.Child = idx.Hash
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[NexusFileInfos] Script Date: 4/1/2020 2:41:00 PM ******/
|
||||
CREATE TABLE [dbo].[NexusFileInfos](
|
||||
[Game] [int] NOT NULL,
|
||||
[ModId] [bigint] NOT NULL,
|
||||
[FileId] [bigint] NOT NULL,
|
||||
[LastChecked] [datetime] NOT NULL,
|
||||
[Data] [nvarchar](max) NOT NULL,
|
||||
CONSTRAINT [PK_NexusFileInfos] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[Game] ASC,
|
||||
[ModId] ASC,
|
||||
[FileId] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[NexusModFiles] Script Date: 4/1/2020 2:41:04 PM ******/
|
||||
|
||||
CREATE TABLE [dbo].[NexusModFiles](
|
||||
[Game] [int] NOT NULL,
|
||||
[ModId] [bigint] NOT NULL,
|
||||
[LastChecked] [datetime] NOT NULL,
|
||||
[Data] [nvarchar](max) NOT NULL,
|
||||
CONSTRAINT [PK_NexusModFiles] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[Game] ASC,
|
||||
[ModId] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[NexusModInfos] Script Date: 4/1/2020 2:41:07 PM ******/
|
||||
|
||||
CREATE TABLE [dbo].[NexusModInfos](
|
||||
[Game] [int] NOT NULL,
|
||||
[ModId] [bigint] NOT NULL,
|
||||
[LastChecked] [datetime] NOT NULL,
|
||||
[Data] [nvarchar](max) NOT NULL,
|
||||
CONSTRAINT [PK_NexusModInfos] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[Game] ASC,
|
||||
[ModId] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[ModLists] Script Date: 4/2/2020 3:59:19 PM ******/
|
||||
CREATE TABLE [dbo].[ModLists](
|
||||
[MachineURL] [nvarchar](50) NOT NULL,
|
||||
[Hash] [bigint] NOT NULL,
|
||||
[Metadata] [nvarchar](max) NOT NULL,
|
||||
[Modlist] [nvarchar](max) NOT NULL,
|
||||
CONSTRAINT [PK_ModLists] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[MachineURL] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[ModListArchive] Script Date: 4/11/2020 10:33:20 AM ******/
|
||||
|
||||
CREATE TABLE [dbo].[ModListArchives](
|
||||
[MachineUrl] [nvarchar](50) NOT NULL,
|
||||
[Hash] [bigint] NOT NULL,
|
||||
[PrimaryKeyString] [nvarchar](max) NOT NULL,
|
||||
[Size] [bigint] NOT NULL,
|
||||
[State] [nvarchar](max) NOT NULL,
|
||||
CONSTRAINT [PK_ModListArchive] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[MachineUrl] ASC,
|
||||
[Hash] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[ModListArchiveStatus] Script Date: 4/11/2020 9:44:25 PM ******/
|
||||
|
||||
CREATE TABLE [dbo].[ModListArchiveStatus](
|
||||
[PrimaryKeyStringHash] [binary](32) NOT NULL,
|
||||
[Hash] [bigint] NOT NULL,
|
||||
[PrimaryKeyString] [nvarchar](max) NOT NULL,
|
||||
[IsValid] [tinyint] NOT NULL,
|
||||
CONSTRAINT [PK_ModListArchiveStatus] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[PrimaryKeyStringHash] ASC,
|
||||
[Hash] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[ArchivePatches] Script Date: 4/13/2020 9:39:25 PM ******/
|
||||
CREATE TABLE [dbo].[ArchivePatches](
|
||||
[SrcPrimaryKeyStringHash] [binary](32) NOT NULL,
|
||||
[SrcPrimaryKeyString] [nvarchar](max) NOT NULL,
|
||||
[SrcHash] [bigint] NOT NULL,
|
||||
[DestPrimaryKeyStringHash] [binary](32) NOT NULL,
|
||||
[DestPrimaryKeyString] [nvarchar](max) NOT NULL,
|
||||
[DestHash] [bigint] NOT NULL,
|
||||
[SrcState] [nvarchar](max) NOT NULL,
|
||||
[DestState] [nvarchar](max) NOT NULL,
|
||||
[SrcDownload] [nvarchar](max) NULL,
|
||||
[DestDownload] [nvarchar](max) NULL,
|
||||
[CDNPath] [nvarchar](max) NULL,
|
||||
CONSTRAINT [PK_ArchivePatches] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[SrcPrimaryKeyStringHash] ASC,
|
||||
[SrcHash] ASC,
|
||||
[DestPrimaryKeyStringHash] ASC,
|
||||
[DestHash] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: Table [dbo].[Metrics] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Metrics](
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Timestamp] [datetime] NOT NULL,
|
||||
[Action] [nvarchar](64) NOT NULL,
|
||||
[Subject] [nvarchar](max) NOT NULL,
|
||||
[MetricsKey] [nvarchar](64) NULL,
|
||||
[GroupingSubject] AS (substring([Subject],(0),case when patindex('%[0-9].%',[Subject])=(0) then len([Subject])+(1) else patindex('%[0-9].%',[Subject]) end)),
|
||||
CONSTRAINT [PK_Metrics] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
/****** Uploaded Files [UploadedFiles] *************/
|
||||
|
||||
CREATE TABLE [dbo].[UploadedFiles](
|
||||
[Id] [uniqueidentifier] NOT NULL,
|
||||
[Name] [nvarchar](max) NOT NULL,
|
||||
[Size] [bigint] NOT NULL,
|
||||
[UploadedBy] [nvarchar](40) NOT NULL,
|
||||
[Hash] [bigint] NOT NULL,
|
||||
[UploadDate] [datetime] NOT NULL,
|
||||
[CDNName] [nvarchar](max) NULL,
|
||||
CONSTRAINT [PK_UploadedFiles] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
/****** API Keys [ApiKeys] ********/
|
||||
CREATE TABLE [dbo].[ApiKeys](
|
||||
[APIKey] [nvarchar](260) NOT NULL,
|
||||
[Owner] [nvarchar](40) NOT NULL,
|
||||
CONSTRAINT [PK_ApiKeys] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[APIKey] ASC,
|
||||
[Owner] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
CREATE UNIQUE NONCLUSTERED INDEX [ByAPIKey] ON [dbo].[ApiKeys]
|
||||
(
|
||||
[APIKey] ASC
|
||||
)
|
||||
INCLUDE([Owner]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[DownloadStates] Script Date: 3/31/2020 6:22:47 AM ******/
|
||||
|
||||
CREATE TABLE [dbo].[DownloadStates](
|
||||
[Id] [binary](32) NOT NULL,
|
||||
[Hash] [bigint] NOT NULL,
|
||||
[PrimaryKey] [nvarchar](max) NOT NULL,
|
||||
[IniState] [nvarchar](max) NOT NULL,
|
||||
[JsonState] [nvarchar](max) NOT NULL,
|
||||
CONSTRAINT [PK_DownloadStates] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [ByHash] ON [dbo].[DownloadStates]
|
||||
(
|
||||
[Hash] ASC
|
||||
)
|
||||
INCLUDE([IniState]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
/****** Object: View [dbo].[GameFiles] Script Date: 4/30/2020 4:23:25 PM ******/
|
||||
|
||||
CREATE VIEW [dbo].[GameFiles]
|
||||
WITH SCHEMABINDING
|
||||
AS
|
||||
|
||||
Select
|
||||
Id,
|
||||
CONVERT(NVARCHAR(20), JSON_VALUE(JsonState,'$.GameVersion')) as GameVersion,
|
||||
CONVERT(NVARCHAR(32),JSON_VALUE(JsonState,'$.Game')) as Game,
|
||||
JSON_VALUE(JsonState,'$.GameFile') as Path,
|
||||
Hash as Hash
|
||||
FROM dbo.DownloadStates
|
||||
WHERE PrimaryKey like 'GameFileSourceDownloader+State|%'
|
||||
AND JSON_VALUE(JsonState,'$.GameFile') NOT LIKE '%.xxhash'
|
||||
GO
|
||||
|
||||
CREATE UNIQUE CLUSTERED INDEX [ByGameAndVersion] ON [dbo].[GameFiles]
|
||||
(
|
||||
[Game] ASC,
|
||||
[GameVersion] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
|
||||
|
||||
/****** Object: Index [IX_Child] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
CREATE NONCLUSTERED INDEX [IX_Child] ON [dbo].[AllFilesInArchive]
|
||||
(
|
||||
[Child] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
GO
|
||||
/****** Object: Index [IX_ArchiveContent_Child] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
CREATE NONCLUSTERED INDEX [IX_ArchiveContent_Child] ON [dbo].[ArchiveContent]
|
||||
(
|
||||
[Child] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
GO
|
||||
SET ARITHABORT ON
|
||||
SET CONCAT_NULL_YIELDS_NULL ON
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
SET ANSI_NULLS ON
|
||||
SET ANSI_PADDING ON
|
||||
SET ANSI_WARNINGS ON
|
||||
SET NUMERIC_ROUNDABORT OFF
|
||||
GO
|
||||
/****** Object: Index [PK_ArchiveContent] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
CREATE UNIQUE NONCLUSTERED INDEX [PK_ArchiveContent] ON [dbo].[ArchiveContent]
|
||||
(
|
||||
[Parent] ASC,
|
||||
[PathHash] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
GO
|
||||
SET ANSI_PADDING ON
|
||||
GO
|
||||
/****** Object: Index [IX_IndexedFile_By_SHA256] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
CREATE UNIQUE NONCLUSTERED INDEX [IX_IndexedFile_By_SHA256] ON [dbo].[IndexedFile]
|
||||
(
|
||||
[Sha256] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[MergeAllFilesInArchive] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
-- =============================================
|
||||
-- Author: <Author,,Name>
|
||||
-- Create date: <Create Date,,>
|
||||
-- Description: <Description,,>
|
||||
-- =============================================
|
||||
CREATE PROCEDURE [dbo].[MergeAllFilesInArchive]
|
||||
AS
|
||||
BEGIN
|
||||
-- SET NOCOUNT ON added to prevent extra result sets from
|
||||
-- interfering with SELECT statements.
|
||||
SET NOCOUNT ON;
|
||||
|
||||
MERGE dbo.AllFilesInArchive t USING (
|
||||
SELECT DISTINCT TopParent, unpvt.Child
|
||||
FROM
|
||||
(SELECT a3.Parent AS P3, a2.Parent as P2, a1.Parent P1, a0.Parent P0, a0.Parent as Parent, a0.Child FROM
|
||||
dbo.ArChiveContent a0
|
||||
LEFT JOIN dbo.ArChiveContent a1 ON a0.Parent = a1.Child
|
||||
LEFT JOIN dbo.ArChiveContent a2 ON a1.Parent = a2.Child
|
||||
LEFT JOIN dbo.ArChiveContent a3 ON a2.Parent = a3.Child) p
|
||||
UNPIVOT
|
||||
(TopParent For C IN (p.P3, p.P2, p.P1, p.P0)) as unpvt
|
||||
LEFT JOIN dbo.IndexedFile idf on unpvt.Child = idf.Hash
|
||||
WHERE TopParent is not null) s
|
||||
ON t.TopParent = s.TopParent AND t.Child = s.Child
|
||||
WHEN NOT MATCHED
|
||||
THEN INSERT (TopParent, Child) VALUES (s.TopParent, s.Child);
|
||||
END
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[MergeIndexedFiles] Script Date: 3/28/2020 4:58:59 PM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
-- Description: <Description,,>
|
||||
-- =============================================
|
||||
CREATE PROCEDURE [dbo].[MergeIndexedFiles]
|
||||
-- Add the parameters for the stored procedure here
|
||||
@Files dbo.IndexedFileType READONLY,
|
||||
@Contents dbo.ArchiveContentType READONLY
|
||||
AS
|
||||
BEGIN
|
||||
-- SET NOCOUNT ON added to prevent extra result sets from
|
||||
-- interfering with SELECT statements.
|
||||
SET NOCOUNT ON;
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
MERGE dbo.IndexedFile AS TARGET
|
||||
USING (SELECT DISTINCT * FROM @Files) as SOURCE
|
||||
ON (TARGET.Hash = SOURCE.HASH)
|
||||
WHEN NOT MATCHED BY TARGET
|
||||
THEN INSERT (Hash, Sha256, Sha1, Md5, Crc32, Size)
|
||||
VALUES (Source.Hash, Source.Sha256, Source.Sha1, Source.Md5, Source.Crc32, Source.Size);
|
||||
|
||||
MERGE dbo.ArchiveContent AS TARGET
|
||||
USING (SELECT DISTINCT * FROM @Contents) as SOURCE
|
||||
ON (TARGET.Parent = SOURCE.Parent AND TARGET.PathHash = CAST(HASHBYTES('SHA2_256', SOURCE.Path) as binary(32)))
|
||||
WHEN NOT MATCHED
|
||||
THEN INSERT (Parent, Child, Path)
|
||||
VALUES (Source.Parent, Source.Child, Source.Path);
|
||||
|
||||
MERGE dbo.AllFilesInArchive t USING (
|
||||
SELECT DISTINCT TopParent, unpvt.Child
|
||||
FROM
|
||||
(SELECT a3.Parent AS P3, a2.Parent as P2, a1.Parent P1, a0.Parent P0, a0.Parent as Parent, a0.Child FROM
|
||||
dbo.ArChiveContent a0
|
||||
LEFT JOIN dbo.ArChiveContent a1 ON a0.Parent = a1.Child
|
||||
LEFT JOIN dbo.ArChiveContent a2 ON a1.Parent = a2.Child
|
||||
LEFT JOIN dbo.ArChiveContent a3 ON a2.Parent = a3.Child) p
|
||||
UNPIVOT
|
||||
(TopParent For C IN (p.P3, p.P2, p.P1, p.P0)) as unpvt
|
||||
LEFT JOIN dbo.IndexedFile idf on unpvt.Child = idf.Hash
|
||||
WHERE TopParent is not null
|
||||
AND Child in (SELECT DISTINCT Hash FROM @Files)) s
|
||||
ON t.TopParent = s.TopParent AND t.Child = s.Child
|
||||
WHEN NOT MATCHED
|
||||
THEN INSERT (TopParent, Child) VALUES (s.TopParent, s.Child);
|
||||
|
||||
COMMIT;
|
||||
|
||||
END
|
||||
GO
|
||||
USE [master]
|
||||
GO
|
||||
ALTER DATABASE [wabbajack_prod] SET READ_WRITE
|
||||
GO
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -25,14 +26,29 @@ namespace Wabbajack.BuildServer.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("{Subject}/{Value}")]
|
||||
public async Task<Result> LogMetricAsync(string Subject, string Value)
|
||||
[Route("{subject}/{value}")]
|
||||
public async Task<Result> LogMetricAsync(string subject, string value)
|
||||
{
|
||||
var date = DateTime.UtcNow;
|
||||
await Log(date, Subject, Value, Request.Headers[Consts.MetricsKeyHeader].FirstOrDefault());
|
||||
await Log(date, subject, value, Request.Headers[Consts.MetricsKeyHeader].FirstOrDefault());
|
||||
return new Result { Timestamp = date};
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("report/{subject}")]
|
||||
public async Task<IActionResult> MetricsReport(string subject)
|
||||
{
|
||||
var results = (await _sql.MetricsReport(subject))
|
||||
.GroupBy(m => m.Subject)
|
||||
.Select(g => new MetricResult
|
||||
{
|
||||
SeriesName = g.Key,
|
||||
Labels = g.Select(m => m.Date.ToString(CultureInfo.InvariantCulture)).ToList(),
|
||||
Values = g.Select(m => m.Count).ToList()
|
||||
});
|
||||
return Ok(results.ToList());
|
||||
}
|
||||
|
||||
private async Task Log(DateTime timestamp, string action, string subject, string metricsKey = null)
|
||||
{
|
||||
_logger.Log(LogLevel.Information, $"Log - {timestamp} {action} {subject} {metricsKey}");
|
||||
|
11
Wabbajack.Server/DTOs/AggregateMetric.cs
Normal file
11
Wabbajack.Server/DTOs/AggregateMetric.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace Wabbajack.Server.DTOs
|
||||
{
|
||||
public class AggregateMetric
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public string Subject { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
11
Wabbajack.Server/DTOs/MetricsResult.cs
Normal file
11
Wabbajack.Server/DTOs/MetricsResult.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Wabbajack.Server.DTOs
|
||||
{
|
||||
public class MetricResult
|
||||
{
|
||||
public string SeriesName { get; set; }
|
||||
public List<string> Labels { get; set; }
|
||||
public List<int> Values { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Dapper;
|
||||
using Wabbajack.Server.DTOs;
|
||||
|
||||
@ -11,5 +13,29 @@ namespace Wabbajack.Server.DataLayer
|
||||
await using var conn = await Open();
|
||||
await conn.ExecuteAsync(@"INSERT INTO dbo.Metrics (Timestamp, Action, Subject, MetricsKey) VALUES (@Timestamp, @Action, @Subject, @MetricsKey)", metric);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<AggregateMetric>> MetricsReport(string action)
|
||||
{
|
||||
await using var conn = await Open();
|
||||
return (await conn.QueryAsync<AggregateMetric>(@"
|
||||
SELECT d.Date, d.GroupingSubject as Subject, Count(*) as Count FROM
|
||||
(select DISTINCT CONVERT(date, Timestamp) as Date, GroupingSubject, Action, MetricsKey from dbo.Metrics) m
|
||||
RIGHT OUTER JOIN
|
||||
(SELECT CONVERT(date, DATEADD(DAY, number + 1, dbo.MinMetricDate())) as Date, GroupingSubject, Action
|
||||
FROM master..spt_values
|
||||
CROSS JOIN (
|
||||
SELECT DISTINCT GroupingSubject, Action FROM dbo.Metrics
|
||||
WHERE MetricsKey is not null
|
||||
AND Subject != 'Default'
|
||||
AND TRY_CONVERT(uniqueidentifier, Subject) is null) as keys
|
||||
WHERE type = 'P'
|
||||
AND DATEADD(DAY, number+1, dbo.MinMetricDate()) <= dbo.MaxMetricDate()) as d
|
||||
ON m.Date = d.Date AND m.GroupingSubject = d.GroupingSubject AND m.Action = d.Action
|
||||
WHERE d.Action = @action
|
||||
AND d.Date >= DATEADD(month, -1, GETUTCDATE())
|
||||
group by d.Date, d.GroupingSubject, d.Action
|
||||
ORDER BY d.Date, d.GroupingSubject, d.Action", new {Action = action}))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
44
Wabbajack.Server/Program.cs
Normal file
44
Wabbajack.Server/Program.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Wabbajack.Server
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
bool testMode = args.Contains("TESTMODE");
|
||||
CreateHostBuilder(args, testMode).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args, bool testMode) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>()
|
||||
.UseKestrel(options =>
|
||||
{
|
||||
options.Listen(IPAddress.Any, testMode ? 8080 : 80);
|
||||
if (!testMode)
|
||||
{
|
||||
options.Listen(IPAddress.Any, 443, listenOptions =>
|
||||
{
|
||||
using (var store = new X509Store(StoreName.My))
|
||||
{
|
||||
store.Open(OpenFlags.ReadOnly);
|
||||
var cert = store.Certificates.Find(X509FindType.FindBySubjectName,
|
||||
"build.wabbajack.org", true)[0];
|
||||
listenOptions.UseHttps(cert);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
options.Limits.MaxRequestBodySize = null;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ namespace Wabbajack.Server.Services
|
||||
|
||||
var totalPurged = purgedFiles + purgedMods;
|
||||
if (totalPurged > 0)
|
||||
_logger.Log(LogLevel.Information, $"Purged {totalPurged} cache items");
|
||||
_logger.Log(LogLevel.Information, $"Purged {totalPurged} cache items {result.Game} {result.ModId} {result.TimeStamp}");
|
||||
|
||||
if (await _sql.GetNexusModInfoString(result.Game, result.ModId) != null) continue;
|
||||
|
||||
@ -124,6 +124,8 @@ namespace Wabbajack.Server.Services
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (!_settings.RunBackEndJobs) return;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
while (true)
|
||||
|
38
Wabbajack.Server/Wabbajack.Server.csproj
Normal file
38
Wabbajack.Server/Wabbajack.Server.csproj
Normal file
@ -0,0 +1,38 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CsvHelper" Version="15.0.5" />
|
||||
<PackageReference Include="Dapper" Version="2.0.35" />
|
||||
<PackageReference Include="FluentFTP" Version="32.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
|
||||
<PackageReference Include="Nettle" Version="1.3.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Wabbajack.Common\Wabbajack.Common.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Lib\Wabbajack.Lib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="public\WABBAJACK_TEST_FILE.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="public\metrics.html">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
@ -13,7 +13,7 @@
|
||||
"JobRunner": true,
|
||||
"JobScheduler": false,
|
||||
"RunFrontEndJobs": true,
|
||||
"RunBackEndJobs": true,
|
||||
"RunBackEndJobs": false,
|
||||
"BunnyCDN_User": "wabbajackcdn",
|
||||
"BunnyCDN_Password": "XXXX",
|
||||
"SQLConnection": "Data Source=.\\SQLEXPRESS;Integrated Security=True;Initial Catalog=wabbajack_prod;MultipleActiveResultSets=true"
|
||||
|
102
Wabbajack.Server/public/metrics.html
Normal file
102
Wabbajack.Server/public/metrics.html
Normal file
@ -0,0 +1,102 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Wabbajack Metrics</title>
|
||||
<script
|
||||
src="https://code.jquery.com/jquery-3.5.1.min.js"
|
||||
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-colorschemes"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Finished Install Counts</h2>
|
||||
<canvas id="finished_install_count" width="800" height="600"></canvas>
|
||||
<hr/>
|
||||
|
||||
<h2>Begin Download</h2>
|
||||
<canvas id="begin_download_chart" width="800" height="600"></canvas>
|
||||
<hr/>
|
||||
|
||||
<h2>Begin Install</h2>
|
||||
<canvas id="begin_install_chart" width="800" height="600"></canvas>
|
||||
<hr/>
|
||||
|
||||
<h2>Finished Install</h2>
|
||||
<canvas id="finished_install_chart" width="800" height="600"></canvas>
|
||||
<hr/>
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
var getReport = function(subject, callback) {
|
||||
$.getJSON("/metrics/report/"+subject, callback)
|
||||
}
|
||||
|
||||
var makeChart = function(ele, group) {
|
||||
|
||||
var result_fn = function (data) {
|
||||
var data = _.filter(data, series => _.some(series.values, v => v > 1));
|
||||
var labels = _.uniq(_.flatten(_.map(data, series => series.labels)));
|
||||
var datasets = _.map(data, series => {
|
||||
return {
|
||||
label: series.seriesName,
|
||||
fill: false,
|
||||
data: _.last(series.values, 30)
|
||||
}});
|
||||
var ctx = document.getElementById(ele).getContext('2d');
|
||||
var chart = new Chart(ctx, {
|
||||
// The type of chart we want to create
|
||||
type: 'line',
|
||||
|
||||
// The data for our dataset
|
||||
data: {
|
||||
labels: _.last(labels, 30),
|
||||
datasets: datasets},
|
||||
|
||||
// Configuration options go here
|
||||
options: {}
|
||||
});
|
||||
};
|
||||
getReport(group, result_fn);
|
||||
};
|
||||
|
||||
|
||||
var makePieChart = function(ele, group) {
|
||||
|
||||
var result_fn = function (data) {
|
||||
var data = _.filter(data, series => _.some(series.values, v => v > 2));
|
||||
var labels = _.map(data, series => series.seriesName);
|
||||
var datasets = {data : _.map(data, series => {
|
||||
return _.reduce(series.values, (x, y) => x + y, 0)})};
|
||||
console.log(datasets);
|
||||
console.log(labels);
|
||||
var ctx = document.getElementById(ele).getContext('2d');
|
||||
var chart = new Chart(ctx, {
|
||||
// The type of chart we want to create
|
||||
type: 'pie',
|
||||
|
||||
// The data for our dataset
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [datasets]},
|
||||
|
||||
// Configuration options go here
|
||||
options: {}
|
||||
});
|
||||
};
|
||||
getReport(group, result_fn)
|
||||
};
|
||||
|
||||
makeChart("begin_download_chart", "downloading");
|
||||
makeChart("begin_install_chart", "begin_install");
|
||||
makeChart("finished_install_chart", "finish_install");
|
||||
makePieChart("finished_install_count", "finish_install");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user