summaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorGabriel Burt <gabriel.burt@gmail.com>2010-03-26 10:17:28 -0700
committerGabriel Burt <gabriel.burt@gmail.com>2010-03-26 10:18:45 -0700
commitda418959cdbab6a7f9e6717d5a21e30829608372 (patch)
tree380b1f41ed7f87677c9420e280b5acf9846e3c89 /extras
parentf4d67028f6faacdfc4277f1425cac5fe8d43c2f9 (diff)
[extras/metrics] usage report import improvements
Diffstat (limited to 'extras')
-rw-r--r--extras/metrics/Database.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/extras/metrics/Database.cs b/extras/metrics/Database.cs
index 37e17b404..c0758d5cc 100644
--- a/extras/metrics/Database.cs
+++ b/extras/metrics/Database.cs
@@ -129,6 +129,8 @@ namespace metrics
var last_config = LastReportNumber;
long last_report_number = Int64.Parse (last_config.Value);
+ var max_report_size = 150 * 1024;
+
db.BeginTransaction ();
foreach (var file in System.IO.Directory.GetFiles ("data")) {
var match = report_number_regex.Match (file);
@@ -141,6 +143,12 @@ namespace metrics
continue;
}
+ var file_size = new System.IO.FileInfo (file).Length;
+ if (file_size > max_report_size) {
+ Log.InformationFormat ("Skipping {0} because too large ({1:N0} KB compressed)", file, file_size/1024.0);
+ continue;
+ }
+
last_report_number = num;
Log.DebugFormat ("Importing {0}", file);
@@ -166,6 +174,10 @@ namespace metrics
var metrics = o["Metrics"] as JsonObject;
foreach (string metric_name in metrics.Keys) {
+ // Skip these; they are a ton of data, and really more for debug purposes
+ if (metric_name == "Banshee/LongSqliteCommand")
+ continue;
+
var samples = metrics[metric_name] as JsonArray;
string name = metric_name;
@@ -179,9 +191,16 @@ namespace metrics
sample_provider.Save (MultiUserSample.Import (db, user_id, name, (string)sample[0], (object)sample[1]));
}
}
+ db.CommitTransaction ();
} catch (Exception e) {
Log.Exception (String.Format ("Failed to read {0}", file), e);
+ db.RollbackTransaction ();
}
+
+ last_config.Value = last_report_number.ToString ();
+ Config.Save (last_config);
+
+ db.BeginTransaction ();
}
db.CommitTransaction ();