Skip to content

Commit

Permalink
Centralise to cache is only updated in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
IsakNaslundBh committed Feb 14, 2025
1 parent dd64984 commit 7a4af15
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions UI_Engine/Compute/LogUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,30 @@ public static void LogUsage(string uiName, string uiVersion, Guid componentId, s
}
}
else
m_ProjectIDPerFile[fileId] = projectId;
UpdateProjectId(uiName, fileId, projectId);

LogToFile(uiName, uiVersion, componentId, callerName, selectedItem, events, fileId, fileName, projectId);
}

/*************************************/

public static void UpdateProjectId(string uiName, string fileId, string projectID)
public static void UpdateProjectId(string uiName, string fileId, string projectId)

Check warning on line 93 in UI_Engine/Compute/LogUsage.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

UI_Engine/Compute/LogUsage.cs#L93

Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent
{
if (string.IsNullOrWhiteSpace(uiName) || string.IsNullOrWhiteSpace(fileId))
return;

bool wasUpdated = true;
lock (m_LogLock)
{
m_ProjectIDPerFile[fileId] = projectID;
string prevPojectId;
if (m_ProjectIDPerFile.TryGetValue(fileId, out prevPojectId) && projectId == prevPojectId) //Check if the ID changed from previous cached value
wasUpdated = false;

m_ProjectIDPerFile[fileId] = projectId; //Set the project Id to the cached dictionary
}
Task.Run(() => UpdateProjectIdsInLogFile(uiName, fileId, projectID));

if(wasUpdated) //If changed from previous value, make sure the logfiles are updated
Task.Run(() => UpdateProjectIdsInLogFile(uiName, fileId, projectId));
}

/*************************************/
Expand Down

0 comments on commit 7a4af15

Please sign in to comment.