Skip to content

Commit

Permalink
fix cache
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Mar 16, 2023
1 parent 5db10c4 commit 1c82f8d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Source/Utils/Rooms/Search/SearchRoomUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ public static class SearchRoomUtil
{
hourStop = hourStop?.AddMinutes(-1);

var polimidailysituation = "polimidailysituation://" + sede + "/" + hourStart?.ToString("yyyy-MM-dd");
var q = Database.Database.ExecuteSelect("SELECT * FROM WebCache WHERE url LIKE @url", GlobalVariables.DbConfigVar, new Dictionary<string, object?>
{
{"@url", "polimidailysituation://" + hourStart?.ToString("yyyy-MM-dd")}
{"@url", polimidailysituation}
}
);

Expand All @@ -25,8 +26,9 @@ public static class SearchRoomUtil
JArray jArray = new JArray();
if (sq != null) jArray = JArray.Parse(sq);
List<Task> tasks = new List<Task>();
foreach (JObject roomobj in jArray)
foreach (var jToken in jArray)
{
var roomobj = (JObject)jToken;
tasks.Add(Task.Run(() =>
{
roomobj["occupancy_rate"] = RoomOccupancyReport.GetReportedOccupancyJObject((uint)(roomobj["room_id"] ?? 1))?["occupancy_rate"];
Expand Down Expand Up @@ -74,7 +76,7 @@ public static class SearchRoomUtil

Database.Database.Execute("INSERT INTO WebCache (url, content, expires_at) VALUES (@url, @content, NOW() + INTERVAL 2 DAYS)", GlobalVariables.DbConfigVar, new Dictionary<string, object?>
{
{"@url", "polimidailysituation://" + hourStart?.ToString("yyyy-MM-dd")},
{"@url", polimidailysituation},
{"@content", results.ToString()}
}
);
Expand Down

0 comments on commit 1c82f8d

Please sign in to comment.