Skip to content

Commit

Permalink
Only return borehole count
Browse files Browse the repository at this point in the history
  • Loading branch information
tschumpr committed Aug 7, 2024
1 parent 8179d8a commit 1f9124d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
8 changes: 0 additions & 8 deletions src/api/Controllers/WorkgroupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ public async Task<IEnumerable<Workgroup>> GetAll()
.ToListAsync()
.ConfigureAwait(false);

foreach (var workgroup in workgroups)
{
if (workgroup.Boreholes != null)
{
workgroup.Boreholes = workgroup.Boreholes.Select(b => new Borehole() { Id = b.Id }).ToList();
}
}

return workgroups;
}

Expand Down
2 changes: 2 additions & 0 deletions src/api/Models/Workgroup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace BDMS.Models;

Expand Down Expand Up @@ -52,6 +53,7 @@ public class Workgroup : IIdentifyable
/// <summary>
/// Gets the boreholes for the workgroup.
/// </summary>
[JsonIgnore]
public ICollection<Borehole>? Boreholes { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/client/src/api/apiInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface Workgroup {
createdAt?: Date | string;
settings?: string;
isSupplier?: boolean;
boreholesCount: number;
boreholeCount: number;
}

export interface WorkgroupRole {
Expand Down
6 changes: 3 additions & 3 deletions src/client/src/pages/settings/admin/adminSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ class AdminSettings extends React.Component {
/>
</p>
</Modal.Description>
) : this.state.deleteWorkgroup.boreholesCount === 0 ? (
) : this.state.deleteWorkgroup.boreholeCount === 0 ? (
<Modal.Description>
<p>
<TranslationText id="msgDeleteWorkgroup" />
Expand Down Expand Up @@ -906,7 +906,7 @@ class AdminSettings extends React.Component {
)}
{this.state.deleteWorkgroup !== null &&
this.state.deleteWorkgroup.disabled === null &&
this.state.deleteWorkgroup.boreholesCount === 0 ? (
this.state.deleteWorkgroup.boreholeCount === 0 ? (
<Button
color="red"
onClick={() => {
Expand Down Expand Up @@ -999,7 +999,7 @@ class AdminSettings extends React.Component {
{workgroup.name}{" "}
{workgroup.supplier === true ? <span style={{ color: "red" }}>(supplier)</span> : ""}
</Table.Cell>
<Table.Cell>{workgroup.boreholesCount}</Table.Cell>
<Table.Cell>{workgroup.boreholeCount}</Table.Cell>
<Table.Cell
style={{
paddingTop: "20px",
Expand Down
4 changes: 2 additions & 2 deletions tests/Controllers/WorkgroupControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task EditWorkgroup()
var workgroupToEdit = await context.WorkgroupsWithIncludes.AsNoTracking().SingleOrDefaultAsync(u => u.Id == createdWorkgroup.Id);
Assert.AreEqual("New Workgroup", workgroupToEdit.Name);
Assert.IsFalse(workgroupToEdit.IsDisabled);
Assert.AreEqual(1, workgroupToEdit.Boreholes.Count);
Assert.AreEqual(1, workgroupToEdit.BoreholeCount);

workgroupToEdit.Name = "Updated Workgroup";
workgroupToEdit.DisabledAt = DateTime.UtcNow;
Expand All @@ -74,7 +74,7 @@ public async Task EditWorkgroup()
Assert.AreEqual("Updated Workgroup", updatedWorkgroup.Name);
Assert.IsTrue(updatedWorkgroup.IsDisabled);
Assert.IsFalse(updatedWorkgroup.IsSupplier);
Assert.AreEqual(1, updatedWorkgroup.Boreholes.Count);
Assert.AreEqual(1, updatedWorkgroup.BoreholeCount);
}

[TestMethod]
Expand Down

0 comments on commit 1f9124d

Please sign in to comment.