forked from mazarskov/ScreenTime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsageAnalyzer.cs
More file actions
28 lines (23 loc) · 746 Bytes
/
Copy pathUsageAnalyzer.cs
File metadata and controls
28 lines (23 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static ScreenTime.DatabaseHelper;
namespace ScreenTime
{
public class UsageAnalyzer
{
public Dictionary<string, int> CalculateAppUsageSeconds(List<AppUsageData> dataFromSpecificDay)
{
// Group by AppName and calculate total seconds used for each app
var appUsageSeconds = dataFromSpecificDay
.GroupBy(data => data.AppName)
.ToDictionary(
group => group.Key,
group => group.Sum(data => (int)(data.EndTime - data.StartTime))
);
return appUsageSeconds;
}
}
}