[banshee] [extras/metrics] Start doing some basic analysis
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [extras/metrics] Start doing some basic analysis
- Date: Fri, 19 Feb 2010 23:36:50 +0000 (UTC)
commit 8fef2fb56d53add4a9aa26ef63e0e3a26ffbadda
Author: Gabriel Burt <gabriel burt gmail com>
Date: Fri Feb 19 15:35:43 2010 -0800
[extras/metrics] Start doing some basic analysis
extras/metrics/CreateMetricsDb.cs | 17 +++++++++----
extras/metrics/Main.cs | 47 +++++++++++++++++++++++++++++++++++++
extras/metrics/MetaMetrics.cs | 46 ++++++++++++++++++++++++++++++++++++
extras/metrics/MultiUserSample.cs | 16 ++++++------
extras/metrics/metrics.csproj | 2 +
5 files changed, 115 insertions(+), 13 deletions(-)
---
diff --git a/extras/metrics/CreateMetricsDb.cs b/extras/metrics/CreateMetricsDb.cs
index 4a76bc5..4e907de 100644
--- a/extras/metrics/CreateMetricsDb.cs
+++ b/extras/metrics/CreateMetricsDb.cs
@@ -33,13 +33,20 @@ using Hyena.Json;
namespace metrics
{
- public class CreateMetricsDb
+ public class Database
{
- public static void Main ()
+ const string db_path = "metrics.db";
+
+ public static HyenaSqliteConnection Open ()
+ {
+ return new HyenaSqliteConnection (db_path);
+ }
+
+ public static bool Exists { get { return System.IO.File.Exists (db_path); } }
+
+ public static void Import ()
{
- string db_path = "metrics.db";
- System.IO.File.Delete (db_path);
- using (var db = new HyenaSqliteConnection (db_path)) {
+ using (var db = Open ()) {
MultiUserSample.Provider = new SqliteModelProvider<MultiUserSample> (db, "Samples", true);
foreach (var file in System.IO.Directory.GetFiles ("data")) {
Log.InformationFormat ("Importing {0}", file);
diff --git a/extras/metrics/Main.cs b/extras/metrics/Main.cs
new file mode 100644
index 0000000..c762d88
--- /dev/null
+++ b/extras/metrics/Main.cs
@@ -0,0 +1,47 @@
+//
+// Main.cs
+//
+// Author:
+// Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+using Hyena;
+using Hyena.CommandLine;
+
+namespace metrics
+{
+ public class MainEntry
+ {
+ public static void Main (string [] args)
+ {
+ if (!Database.Exists) {
+ Database.Import ();
+ } else {
+ using (var db = Database.Open ()) {
+ new MetaMetrics (db);
+ }
+ }
+ }
+ }
+}
diff --git a/extras/metrics/MetaMetrics.cs b/extras/metrics/MetaMetrics.cs
new file mode 100644
index 0000000..bf0c72f
--- /dev/null
+++ b/extras/metrics/MetaMetrics.cs
@@ -0,0 +1,46 @@
+//
+// MetaMetrics.cs
+//
+// Author:
+// Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using Hyena.Data.Sqlite;
+
+namespace metrics
+{
+ public class MetaMetrics
+ {
+ public DateTime FirstReport { get; private set; }
+ public DateTime LastReport { get; private set; }
+ public MetaMetrics (HyenaSqliteConnection db)
+ {
+ FirstReport = db.Query<DateTime> ("SELECT Stamp FROM Samples ORDER BY STAMP ASC");
+ LastReport = db.Query<DateTime> ("SELECT Stamp FROM Samples ORDER BY STAMP DESC");
+
+ Console.WriteLine ("First report was on {0}", FirstReport);
+ Console.WriteLine ("Last report was on {0}", LastReport);
+ Console.WriteLine ("Total unique users: {0}", db.Query<long> ("SELECT COUNT(DISTINCT(UserId)) FROM Samples"));
+ }
+ }
+}
diff --git a/extras/metrics/MultiUserSample.cs b/extras/metrics/MultiUserSample.cs
index a96e0cd..20bf1b3 100644
--- a/extras/metrics/MultiUserSample.cs
+++ b/extras/metrics/MultiUserSample.cs
@@ -1,21 +1,21 @@
-//
+//
// MultiUserSample.cs
-//
+//
// Author:
// Gabriel Burt <gabriel burt gmail com>
-//
-// Copyright (c) 2010 Gabriel Burt
-//
+//
+// Copyright (c) 2010 Novell, Inc.
+//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -66,4 +66,4 @@ namespace metrics
Provider.Save (sample);
}
}
-}
\ No newline at end of file
+}
diff --git a/extras/metrics/metrics.csproj b/extras/metrics/metrics.csproj
index 82b4e68..1ba256a 100644
--- a/extras/metrics/metrics.csproj
+++ b/extras/metrics/metrics.csproj
@@ -34,6 +34,8 @@
<ItemGroup>
<Compile Include="CreateMetricsDb.cs" />
<Compile Include="MultiUserSample.cs" />
+ <Compile Include="MetaMetrics.cs" />
+ <Compile Include="Main.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Libraries\Hyena\Hyena.csproj">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]