mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move version statistics to database.
This commit is contained in:
3
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
3
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -311,6 +311,8 @@
|
||||
<e p="20181221034941_SeenDevicesStatistics.cs" t="Include" />
|
||||
<e p="20181221040408_OperatingSystemStatistics.Designer.cs" t="Include" />
|
||||
<e p="20181221040408_OperatingSystemStatistics.cs" t="Include" />
|
||||
<e p="20181221041242_VersionStatistics.Designer.cs" t="Include" />
|
||||
<e p="20181221041242_VersionStatistics.cs" t="Include" />
|
||||
<e p="DicContextModelSnapshot.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Models" t="Include">
|
||||
@@ -324,6 +326,7 @@
|
||||
<e p="OperatingSystem.cs" t="Include" />
|
||||
<e p="Partition.cs" t="Include" />
|
||||
<e p="Report.cs" t="Include" />
|
||||
<e p="Version.cs" t="Include" />
|
||||
</e>
|
||||
<e p="bin" t="ExcludeRecursive" />
|
||||
<e p="obj" t="ExcludeRecursive">
|
||||
|
||||
@@ -44,7 +44,7 @@ using DiscImageChef.Database.Models;
|
||||
using Device = DiscImageChef.Devices.Device;
|
||||
using MediaType = DiscImageChef.CommonTypes.MediaType;
|
||||
using OperatingSystem = DiscImageChef.Database.Models.OperatingSystem;
|
||||
using Version = DiscImageChef.CommonTypes.Interop.Version;
|
||||
using Version = DiscImageChef.Database.Models.Version;
|
||||
|
||||
namespace DiscImageChef.Core
|
||||
{
|
||||
@@ -82,13 +82,8 @@ namespace DiscImageChef.Core
|
||||
Synchronized = false,
|
||||
Version = DetectOS.GetVersion()
|
||||
});
|
||||
CurrentStats = new Stats
|
||||
{
|
||||
Versions = new List<NameValueStats>
|
||||
{
|
||||
new NameValueStats {name = Version.GetVersion(), Value = 1}
|
||||
}
|
||||
};
|
||||
ctx.Versions.Add(new Version {Value = CommonTypes.Interop.Version.GetVersion(), Synchronized = false});
|
||||
CurrentStats = new Stats();
|
||||
XmlSerializer xs = new XmlSerializer(AllStats.GetType());
|
||||
StreamReader sr = new StreamReader(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"));
|
||||
AllStats = (Stats)xs.Deserialize(sr);
|
||||
@@ -103,13 +98,8 @@ namespace DiscImageChef.Core
|
||||
Synchronized = false,
|
||||
Version = DetectOS.GetVersion()
|
||||
});
|
||||
CurrentStats = new Stats
|
||||
{
|
||||
Versions = new List<NameValueStats>
|
||||
{
|
||||
new NameValueStats {name = Version.GetVersion(), Value = 1}
|
||||
}
|
||||
};
|
||||
ctx.Versions.Add(new Version {Value = CommonTypes.Interop.Version.GetVersion(), Synchronized = false});
|
||||
CurrentStats = new Stats();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -159,7 +149,8 @@ namespace DiscImageChef.Core
|
||||
long count = 0;
|
||||
|
||||
NameValueStats old = null;
|
||||
foreach(NameValueStats nvs in AllStats.Versions.Where(nvs => nvs.name == Version.GetVersion()))
|
||||
foreach(NameValueStats nvs in AllStats.Versions.Where(nvs => nvs.name == CommonTypes
|
||||
.Interop.Version.GetVersion()))
|
||||
{
|
||||
count = nvs.Value + 1;
|
||||
old = nvs;
|
||||
@@ -169,7 +160,10 @@ namespace DiscImageChef.Core
|
||||
if(old != null) AllStats.Versions.Remove(old);
|
||||
|
||||
count++;
|
||||
AllStats.Versions.Add(new NameValueStats {name = Version.GetVersion(), Value = count});
|
||||
AllStats.Versions.Add(new NameValueStats
|
||||
{
|
||||
name = CommonTypes.Interop.Version.GetVersion(), Value = count
|
||||
});
|
||||
}
|
||||
else if(CurrentStats != null) AllStats.Versions = CurrentStats.Versions;
|
||||
|
||||
@@ -228,7 +222,7 @@ namespace DiscImageChef.Core
|
||||
|
||||
WebRequest request = WebRequest.Create("http://discimagechef.claunia.com/api/uploadstats");
|
||||
((HttpWebRequest)request).UserAgent =
|
||||
$"DiscImageChef {typeof(Version).Assembly.GetName().Version}";
|
||||
$"DiscImageChef {typeof(CommonTypes.Interop.Version).Assembly.GetName().Version}";
|
||||
request.Method = "POST";
|
||||
request.ContentLength = fs.Length;
|
||||
request.ContentType = "application/xml";
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace DiscImageChef.Database
|
||||
public DbSet<Media> Medias { get; set; }
|
||||
public DbSet<DeviceStat> SeenDevices { get; set; }
|
||||
public DbSet<OperatingSystem> OperatingSystems { get; set; }
|
||||
public DbSet<Version> Versions { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
|
||||
@@ -72,6 +72,8 @@
|
||||
<Compile Include="Migrations\20181221034941_SeenDevicesStatistics.Designer.cs" />
|
||||
<Compile Include="Migrations\20181221040408_OperatingSystemStatistics.cs" />
|
||||
<Compile Include="Migrations\20181221040408_OperatingSystemStatistics.Designer.cs" />
|
||||
<Compile Include="Migrations\20181221041242_VersionStatistics.cs" />
|
||||
<Compile Include="Migrations\20181221041242_VersionStatistics.Designer.cs" />
|
||||
<Compile Include="Migrations\DicContextModelSnapshot.cs" />
|
||||
<Compile Include="Models\Command.cs" />
|
||||
<Compile Include="Models\Device.cs" />
|
||||
@@ -83,6 +85,7 @@
|
||||
<Compile Include="Models\OperatingSystem.cs" />
|
||||
<Compile Include="Models\Partition.cs" />
|
||||
<Compile Include="Models\Report.cs" />
|
||||
<Compile Include="Models\Version.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DiscImageChef.CommonTypes\DiscImageChef.CommonTypes.csproj" />
|
||||
|
||||
1395
DiscImageChef.Database/Migrations/20181221041242_VersionStatistics.Designer.cs
generated
Normal file
1395
DiscImageChef.Database/Migrations/20181221041242_VersionStatistics.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace DiscImageChef.Database.Migrations
|
||||
{
|
||||
public partial class VersionStatistics : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("Versions",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Value = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
}, constraints: table => { table.PrimaryKey("PK_Versions", x => x.Id); });
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable("Versions");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1046,6 +1046,19 @@ namespace DiscImageChef.Database.Migrations
|
||||
b.ToTable("Reports");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiscImageChef.Database.Models.Version", b =>
|
||||
{
|
||||
b.Property<int>("Id").ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<bool>("Synchronized");
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Versions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiscImageChef.Decoders.SCSI.Modes+ModePage_2A", b =>
|
||||
{
|
||||
b.Property<int>("Id").ValueGeneratedOnAdd();
|
||||
|
||||
12
DiscImageChef.Database/Models/Version.cs
Normal file
12
DiscImageChef.Database/Models/Version.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace DiscImageChef.Database.Models
|
||||
{
|
||||
public class Version
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string Value { get; set; }
|
||||
public bool Synchronized { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user