[gdm] Run ck-history with the --since option of ~2 months



commit d71c6eef037cd70785c57b0eaed3522c19cf41d4
Author: William Jon McCann <jmccann redhat com>
Date:   Fri Jun 11 17:05:26 2010 -0400

    Run ck-history with the --since option of ~2 months
    
    Without the option ConsoleKit tries to load the entire history
    including any log rotated files.  This can prove to be very
    costly.  Events after a couple of months lose relevancy anyway
    so it seems reasonable to use a recent time window for computing
    the frequency information.
    
    This requires ConsoleKit from git master.

 gui/simple-greeter/gdm-user-manager.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-user-manager.c b/gui/simple-greeter/gdm-user-manager.c
index d9b65fa..b8aa10b 100644
--- a/gui/simple-greeter/gdm-user-manager.c
+++ b/gui/simple-greeter/gdm-user-manager.c
@@ -80,6 +80,9 @@
 #define GDM_USERNAME "gdm"
 #endif
 
+/* approximately two months */
+#define LOGIN_FREQUENCY_TIME_WINDOW_SECS (60 * 24 * 60 * 60)
+
 #define ACCOUNTS_NAME      "org.freedesktop.Accounts"
 #define ACCOUNTS_PATH      "/org/freedesktop/Accounts"
 #define ACCOUNTS_INTERFACE "org.freedesktop.Accounts"
@@ -1501,12 +1504,14 @@ static gboolean
 load_ck_history (GdmUserManager *manager)
 {
         char       *command;
+        char       *since;
         const char *seat_id;
         GError     *error;
         gboolean    res;
         char      **argv;
         int         standard_out;
         GIOChannel *channel;
+        GTimeVal    tv;
 
         g_assert (manager->priv->ck_history_id == 0);
 
@@ -1524,8 +1529,14 @@ load_ck_history (GdmUserManager *manager)
                 goto out;
         }
 
-        command = g_strdup_printf ("ck-history --frequent --seat='%s' --session-type=''",
+        g_get_current_time (&tv);
+        tv.tv_sec -= LOGIN_FREQUENCY_TIME_WINDOW_SECS;
+        since = g_time_val_to_iso8601 (&tv);
+
+        command = g_strdup_printf ("ck-history --frequent --since='%s' --seat='%s' --session-type=''",
+                                   since,
                                    seat_id);
+        g_free (since);
         g_debug ("GdmUserManager: running '%s'", command);
         error = NULL;
         if (! g_shell_parse_argv (command, NULL, &argv, &error)) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]