Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Forecast DB model #575

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/Core/Consultants/Consultant.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;
using Core.Engagements;
using Core.Forecasts;
using Core.Organizations;
using Core.PlannedAbsences;
using Core.Staffings;
Expand Down Expand Up @@ -34,6 +35,8 @@ public class Consultant

public List<Staffing> Staffings { get; set; } = new();

public List<Forecast> Forecasts { get; set; } = new();


public int YearsOfExperience
{
Expand Down
18 changes: 18 additions & 0 deletions backend/Core/Forecasts/Forecast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations.Schema;
using Core.Consultants;

namespace Core.Forecasts;

public class Forecast
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }

public required int ConsultantId { get; set; }
public required Consultant Consultant { get; set; }
astride marked this conversation as resolved.
Show resolved Hide resolved

public DateOnly MonthYear { get; set; }
astride marked this conversation as resolved.
Show resolved Hide resolved

public int OriginalValue { get; set; }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need to save the original value? This value will be retrieved and calculated based on information from the staffing table (and other tables?) on every single page load regardless. Or am I overlooking something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That depends if we want to actually recalculate every single time or if we want to pre-calculate it and save and then regenerate periodically or whenever the staffing table updates.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I do believe Odd Morten said (before you joined) that everytime someone opens the Prognose page, he wants real-time data to be pulled. @idamand @MariaBonde Am I remembering that correctly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that is correct @astride!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think he said that prognose should be updated every time bemanning gets updated? Sidenote, I was thinking about how it will work if there is an adjusted value, and then bemanning gets updated with a new value, but in that case, Odd Morten said to just save the higher number I think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MariaBonde I think you are right, but also: If a change is made in Bemanning after you have opened the Prognose page, you will only see those changes on the Prognose page if you manually refresh the Prognose page or you re-enter it. Does that sound right?

The Bemanning page also seems to work that way; if someone else changes something in Bemanning while you have the Bemanning page open, those changes will be reflected on your screen only after a manual refresh.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MariaBonde I agree on the sidenote!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think that sounds reasonable, especially if bemanning works that way

public int? AdjustedValue { get; set; }
}
7 changes: 7 additions & 0 deletions backend/Infrastructure/DatabaseContext/ApplicationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Core.Consultants;
using Core.Customers;
using Core.Engagements;
using Core.Forecasts;
using Core.Organizations;
using Core.PlannedAbsences;
using Core.Staffings;
Expand All @@ -27,6 +28,7 @@ public class ApplicationContext(DbContextOptions options) : DbContext(options)
public DbSet<Engagement> Project { get; init; } = null!;
public DbSet<Staffing> Staffing { get; init; } = null!;
public DbSet<Agreement> Agreements { get; init; } = null!;
public DbSet<Forecast> Forecasts { get; init; } = null!;


protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
Expand Down Expand Up @@ -202,6 +204,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
GraduationYear = 2019
});

modelBuilder.Entity<Forecast>()
.HasOne<Consultant>(f => f.Consultant)
.WithMany(c => c.Forecasts)
.HasForeignKey(f => f.ConsultantId);

base.OnModelCreating(modelBuilder);
}
}
Loading
Loading