Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit c8d6db5

Browse files
Grouping data records by GitHub for Unity version and Unity version
1 parent 481a56e commit c8d6db5

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/GitHub.Api/Metrics/UsageModel.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ class UsageModel
3232

3333
private Usage currentUsage;
3434

35-
public Usage GetCurrentUsage()
35+
public Usage GetCurrentUsage(string appVersion, string unityVersion)
3636
{
37+
Guard.ArgumentNotNullOrWhiteSpace(appVersion, "appVersion");
38+
Guard.ArgumentNotNullOrWhiteSpace(unityVersion, "unityVersion");
39+
3740
var date = DateTime.UtcNow.Date;
3841
if (currentUsage == null)
3942
{
40-
currentUsage = Reports.FirstOrDefault(usage => usage.Date == date);
43+
currentUsage = Reports
44+
.FirstOrDefault(usage => usage.Date == date
45+
&& usage.AppVersion == appVersion
46+
&& usage.UnityVersion == unityVersion);
4147
}
4248

4349
if (currentUsage?.Date == date)
@@ -48,7 +54,12 @@ public Usage GetCurrentUsage()
4854
}
4955
else
5056
{
51-
currentUsage = new Usage { Date = date, Guid = Guid };
57+
currentUsage = new Usage {
58+
Date = date,
59+
Guid = Guid,
60+
AppVersion = appVersion,
61+
UnityVersion = unityVersion,
62+
};
5263
Reports.Add(currentUsage);
5364
}
5465

src/GitHub.Api/Metrics/UsageTracker.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,8 @@ private async Task SendUsage()
154154

155155
private Usage GetCurrentUsage(UsageStore usageStore)
156156
{
157-
var usage = usageStore.Model.GetCurrentUsage();
158-
usage.UnityVersion = unityVersion;
157+
var usage = usageStore.Model.GetCurrentUsage(AppConfiguration.AssemblyName.Version.ToString(), unityVersion);
159158
usage.Lang = CultureInfo.InstalledUICulture.IetfLanguageTag;
160-
usage.AppVersion = AppConfiguration.AssemblyName.Version.ToString();
161159
usage.CurrentLang = CultureInfo.CurrentCulture.IetfLanguageTag;
162160
return usage;
163161
}

0 commit comments

Comments
 (0)