diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/api/api/Data/UserStoreDatabaseSettings.cs | 1 | ||||
-rw-r--r-- | backend/api/api/Interfaces/IUserStoreDatabaseSettings.cs | 1 | ||||
-rw-r--r-- | backend/api/api/Models/Experiment.cs | 19 | ||||
-rw-r--r-- | backend/api/api/Program.cs | 1 | ||||
-rw-r--r-- | backend/api/api/Services/ExperimentService.cs | 22 | ||||
-rw-r--r-- | backend/api/api/Services/IExperimentService.cs | 9 | ||||
-rw-r--r-- | backend/api/api/appsettings.json | 25 |
7 files changed, 66 insertions, 12 deletions
diff --git a/backend/api/api/Data/UserStoreDatabaseSettings.cs b/backend/api/api/Data/UserStoreDatabaseSettings.cs index e83d2b54..822f9bf5 100644 --- a/backend/api/api/Data/UserStoreDatabaseSettings.cs +++ b/backend/api/api/Data/UserStoreDatabaseSettings.cs @@ -13,5 +13,6 @@ namespace api.Data public string PredictorCollectionName { get; set; } = String.Empty; public string ModelCollectionName { get; set; } = String.Empty; public string FilesCollectionName { get; set; } = String.Empty; + public string ExperimentCollectionName { get; set; } = String.Empty; } } diff --git a/backend/api/api/Interfaces/IUserStoreDatabaseSettings.cs b/backend/api/api/Interfaces/IUserStoreDatabaseSettings.cs index a5b5f5eb..05c41701 100644 --- a/backend/api/api/Interfaces/IUserStoreDatabaseSettings.cs +++ b/backend/api/api/Interfaces/IUserStoreDatabaseSettings.cs @@ -9,5 +9,6 @@ string PredictorCollectionName { get; set; } string ModelCollectionName { get; set; } string FilesCollectionName { get; set; } + string ExperimentCollectionName { get; set; } } } diff --git a/backend/api/api/Models/Experiment.cs b/backend/api/api/Models/Experiment.cs new file mode 100644 index 00000000..3b435d3f --- /dev/null +++ b/backend/api/api/Models/Experiment.cs @@ -0,0 +1,19 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; + +namespace api.Models +{ + public class Experiment + { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public string _id { get; set; } + + public string datasetId { get; set; } + public string[] inputColumns { get; set; } + public string outputColumn { get; set; } + public string nullValues { get; set; } + public NullValues[] nullValuesReplacers { get; set; } + + } +} diff --git a/backend/api/api/Program.cs b/backend/api/api/Program.cs index 2bb97e45..7d5d0c45 100644 --- a/backend/api/api/Program.cs +++ b/backend/api/api/Program.cs @@ -34,6 +34,7 @@ builder.Services.AddScoped<IModelService, ModelService>(); builder.Services.AddScoped<IPredictorService, PredictorService>(); builder.Services.AddScoped<IFileService, FileService>(); builder.Services.AddScoped<IJwtToken, JwtToken>(); +builder.Services.AddScoped<IExperimentService, ExperimentService>(); var mlwss = new MLWebSocketService(); diff --git a/backend/api/api/Services/ExperimentService.cs b/backend/api/api/Services/ExperimentService.cs new file mode 100644 index 00000000..a3b28da4 --- /dev/null +++ b/backend/api/api/Services/ExperimentService.cs @@ -0,0 +1,22 @@ +using api.Interfaces; +using api.Models; +using MongoDB.Driver; + +namespace api.Services +{ + public class ExperimentService : IExperimentService + { + private readonly IMongoCollection<Experiment> _experiment; + public ExperimentService(IUserStoreDatabaseSettings settings, IMongoClient mongoClient) + { + var database = mongoClient.GetDatabase(settings.DatabaseName); + _experiment = database.GetCollection<Experiment>(settings.ExperimentCollectionName); + } + + public Experiment Create(Experiment experiment) + { + _experiment.InsertOne(experiment); + return experiment; + } + } +} diff --git a/backend/api/api/Services/IExperimentService.cs b/backend/api/api/Services/IExperimentService.cs new file mode 100644 index 00000000..7c80599a --- /dev/null +++ b/backend/api/api/Services/IExperimentService.cs @@ -0,0 +1,9 @@ +using api.Models; + +namespace api.Services +{ + public interface IExperimentService + { + Experiment Create(Experiment experiment); + } +}
\ No newline at end of file diff --git a/backend/api/api/appsettings.json b/backend/api/api/appsettings.json index fdccfb07..f8923a10 100644 --- a/backend/api/api/appsettings.json +++ b/backend/api/api/appsettings.json @@ -9,17 +9,18 @@ } }, "AllowedHosts": "*", - "UserStoreDatabaseSettings": { - /* LocalHost - */ - "ConnectionString": "mongodb://127.0.0.1:27017/", - "DatabaseName": "si_project", - "CollectionName": "users", - "DatasetCollectionName": "Dataset", - "ModelCollectionName": "Model", - "PredictorCollectionName": "Predictor", - "FilesCollectionName": "Files" - /* + "UserStoreDatabaseSettings": { + /* LocalHost + */ + "ConnectionString": "mongodb://127.0.0.1:27017/", + "DatabaseName": "si_project", + "CollectionName": "users", + "DatasetCollectionName": "Dataset", + "ModelCollectionName": "Model", + "PredictorCollectionName": "Predictor", + "FilesCollectionName": "Files", + "ExperimentCollectionName": "Experiment" + /* "ConnectionString": "mongodb+srv://si_user:si_user@sidatabase.twtfm.mongodb.net/myFirstDatabase?retryWrites=true&w=majority", "DatabaseName": "si_db", "CollectionName": "users", @@ -27,5 +28,5 @@ "ModelCollectionName": "Model", "PredictorCollectionName": "Predictor", "FilesCollectionName": "Files"*/ - } + } }
\ No newline at end of file |