-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from EspadaKomanda/AnalyticService
Analytic service
- Loading branch information
Showing
176 changed files
with
6,782 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"dotnet.defaultSolution": "AnalyticService.sln" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"Newtonsoft" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
41
AnalyticService/AnalyticService/Database/ApplicationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
27
AnalyticService/AnalyticService/Database/IApplicationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
AnalyticService/AnalyticService/Database/Models/Attendance/Event.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
AnalyticService/AnalyticService/Database/Models/Attendance/UserEventAttendance.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
AnalyticService/AnalyticService/Database/Models/Tests/CourseTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
31
AnalyticService/AnalyticService/Database/Models/Tests/Question.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
AnalyticService/AnalyticService/Database/Models/Tests/Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
AnalyticService/AnalyticService/Database/Models/Tests/UserTestAttempt.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
AnalyticService/AnalyticService/Database/Models/Tests/UserTestAttemptAnswer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
AnalyticService/AnalyticService/Kafka/Attributes/KafkaMethodAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
AnalyticService/AnalyticService/Kafka/Attributes/KafkaServiceNameAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ce/AnalyticService/Kafka/Exceptions/ConfigurationException/ConfigureConsumersException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {} | ||
} | ||
} |
Oops, something went wrong.