This commit is contained in:
guange 2019-01-18 18:51:51 +08:00
parent 968576e58c
commit 096d2ea2fd
4 changed files with 12 additions and 2 deletions

View File

@ -87,3 +87,4 @@ create table datas (
) comment = '通用配置表'; ) comment = '通用配置表';
insert into datas (`key`, data) values ('from_type', '{}'); insert into datas (`key`, data) values ('from_type', '{}');
insert into datas (`key`, data) values ('last_month_sell', '{}'); insert into datas (`key`, data) values ('last_month_sell', '{}');
insert into datas (`key`, data) values ('hour_sell', '{}');

View File

@ -82,7 +82,6 @@ $(function(){
//主要症状
var histogramChart2 = echarts.init(document.getElementById('histogramChart2')); var histogramChart2 = echarts.init(document.getElementById('histogramChart2'));
histogramChart2.setOption({ histogramChart2.setOption({

View File

@ -86,7 +86,7 @@
</div> </div>
<div class="left div_any01" style="width:41.5%;"> <div class="left div_any01" style="width:41.5%;">
<div class="div_any_child" style="height: 420px;"> <div class="div_any_child" style="height: 420px;">
<div class="div_any_title"><img src="{% static "images/title_14.png" %}">时段访问占比</div> <div class="div_any_title"><img src="{% static "images/title_14.png" %}">时段购买占比</div>
<p id="histogramChart2" class="p_chart" style="height: 400px;"></p> <p id="histogramChart2" class="p_chart" style="height: 400px;"></p>
</div> </div>
</div> </div>

View File

@ -57,6 +57,15 @@ def collect_last_month_sells(spark):
data[month] = jd_comment_count data[month] = jd_comment_count
mysql_execute("update datas set data = '{}' where `key` = 'last_month_sell'".format( json.dumps(data,ensure_ascii=False) )) mysql_execute("update datas set data = '{}' where `key` = 'last_month_sell'".format( json.dumps(data,ensure_ascii=False) ))
def collect_hour_sells(spark):
data = {}
for i in range(24):
hour = "%02d" % (i)
df = spark.sql("select count(*) as N from jd_comment where comment_time like '% "+hour+":%'")
jd_comment_count = df.rdd.collect()[0]["N"]
data[hour] = jd_comment_count
mysql_execute("update datas set data = '{}' where `key` = 'hour_sell'".format( json.dumps(data,ensure_ascii=False) ))
def collect_crawl_info(spark): def collect_crawl_info(spark):
@ -137,6 +146,7 @@ if __name__ == "__main__":
collect_top10_sells(spark) collect_top10_sells(spark)
collect_from_type(spark) collect_from_type(spark)
collect_last_month_sells(spark) collect_last_month_sells(spark)
collect_hour_sells(spark)
count = 1 count = 1
time.sleep(10) time.sleep(10)