Skip to content

Commit 54d7b19

Browse files
committed
Preventing the code from first setting planHours to 0 and then parsing the planText and setting it back to some value and keep doing that for hours on end for no reason.
Also setting the CreatedByUserId and UpdatedByUserId to 0, since that is the System Id and no user.
1 parent 6fc351a commit 54d7b19

File tree

1 file changed

+15
-32
lines changed

1 file changed

+15
-32
lines changed

ServiceTimePlanningPlugin/Scheduler/Jobs/SearchListJob.cs

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ public async Task Execute()
221221
PlanText = planText,
222222
PlanHours = parsedPlanHours,
223223
SdkSitId = (int)site.MicrotingUid!,
224-
CreatedByUserId = 1,
225-
UpdatedByUserId = 1,
224+
CreatedByUserId = 0,
225+
UpdatedByUserId = 0,
226226
NettoHours = 0,
227227
PaiedOutFlex = 0,
228228
Pause1Id = 0,
@@ -263,40 +263,23 @@ public async Task Execute()
263263
}
264264

265265
planRegistration.PlanText = planText;
266-
// print to console if the current PlanHours is different from the one in the database
267-
if (planRegistration.PlanHours != parsedPlanHours)
268-
{
269-
Console.WriteLine(
270-
$"warn: PlanHours for site: {site.Name} and date: {dateValue} has changed from {planRegistration.PlanHours} to {parsedPlanHours}");
271-
}
272266

273-
if (!planRegistration.PlanChangedByAdmin)
267+
if (string.IsNullOrEmpty(planRegistration.PlanText))
274268
{
275-
planRegistration.PlanHours = parsedPlanHours;
269+
// print to console if the current PlanHours is different from the one in the database
270+
if (planRegistration.PlanHours != parsedPlanHours)
271+
{
272+
Console.WriteLine(
273+
$"warn: PlanHours for site: {site.Name} and date: {dateValue} has changed from {planRegistration.PlanHours} to {parsedPlanHours}");
274+
}
275+
276+
if (!planRegistration.PlanChangedByAdmin)
277+
{
278+
planRegistration.PlanHours = parsedPlanHours;
279+
}
276280
}
277281

278-
planRegistration.UpdatedByUserId = 1;
279-
280-
// Commented out flex calculations to let UpdatePlanRegistration handle it
281-
// if (preTimePlanning != null)
282-
// {
283-
// planRegistration.SumFlexStart = preTimePlanning.SumFlexEnd;
284-
// planRegistration.SumFlexEnd =
285-
// preTimePlanning.SumFlexEnd + planRegistration.PlanHours -
286-
// planRegistration.NettoHours -
287-
// planRegistration.PaiedOutFlex;
288-
// planRegistration.Flex =
289-
// planRegistration.NettoHours - planRegistration.PlanHours;
290-
// }
291-
// else
292-
// {
293-
// planRegistration.SumFlexEnd =
294-
// planRegistration.PlanHours - planRegistration.NettoHours -
295-
// planRegistration.PaiedOutFlex;
296-
// planRegistration.SumFlexStart = 0;
297-
// planRegistration.Flex =
298-
// planRegistration.NettoHours - planRegistration.PlanHours;
299-
// }
282+
planRegistration.UpdatedByUserId = 0;
300283

301284
await planRegistration.Update(dbContext);
302285
}

0 commit comments

Comments
 (0)