Skip to content

Commit

Permalink
Merge pull request #4 from EspadaKomanda/AnalyticService
Browse files Browse the repository at this point in the history
Analytic service
  • Loading branch information
Er3shk1gal authored Nov 27, 2024
2 parents 8e2f551 + f39b1c7 commit d541e61
Show file tree
Hide file tree
Showing 176 changed files with 6,782 additions and 0 deletions.
3 changes: 3 additions & 0 deletions AnalyticService/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotnet.defaultSolution": "AnalyticService.sln"
}
22 changes: 22 additions & 0 deletions AnalyticService/AnalyticService.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnalyticService", "AnalyticService\AnalyticService.csproj", "{E77EF670-69B3-438B-9387-D709E9210D7D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E77EF670-69B3-438B-9387-D709E9210D7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E77EF670-69B3-438B-9387-D709E9210D7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E77EF670-69B3-438B-9387-D709E9210D7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E77EF670-69B3-438B-9387-D709E9210D7D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
5 changes: 5 additions & 0 deletions AnalyticService/AnalyticService/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"Newtonsoft"
]
}
19 changes: 19 additions & 0 deletions AnalyticService/AnalyticService/AnalyticService.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.67.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Confluent.Kafka" Version="2.4.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Proto/analytic.proto" />
</ItemGroup>
</Project>
25 changes: 25 additions & 0 deletions AnalyticService/AnalyticService/AnalyticService.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnalyticService", "AnalyticService.csproj", "{217D03FD-F8C5-4F30-BA5C-CD6C685DBC23}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{217D03FD-F8C5-4F30-BA5C-CD6C685DBC23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{217D03FD-F8C5-4F30-BA5C-CD6C685DBC23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{217D03FD-F8C5-4F30-BA5C-CD6C685DBC23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{217D03FD-F8C5-4F30-BA5C-CD6C685DBC23}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DAAF9384-2BCD-4D88-9E75-9B1F59E133FF}
EndGlobalSection
EndGlobal
41 changes: 41 additions & 0 deletions AnalyticService/AnalyticService/Database/ApplicationContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AnalyticService.Database.Models;
using AnalyticService.Database.Models.Attendance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;

namespace AnalyticService.Database
{
public class ApplicationContext : DbContext , IApplicationContext
{
public DbSet<Event> Events { get; set; }
public DbSet<UserEventAttendance> UserEventAttendances { get; set; }
public DbSet<CourseTest> CourseTests { get; set;}
public DbSet<Question> Questions { get; set; }
public DbSet<Test> Tests { get; set; }
public DbSet<UserTestAttempt> UserTestAttempts { get; set; }
public DbSet<UserTestAttemptAnswer> UserTestAttemptAnswers { get; set; }

public ApplicationContext(DbContextOptions<ApplicationContext> options) : base(options)
{
Database.EnsureCreated();
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseLazyLoadingProxies();
}
public async Task<IDbContextTransaction> BeginTransactionAsync(CancellationToken cancellationToken = default)
{
return await Database.BeginTransactionAsync(cancellationToken);
}
public async Task<int> SaveChangesAsync()
{
return await base.SaveChangesAsync();
}
}

}
27 changes: 27 additions & 0 deletions AnalyticService/AnalyticService/Database/IApplicationContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AnalyticService.Database.Models;
using AnalyticService.Database.Models.Attendance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Storage;

namespace AnalyticService.Database
{
public interface IApplicationContext
{
public DbSet<Event> Events { get; set; }
public DbSet<UserEventAttendance> UserEventAttendances { get; set; }
public DbSet<CourseTest> CourseTests { get; set;}
public DbSet<Question> Questions { get; set; }
public DbSet<Test> Tests { get; set; }
public DbSet<UserTestAttempt> UserTestAttempts { get; set; }
public DbSet<UserTestAttemptAnswer> UserTestAttemptAnswers { get; set; }
Task<int> SaveChangesAsync();
EntityEntry Entry(object entity);

Task<IDbContextTransaction> BeginTransactionAsync(CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace AnalyticService.Database.Models.Attendance
{
public class Event
{
[Key]
public long Id { get; set; }
public long StudyGroupId { get; set; }
public string Name { get; set; } = "";
public TimeSpan Duration { get; set; }
public DateTime Date { get; set; }
public DayOfWeek DayOfWeek { get; set; }
public bool IsWeekEven { get; set; }
public DateTime BeginDate { get; set; }
public DateTime EndDate { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace AnalyticService.Database.Models.Attendance
{
public class UserEventAttendance
{
[Key]
public long Id { get; set; }
public long UserId { get; set; }
public long EventId { get; set; }
[ForeignKey("EventId")]
public Event Event { get; set; } = null!;
public bool Status { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace AnalyticService.Database.Models
{
public class CourseTest
{
[Key]
public long Id { get; set; }
public long CourseId { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public long TestId { get; set; }
[ForeignKey("TestId")]
public Test Test { get; set; } = null!;
public int Attempts { get; set; }
public TimeSpan Time { get; set; }
public double MinScore { get; set; }
public double MaxScore { get; set; }
}
}
31 changes: 31 additions & 0 deletions AnalyticService/AnalyticService/Database/Models/Tests/Question.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace AnalyticService.Database.Models
{
public class Question
{
[Key]
public long Id { get; set; }
public long TestId { get; set; }

[ForeignKey("TestId")]
public Test Test{ get; set; } = null!;
public string Title { get; set; } = "";
public string Content { get; set; } = "";
public QuestionType QuestionType { get; set; }
}
public enum QuestionType
{
TEXT,
CHECKBOX,
CHECKBOXES,
CODE,
URL,
FILE
}
}
19 changes: 19 additions & 0 deletions AnalyticService/AnalyticService/Database/Models/Tests/Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace AnalyticService.Database.Models
{
public class Test
{
[Key]
public long Id { get; set; }
public int Attempts { get; set; } = 1;
public string Name { get; set; } = null!;
public TimeSpan Time { get; set; }
public double MinScore { get; set; }
public double MaxScore { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace AnalyticService.Database.Models
{
public class UserTestAttempt
{
[Key]
public long Id { get; set; }
public long UserId { get; set; }
public int AttemptNumber { get; set; }
public double Score { get; set; }
public DateTime Date { get; set; }
public bool Passed { get; set; }
public long CourseTestId { get; set; }
[ForeignKey("CourseTestId")]
public CourseTest CourseTest { get; set; } = null!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace AnalyticService.Database.Models
{
public class UserTestAttemptAnswer
{
[Key]
public long Id { get; set; }
public long UserTestAttemptId { get; set; }
[ForeignKey("UserTestAttemptId")]
public UserTestAttempt UserTestAttempt { get; set; } = null!;
public long QuestionId { get; set; }
public string Content { get; set; } = "";
public bool IsCorrect { get; set; }
public Status Status { get; set; }
public DateTime StatusModifiedAt { get; set; }
}
public enum Status
{
ON_VERIFICATION,
CORRECT,
WRONG
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace KafkaAttributesLib.Attributes
{
[AttributeUsage(AttributeTargets.Method)]
public class KafkaMethodAttribute : Attribute
{
public string MethodName { get; }

public KafkaMethodAttribute(string methodName)
{
MethodName = methodName;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace KafkaAttributesLib.Attributes
{
[AttributeUsage(AttributeTargets.Class)]
public class KafkaServiceNameAttribute : Attribute
{
public string ServiceName { get; }

public KafkaServiceNameAttribute(string serviceName)
{
ServiceName = serviceName;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace KafkaAttributesLib.Exceptions.ProducerExceptions
{
public class ConfigureConsumersException : MyKafkaException
{
public ConfigureConsumersException() {}
public ConfigureConsumersException(string message) : base(message) {}
public ConfigureConsumersException(string message, System.Exception inner) : base(message, inner) {}
}
}
Loading

0 comments on commit d541e61

Please sign in to comment.