-
-
Notifications
You must be signed in to change notification settings - Fork 85
Develop #442
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
Develop #442
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| using FluentMigrator; | ||
|
|
||
| namespace Resgrid.Providers.Migrations.Migrations | ||
| { | ||
| /// <summary> | ||
| /// Per-lane work-time (crew fatigue) indicator thresholds: minutes before the lane work light | ||
| /// turns amber/red (0 = disabled; clients fall back to their own defaults). Denormalized onto | ||
| /// runtime nodes from the template role at seeding, like the other lane limits. | ||
| /// </summary> | ||
| [Migration(103)] | ||
| public class M0103_AddLaneWorkTimeThresholds : Migration | ||
| { | ||
| public override void Up() | ||
| { | ||
| if (Schema.Table("CommandStructureNodes").Exists()) | ||
| { | ||
| foreach (var column in new[] { "WorkTimeAmberMinutes", "WorkTimeRedMinutes" }) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WHAT: The column-name string literals are defined inline and will be repeated four times in this file. WHY: Repeating raw string literals for database identifiers risks typos and makes future renames error-prone. HOW: Extract a private static readonly string[] WorkTimeColumns = { "WorkTimeAmberMinutes", "WorkTimeRedMinutes" }; at class level and reference it in every loop. Also found in:
Kody rule violation: Centralize string constants Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
| { | ||
| if (!Schema.Table("CommandStructureNodes").Column(column).Exists()) | ||
| { | ||
| Alter.Table("CommandStructureNodes") | ||
| .AddColumn(column).AsInt32().NotNullable().WithDefaultValue(0); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (Schema.Table("CommandDefinitionRoles").Exists()) | ||
| { | ||
| foreach (var column in new[] { "WorkTimeAmberMinutes", "WorkTimeRedMinutes" }) | ||
| { | ||
| if (!Schema.Table("CommandDefinitionRoles").Column(column).Exists()) | ||
| { | ||
| Alter.Table("CommandDefinitionRoles") | ||
| .AddColumn(column).AsInt32().NotNullable().WithDefaultValue(0); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public override void Down() | ||
| { | ||
| if (Schema.Table("CommandStructureNodes").Exists()) | ||
| { | ||
| foreach (var column in new[] { "WorkTimeAmberMinutes", "WorkTimeRedMinutes" }) | ||
| { | ||
| if (Schema.Table("CommandStructureNodes").Column(column).Exists()) | ||
| Delete.Column(column).FromTable("CommandStructureNodes"); | ||
| } | ||
| } | ||
|
|
||
| if (Schema.Table("CommandDefinitionRoles").Exists()) | ||
| { | ||
| foreach (var column in new[] { "WorkTimeAmberMinutes", "WorkTimeRedMinutes" }) | ||
| { | ||
| if (Schema.Table("CommandDefinitionRoles").Column(column).Exists()) | ||
| Delete.Column(column).FromTable("CommandDefinitionRoles"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| using FluentMigrator; | ||
|
|
||
| namespace Resgrid.Providers.MigrationsPg.Migrations | ||
| { | ||
| /// <summary> | ||
| /// Per-lane work-time (crew fatigue) indicator thresholds: minutes before the lane work light | ||
| /// turns amber/red (0 = disabled; clients fall back to their own defaults). Denormalized onto | ||
| /// runtime nodes from the template role at seeding, like the other lane limits. | ||
| /// </summary> | ||
| [Migration(103)] | ||
| public class M0103_AddLaneWorkTimeThresholdsPg : Migration | ||
| { | ||
| public override void Up() | ||
| { | ||
| if (Schema.Table("commandstructurenodes").Exists()) | ||
| { | ||
| foreach (var column in new[] { "worktimeamberminutes", "worktimeredminutes" }) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WHAT: The column-name array literal new[] { "worktimeamberminutes", "worktimeredminutes" } is repeated on lines 17, 29, 44, and 53. WHY: Duplicated literals risk divergence if a column name is renamed or added. HOW: Declare a private static readonly string[] WorkTimeColumns at class level and reference it in all four loops; additionally, factor the repeated Alter/Table-check and Delete/Table-check blocks into helper methods. Also found in:
Kody rule violation: Extract duplicated logic into functions Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
| { | ||
| if (!Schema.Table("commandstructurenodes").Column(column).Exists()) | ||
| { | ||
| Alter.Table("commandstructurenodes") | ||
| .AddColumn(column).AsInt32().NotNullable().WithDefaultValue(0); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (Schema.Table("commanddefinitionroles").Exists()) | ||
| { | ||
| foreach (var column in new[] { "worktimeamberminutes", "worktimeredminutes" }) | ||
| { | ||
| if (!Schema.Table("commanddefinitionroles").Column(column).Exists()) | ||
| { | ||
| Alter.Table("commanddefinitionroles") | ||
| .AddColumn(column).AsInt32().NotNullable().WithDefaultValue(0); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public override void Down() | ||
| { | ||
| if (Schema.Table("commandstructurenodes").Exists()) | ||
| { | ||
| foreach (var column in new[] { "worktimeamberminutes", "worktimeredminutes" }) | ||
| { | ||
| if (Schema.Table("commandstructurenodes").Column(column).Exists()) | ||
| Delete.Column(column).FromTable("commandstructurenodes"); | ||
| } | ||
| } | ||
|
|
||
| if (Schema.Table("commanddefinitionroles").Exists()) | ||
| { | ||
| foreach (var column in new[] { "worktimeamberminutes", "worktimeredminutes" }) | ||
| { | ||
| if (Schema.Table("commanddefinitionroles").Column(column).Exists()) | ||
| Delete.Column(column).FromTable("commanddefinitionroles"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,8 @@ public class CommandRoleResultData | |
| public int MaxUnits { get; set; } | ||
| public int MinTimeInRole { get; set; } | ||
| public int MaxTimeInRole { get; set; } | ||
| public int WorkTimeAmberMinutes { get; set; } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WHAT: The new int property Also found in:
Kody rule violation: Initialize properties with default values Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
| public int WorkTimeRedMinutes { get; set; } | ||
|
|
||
| /// <summary>Lane identification color (hex, e.g. "#e74c3c"); null = default styling.</summary> | ||
| public string Color { get; set; } | ||
|
|
@@ -110,6 +112,8 @@ public class SaveCommandLaneInput | |
| public int MaxUnits { get; set; } | ||
| public int MinTimeInRole { get; set; } | ||
| public int MaxTimeInRole { get; set; } | ||
| public int WorkTimeAmberMinutes { get; set; } | ||
| public int WorkTimeRedMinutes { get; set; } | ||
|
Comment on lines
+115
to
+116
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Preserve omitted thresholds during updates. Because these request fields are non-nullable, callers that omit the new JSON properties receive 🤖 Prompt for AI Agents |
||
|
|
||
| /// <summary>Lane identification color (hex, e.g. "#e74c3c"); null = default styling.</summary> | ||
| public string Color { get; set; } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uninitialized property WorkTimeAmberMinutes in CommandModels.cs lacks an explicit default initializer, leaving the object in an ambiguous state per Rule [32]. Add an explicit initializer such as = 0 or set it in the constructor.
Kody rule violation: Replace magic numbers with named constants
Prompt for LLM
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.