Add local time attribute to the communication log table 83/42983/1 accepted/tizen/mobile/20150708.020007 accepted/tizen/tv/20150708.020125 submit/tizen_mobile/20150707.222458 submit/tizen_tv/20150707.222506
authorMu-Woong <muwoong.lee@samsung.com>
Mon, 6 Jul 2015 12:52:12 +0000 (21:52 +0900)
committerMu-Woong <muwoong.lee@samsung.com>
Mon, 6 Jul 2015 12:52:12 +0000 (21:52 +0900)
Change-Id: Iccdd15a497784f99929be9b5ba6ef7cd5a311635
Signed-off-by: Mu-Woong <muwoong.lee@samsung.com>
src/social/db_handle.cpp
src/social/log_aggregator.cpp
src/social/log_aggregator.h
src/social/social_stats_types.h

index 1062bbd..8ac51cc 100644 (file)
@@ -111,13 +111,11 @@ std::string ctx::social_db_handle::create_sql_frequency(ctx::json filter)
                return "";
        }
 
-       /* TODO: Enable after fixing the log aggregator
        if (filter.get(NULL, STATS_DAY_OF_WEEK, &week_str))
                filter_cleaned.set(NULL, STATS_DAY_OF_WEEK, week_str);
 
        if (filter.get(NULL, STATS_TIME_OF_DAY, &time_of_day))
                filter_cleaned.set(NULL, STATS_TIME_OF_DAY, time_of_day);
-       */
 
        std::stringstream query;
 
index f1488d9..4d2536f 100644 (file)
@@ -55,6 +55,7 @@ void ctx::contact_log_aggregator::aggregate_contact_log()
 {
        db_manager::execute(0,
                        "SELECT IFNULL(MAX(" STATS_UNIV_TIME "),0) AS " STATS_LAST_TIME \
+                       ", (strftime('%s', 'now', 'localtime')) - (strftime('%s', 'now')) AS " TIME_DIFFERENCE \
                        " FROM " SOCIAL_TABLE_CONTACT_LOG, this);
 }
 
@@ -64,7 +65,9 @@ void ctx::contact_log_aggregator::on_query_result_received(unsigned int query_id
 
        int last_time = 0;
        records[0].get(NULL, STATS_LAST_TIME, &last_time);
-       _D("Last Comm Time: %d", last_time);
+       records[0].get(NULL, TIME_DIFFERENCE, &time_diff);
+
+       _D("Last Time: %d / Local - UTC: %d", last_time, time_diff);
 
        scope_zone_joiner sz(zone_util::default_zone());
 
@@ -143,6 +146,7 @@ void ctx::contact_log_aggregator::insert_contact_log_list(contacts_list_h list)
                data.set(NULL, SOCIAL_PHONE_LOG_TYPE, log_type);
                data.set(NULL, STATS_DURATION, duration);
                data.set(NULL, STATS_UNIV_TIME, accesstime);
+               data.set(NULL, STATS_LOCAL_TIME, accesstime + time_diff);
 
                /* TODO: Local Time */
 
index d42d5a7..e7b0c62 100644 (file)
@@ -26,6 +26,7 @@ namespace ctx {
        class contact_log_aggregator : public db_listener_iface, public timer_listener_iface {
                private:
                        int timer_id;
+                       int time_diff;
                        void create_table();
                        void get_updated_contact_log_list(int last_time, contacts_list_h *list);
                        void insert_contact_log_list(contacts_list_h list);
index 18d2a2b..f38b0da 100644 (file)
@@ -26,7 +26,8 @@
 #define SOCIAL_TABLE_CONTACT_LOG_COLUMNS \
        "Address TEXT NOT NULL, PLogType INTEGER NOT NULL, " \
        "Duration INTEGER NOT NULL DEFAULT 0, " \
-       "UTC TIMESTAMP DEFAULT (strftime('%s', 'now'))"
+       "UTC TIMESTAMP DEFAULT (strftime('%s', 'now')), " \
+       "LocalTime TIMESTAMP DEFAULT (strftime('%s', 'now', 'localtime'))"
 
 #define SOCIAL_TEMP_CONTACT_FREQ       "Temp_ContactFreq"
 #define SOCIAL_TEMP_CONTACT_FREQ_SQL \
@@ -36,6 +37,7 @@
 #define SOCIAL_COMMUNICATION_TYPE      "CommunicationType"
 #define SOCIAL_ADDRESS                         "Address"
 #define SOCIAL_PHONE_LOG_TYPE          "PLogType"
+#define TIME_DIFFERENCE                                "TimeDIff"
 
 enum _social_comm_type_e {
        SOCIAL_COMMUNICATION_TYPE_CALL = 1,