Esempio n. 1
0
    }


#インストールユーザーを抽出する
logdb = db_util.db_command("takagi", "7TgYiaI9", db["meta"]["server"], db["meta"]["db_name"])
sql = "select * from mnl_metalog where regdate = " + str(install_date)
log = logdb.db_anyselect(sql)
for v in log:
     user_data.setdefault(v["uid"], {})
     user_data[v["uid"]].setdefault(v["app_id"], {})
     user_data[v["uid"]][v["app_id"]].setdefault("regdate", int(v["regdate"]))
     user_data[v["uid"]][v["app_id"]].setdefault("app_id", v["app_id"])
     user_data[v["uid"]][v["app_id"]].setdefault("os_type", v["os_type"])
     user_data[v["uid"]][v["app_id"]].setdefault("duration", None)
     if int(v["pay_all"]) > 0:
          duration = date_func.duration(int(v["regdate"]), int(v["date"]))
          if user_data[v["uid"]][v["app_id"]]["duration"] == None or (user_data[v["uid"]][v["app_id"]]["duration"] > duration and user_data[v["uid"]][v["app_id"]]["duration"] != None):
               user_data[v["uid"]][v["app_id"]]["duration"] = duration

#集計
summary = {}

for uid, data0 in user_data.items():
     for app_id, data in data0.items():
          summary.setdefault(data["regdate"], {})
          summary[data["regdate"]].setdefault(app_id, {})
          summary[data["regdate"]][app_id].setdefault(data["os_type"], {})
          summary[data["regdate"]][app_id][data["os_type"]].setdefault("nuu", 0)
          summary[data["regdate"]][app_id][data["os_type"]].setdefault("day01", 0)
          summary[data["regdate"]][app_id][data["os_type"]].setdefault("day02", 0)
          summary[data["regdate"]][app_id][data["os_type"]].setdefault("day03", 0)
Esempio n. 2
0
where = "date = " + str(lower) + " and session_num > 0"
access_log = kidsnbooks_log.db_select("*", "mnl_metalog_light_fast", where, None)
summary = {}
for v in access_log:
    summary.setdefault(v["app_id"], {})
    summary[v["app_id"]].setdefault(v["os_type"], {})
    summary[v["app_id"]][v["os_type"]].setdefault("today", 0)
    summary[v["app_id"]][v["os_type"]].setdefault("this_month", 0)
    summary[v["app_id"]][v["os_type"]].setdefault("one_month_ago", 0)
    summary[v["app_id"]][v["os_type"]].setdefault("two_month_ago", 0)
    summary[v["app_id"]][v["os_type"]].setdefault("three_month_ago", 0)
    summary[v["app_id"]][v["os_type"]].setdefault("six_month_ago", 0)
    summary[v["app_id"]][v["os_type"]].setdefault("one_year_ago", 0)
    summary[v["app_id"]][v["os_type"]].setdefault("over_one_year_ago", 0)
    if v["regdate"] != "NULL" and int(v["regdate"]) != 0:
        if date_func.duration(int(v["regdate"]), lower) == 0:
            summary[v["app_id"]][v["os_type"]]["today"] += 1
        elif date_func.duration(int(v["regdate"]), lower) <= 30:
            summary[v["app_id"]][v["os_type"]]["this_month"] += 1
        elif date_func.duration(int(v["regdate"]), lower) <= 60:
            summary[v["app_id"]][v["os_type"]]["two_month_ago"] += 1
        elif date_func.duration(int(v["regdate"]), lower) <= 90:
            summary[v["app_id"]][v["os_type"]]["three_month_ago"] += 1
        elif date_func.duration(int(v["regdate"]), lower) <= 180:
            summary[v["app_id"]][v["os_type"]]["six_month_ago"] += 1
        elif date_func.duration(int(v["regdate"]), lower) <= 365:
            summary[v["app_id"]][v["os_type"]]["one_year_ago"] += 1
        else:
            summary[v["app_id"]][v["os_type"]]["over_one_year_ago"] += 1
  
#output