From 822cbdaa6649af182ab6354919f660987b424834 Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 16 Sep 2019 10:25:34 +0800 Subject: [PATCH 01/21] fix config not found in crontab --- priv_maps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv_maps.md b/priv_maps.md index f37d4fb..5f55e0e 100644 --- a/priv_maps.md +++ b/priv_maps.md @@ -84,7 +84,7 @@ http://154.8.214.202:5015/interface/company? "code": 200 } -#### 3、更改公司信息 +#### 3、更改图片信息 ##### 接口地址 From e735e11fe9bcd7098747a50449e93bda52e3fc61 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 19 Sep 2019 10:00:09 +0800 Subject: [PATCH 02/21] 1 --- handler/__pycache__/__init__.cpython-36.pyc | Bin 122 -> 123 bytes handler/__pycache__/company.cpython-36.pyc | Bin 4488 -> 4489 bytes handler/__pycache__/location.cpython-36.pyc | Bin 4293 -> 4294 bytes log/__pycache__/__init__.cpython-36.pyc | Bin 118 -> 119 bytes log/__pycache__/mylog.cpython-36.pyc | Bin 721 -> 722 bytes myredis/__pycache__/__init__.cpython-36.pyc | Bin 122 -> 123 bytes myredis/__pycache__/myredis.cpython-36.pyc | Bin 513 -> 514 bytes mysql/__pycache__/__init__.cpython-36.pyc | Bin 120 -> 121 bytes mysql/__pycache__/mmysql.cpython-36.pyc | Bin 4086 -> 4087 bytes 9 files changed, 0 insertions(+), 0 deletions(-) diff --git a/handler/__pycache__/__init__.cpython-36.pyc b/handler/__pycache__/__init__.cpython-36.pyc index d066b6659055d004cb620f62a07009827b1c9191..1c47a87c9603120b7aa658de5ea174ee7d0a22cc 100644 GIT binary patch delta 27 icmb=bW;f>L=hY=haLcH=m
  • jmIL=hY=hXDX=ZU{pF delta 26 hcmb=dU^nLFItF% From d22002818a7bc72a19fc7f29083e77ab02845e49 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 19 Sep 2019 17:44:12 +0800 Subject: [PATCH 03/21] change env to prod --- ops/env.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ops/env.py b/ops/env.py index dbda6c9..7dbafa1 100644 --- a/ops/env.py +++ b/ops/env.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -myenv="test" +myenv="prod" From 2e821a68a284e997479ba2263e5697a57c7e623a Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 19 Sep 2019 17:54:46 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=E8=B0=83=E6=95=B4info=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E4=B8=BA3=E5=B0=8F=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ad_tasks.py b/ad_tasks.py index 7a9f0b1..7a892d8 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -58,7 +58,7 @@ def sadd_adkey(key, line): if new_line: my_redis.hmset(info_key, new_line) - my_redis.expire(info_key, 60 * 3) + my_redis.expire(info_key, 60 * 60 * 3) #log.info(f"add info {new_line} 2 {info_key}!") else: log.error(f"split adinfo about locationid failed! localtionid={locationid} ") From 5707dbd2970180277a9fda9017d8426a38db49de Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 19 Sep 2019 19:20:54 +0800 Subject: [PATCH 05/21] fix key not found in redis --- ad_interface_tornado.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 09da09a..7cbb484 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -111,16 +111,20 @@ class DispatchHandler(tornado.web.RequestHandler): key_word = f"ad::{gameid}_*::{channelid}::{area}::*" else: pass - ad_keys = my_redis.keys(key_word) + try: + ad_keys = my_redis.keys(key_word) + except Exception: + log.error(f"{ad_keys} not found in redis!") ids = [] - for ad_key in ad_keys: - adlists = my_redis.smembers(ad_key) - try: - for key in adlists: - ids.append(key) - except Exception: - log.error(f"get redis data failed!", exc_info=True) - return self.write({'errcode': 2, "errmsg": f"get redis data failed!"}) + if ad_keys: + for ad_key in ad_keys: + adlists = my_redis.smembers(ad_key) + try: + for key in adlists: + ids.append(key) + except Exception: + log.error(f"get redis data failed!", exc_info=True) + return self.write({'errcode': 2, "errmsg": f"get redis data failed!"}) dist_ids = list(set(ids)) info = [] if not dist_ids: From 7d136131ee71b964636d6b540b8f636a568748cb Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 19 Sep 2019 19:23:12 +0800 Subject: [PATCH 06/21] fix key not found in redis --- ad_interface_tornado.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 7cbb484..8ef4d8e 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -110,7 +110,7 @@ class DispatchHandler(tornado.web.RequestHandler): elif gameid and area: key_word = f"ad::{gameid}_*::{channelid}::{area}::*" else: - pass + key_word = "" try: ad_keys = my_redis.keys(key_word) except Exception: From 8cc4c9f57900bb1869a862d8d03310fda75fbada Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 19 Sep 2019 19:25:55 +0800 Subject: [PATCH 07/21] fix key not found in redis --- ad_interface_tornado.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 8ef4d8e..ce49ced 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -105,16 +105,14 @@ class DispatchHandler(tornado.web.RequestHandler): result = {'errcode': 2, "errmsg": f"get args failed,{str(e)}"} log.error(result) return self.write_error(2) + key_word = "" if gameid and locationid: key_word = f"ad::{gameid}_*::{channelid}::*::{locationid}" elif gameid and area: key_word = f"ad::{gameid}_*::{channelid}::{area}::*" else: - key_word = "" - try: - ad_keys = my_redis.keys(key_word) - except Exception: - log.error(f"{ad_keys} not found in redis!") + pass + ad_keys = my_redis.keys(key_word) ids = [] if ad_keys: for ad_key in ad_keys: From 9bc778ab5536e286c76d663724ef878811d3dcfc Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 19 Sep 2019 19:34:30 +0800 Subject: [PATCH 08/21] fix key not found in redis --- ad_interface_tornado.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index ce49ced..ffa5851 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -111,7 +111,8 @@ class DispatchHandler(tornado.web.RequestHandler): elif gameid and area: key_word = f"ad::{gameid}_*::{channelid}::{area}::*" else: - pass + return self.write({'errcode': 2, "errmsg": "key_word not set!"}) + print(f"key_word={key_word}") ad_keys = my_redis.keys(key_word) ids = [] if ad_keys: From 869afc4290686cc0c89179ff8c31c518d97f76f8 Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 19 Sep 2019 19:53:06 +0800 Subject: [PATCH 09/21] =?UTF-8?q?=E8=B0=83=E8=AF=95=20=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E7=BB=A7=E7=BB=AD=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 2 +- ad_tasks.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index ffa5851..b987eb9 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -112,7 +112,7 @@ class DispatchHandler(tornado.web.RequestHandler): key_word = f"ad::{gameid}_*::{channelid}::{area}::*" else: return self.write({'errcode': 2, "errmsg": "key_word not set!"}) - print(f"key_word={key_word}") + #print(f"key_word={key_word}") ad_keys = my_redis.keys(key_word) ids = [] if ad_keys: diff --git a/ad_tasks.py b/ad_tasks.py index 7a892d8..f4b78d4 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -169,6 +169,7 @@ def send_cache_data(): for line in remove_data: try: id, gameid, channelid, locationids, status = line + print(f"find remove data in {line} ") for locationid in locationids.replace("[", "").replace("]", "").replace('"', "").split(','): locationid = locationid.strip() area_all = get_area_by_locationid(locationid) @@ -177,6 +178,7 @@ def send_cache_data(): area = area.strip() key = f"ad::{gameid}_{locationid}::{channelid}::{area}::{locationid}" values = f"{id}_{locationid}" + print(f"remove {values} from {key}") if my_redis.sismember(key, values): my_redis.srem(key, values) my_redis.expire(f"adinfo::{values}::info", 1) From 644ad943ead30854a32f36085ea17a03ee23790f Mon Sep 17 00:00:00 2001 From: pengtao Date: Thu, 19 Sep 2019 19:56:27 +0800 Subject: [PATCH 10/21] =?UTF-8?q?=E8=B0=83=E8=AF=95=20=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E7=BB=A7=E7=BB=AD=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ad_tasks.py b/ad_tasks.py index f4b78d4..2d1918d 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -176,7 +176,7 @@ def send_cache_data(): if area_all: for area in area_all.split(','): area = area.strip() - key = f"ad::{gameid}_{locationid}::{channelid}::{area}::{locationid}" + key = f"ad::{gameid}_{locationid}_{area}::{channelid}::{area}::{locationid}" values = f"{id}_{locationid}" print(f"remove {values} from {key}") if my_redis.sismember(key, values): From 7d55b1f2e5b655b11bb32866e1e5d2aeb05066d3 Mon Sep 17 00:00:00 2001 From: pengtao Date: Fri, 20 Sep 2019 11:29:15 +0800 Subject: [PATCH 11/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E6=8C=89gameid=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/ad.py | 70 ++++++++++++--------------------------------------- 1 file changed, 16 insertions(+), 54 deletions(-) diff --git a/handler/ad.py b/handler/ad.py index 906f766..c813371 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -49,62 +49,14 @@ class Ad(Resource): status = self.args['status'] id = self.args['id'] companyid = self.args['companyid'] + gameid = self.args['gameid'] # if not gameid or not localid: # # log.error(f"请输入必须的游戏ID和位置ID字段,当前获得是{gameid},{localid}") # return jsonify({'code': 500, "message": f"请输入必须的游戏ID和位置ID字段,当前获得是{gameid},{localid},{status}"}) # now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") if not id: - if companyid: - sel_sql = f"""select - id, - name, - begin_time, - end_time, - ad_num, - ad_title, - ad_body, - ad_image, - jump_param, - ad_sort, - status, - companyid, - locationid, - gameid, - channelid, - jump_status, - ad_property - from - ad - where - in_used=1 - and companyid={companyid};""" - elif status or status == 0: - sel_sql = f"""select - id, - name, - begin_time, - end_time, - ad_num, - ad_title, - ad_body, - ad_image, - jump_param, - ad_sort, - status, - companyid, - locationid, - gameid, - channelid, - jump_status, - ad_property - from - ad - where - in_used=1 - and status={status};""" - else: - sel_sql = f"""select + base_sql = """SELECT id, name, begin_time, @@ -122,10 +74,20 @@ class Ad(Resource): channelid, jump_status, ad_property - from + FROM ad - where - in_used=1 ;""" + WHERE + in_used=1 """ + + if companyid: + sel_sql = f"{base_sql} and companyid={companyid}" + else: + sel_sql = f"{base_sql}" + if status: + sel_sql = f"{sel_sql} and status={status}" + if gameid: + sel_sql = f"{sel_sql} and gameid={gameid}" + else: sel_sql = f"""select id, @@ -258,7 +220,7 @@ class Ad(Resource): if not id: return jsonify({'code': 404, 'message': f'{id} not found!'}) #del_sql = f"delete from ad where id={id};" - del_sql = f"update ad set status=4 where id={id};" + del_sql = f"update ad set in_used=0 where id={id};" try: self.mydb.change(del_sql) return jsonify({'code': 200, 'message': f'remove adid={id} success!'}) From 09a5dff82f6f9efa7b9ce66ec6d2ea8baeb1fe91 Mon Sep 17 00:00:00 2001 From: pengtao Date: Fri, 20 Sep 2019 12:47:37 +0800 Subject: [PATCH 12/21] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=94=B1status=3D4=20?= =?UTF-8?q?=E6=94=B9=E4=B8=BAin=5Fused=3D0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ad_tasks.py b/ad_tasks.py index 2d1918d..b9dec15 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -163,7 +163,7 @@ def send_cache_data(): ad where '{now}'> end_time - or status in (3,4) """ + or status in (3,4) or in_used=0 """ remove_data = mydb.query(expire_sql) if remove_data: for line in remove_data: From 8d6c0f9bd6b20f5ee2ff9c598572dfef2ef5bba1 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 20 Sep 2019 15:35:04 +0800 Subject: [PATCH 13/21] fix expire time to 24 hours --- ad_tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ad_tasks.py b/ad_tasks.py index b9dec15..7bebc7c 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -58,7 +58,7 @@ def sadd_adkey(key, line): if new_line: my_redis.hmset(info_key, new_line) - my_redis.expire(info_key, 60 * 60 * 3) + my_redis.expire(info_key, 60 * 60 * 24) #log.info(f"add info {new_line} 2 {info_key}!") else: log.error(f"split adinfo about locationid failed! localtionid={locationid} ") From 5ff3ccd970bafa00a4f5543cfb09bda57b6b405a Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 23 Sep 2019 10:35:55 +0800 Subject: [PATCH 14/21] =?UTF-8?q?=E5=B9=BF=E5=91=8A=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E9=9C=80=E6=B7=BB=E5=8A=A0locationid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index b987eb9..f7c7010 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -70,7 +70,7 @@ class DispatchHandler(tornado.web.RequestHandler): def _upAdRecording(self): try: adid = unquote(self.get_query_argument('adid'), 'utf-8') - localtionid = self.get_query_argument('locationid', 'utf-8') + localtionid = self.get_query_argument('locationid') log.info(f" get adid was {adid}") ids = json.loads(adid) except Exception: @@ -78,6 +78,9 @@ class DispatchHandler(tornado.web.RequestHandler): log.error(result, exc_info=True) self.write({'errcode': 1, "errmsg": 'get adid failed!'}) + if not localtionid: + self.write({'errcode': 1, "errmsg": 'get localtionid failed!'}) + if ids: for id in ids: if id: From da97efa222d79f05a78c249176c75b5c95c56abe Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 23 Sep 2019 10:46:15 +0800 Subject: [PATCH 15/21] =?UTF-8?q?=E5=B9=BF=E5=91=8A=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E9=9C=80=E6=B7=BB=E5=8A=A0locationid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ad_Readme.md b/ad_Readme.md index 56e4ab4..468f3b6 100644 --- a/ad_Readme.md +++ b/ad_Readme.md @@ -95,6 +95,7 @@ https://spread.kingsome.cn/webapp/index.php?c=Ops&a=upAdRecording&adid=%5B%22104 | c | string | 是 | OPS通用接口标志 | | a | string | 是 | 方法定义 upAdRecording | | adid | int | 是 | 广告ID | +|locationid|int|是|位置ID| ##### 返回参数说明 From f1cb2390b09ccce8048a35de89db11f45a25e5c4 Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 23 Sep 2019 15:04:55 +0800 Subject: [PATCH 16/21] =?UTF-8?q?=E5=B9=BF=E5=91=8A=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_Readme.md | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/ad_Readme.md b/ad_Readme.md index 468f3b6..5006a49 100644 --- a/ad_Readme.md +++ b/ad_Readme.md @@ -31,15 +31,20 @@ http://spread.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"100 | ad_body | string | 是 | 广告正文 | | ad_image | string | 是 | 广告图片 | | ad_sort | int | 是 | 播放优先级 | -| adid | int | 是 | 广告标志ID,用途数据上传统计 | +| id | int | 是 | 广告标志ID,用途数据上传统计 | | name | string | 是 | 广告名称 | | jump_status | int | 是 | 跳转状态,1=跳转,0=不跳 | | jump_param | string | 是 | 跳转参数 | -| area | string | 是 | 区域(第一元素:1=首页,2=游戏中,3=结算页,4=关闭,第二元素:X轴第三元素:Y轴,其中X,Y取值范围(0,15))如(1,0,0)代表首页左上 | +| area | string | 是 | 区域 | | type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | | mode | int | 是 | 广告单播或轮播模式(1=单播,2=轮播) | | ad_property | string | 是 | 广告属性描述 | - +| channelid | int | 是 | 平台ID | +| companyid | int | 是 | 公司ID | +| createtime | string | 是 | 广告创建时间 | +| ld_property | string | 是 | 位置属性 | +| locationid | int | 是 | 位置ID | +| x,y,x_offset,y_offset | int | 是 | 广告坐标系| ##### 返回示例 { @@ -49,20 +54,27 @@ http://spread.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"100 "totoal": 1, "result": [ { - "ad_body": "33", - "ad_image": "https://resource.kingsome.cn//ad/1d7bb7a2-a865-11e9-8df4-525400ddcafb_banner12(1).png", + "ad_body": "", + "ad_image": "https://resource.kingsome.cn/ad/b63dd2ca-dad5-11e9-9ea2-525400ddcafb_png", + "ad_property": "{\"is_shake\":0,\"is_hot\":0,\"is_new\":0,\"is_recommend\":0,\"appid\":\"wxdb103a128e118619\",\"jump_param\":\"yx2nyabgm8\",\"played\":0}", "ad_sort": "0", - "ad_title": "333", - "area": "1,0,0", + "ad_title": "", + "area": "3,8,12,0,32", "channelid": "6001", - "companyid": "1002", - "id": "1014", - "jump_param": "fdfd", - "jump_status": "0", - "locationid": "1001", - "mode": "0", - "name": "33", - "type": "1" + "companyid": "0", + "createtime": "2019-09-20 10:42:42", + "id": "1258", + "jump_param": "", + "jump_status": "1", + "ld_property": "{\"title\":\"底部横向滚动\",\"show_name\":\"\",\"bg_img\":\"\",\"has_dot\":false,\"is_shake\":false,\"is_hide\":true,\"is_show_name\":false,\"related\":[],\"scale\":1}", + "locationid": "1073", + "mode": "1", + "name": "首页icon轮播+底部横向滚动6", + "type": "6", + "x": "8", + "x_offset": "0", + "y": "12", + "y_offset": "32" } ] } @@ -113,5 +125,3 @@ https://spread.kingsome.cn/webapp/index.php?c=Ops&a=upAdRecording&adid=%5B%22104 "errmsg": "", "message": "1002 incr success!" } - -{"#account_id":"6001_2001_oJqfX5R1IDH0aUDTFxNqu5D1PsV8","#distinct_id":"SSg9qS1A2sLRHgvldEm9dkLiCJ6fSaa5","#type":"track","#time":"2019-09-06 14:45:45","#ip":"101.84.36.110","#event_name":"event_11_31","properties":{"nickname":"226","button_name":"jc_promotipn","button_param":"[{\"appid\":\"wxdb103a128e118619\",\"channelid\":\"6001\",\"adid\":\"1118\",\"jump_param\":\"yx2nyabgm8\"}]","account_id":"6001_2001_oJqfX5R1IDH0aUDTFxNqu5D1PsV8","account_register_utctime":1562124532,"account_register_date":"2019-07-03 11:28:52","localuuid":"SSg9qS1A2sLRHgvldEm9dkLiCJ6fSaa5","channel":"6001","from_appid":"","ad_channel":"","gameid":"2001"}} From ea35db73660adeecc8c9c4205a3a9759556d8d7a Mon Sep 17 00:00:00 2001 From: pengtao Date: Mon, 23 Sep 2019 15:06:56 +0800 Subject: [PATCH 17/21] =?UTF-8?q?=E5=B9=BF=E5=91=8A=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_Readme.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/ad_Readme.md b/ad_Readme.md index 5006a49..a9633e9 100644 --- a/ad_Readme.md +++ b/ad_Readme.md @@ -34,7 +34,6 @@ http://spread.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"100 | id | int | 是 | 广告标志ID,用途数据上传统计 | | name | string | 是 | 广告名称 | | jump_status | int | 是 | 跳转状态,1=跳转,0=不跳 | -| jump_param | string | 是 | 跳转参数 | | area | string | 是 | 区域 | | type | int | 是 | 类型(1=icon,2=banner,3=浮窗) | | mode | int | 是 | 广告单播或轮播模式(1=单播,2=轮播) | @@ -64,7 +63,6 @@ http://spread.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"100 "companyid": "0", "createtime": "2019-09-20 10:42:42", "id": "1258", - "jump_param": "", "jump_status": "1", "ld_property": "{\"title\":\"底部横向滚动\",\"show_name\":\"\",\"bg_img\":\"\",\"has_dot\":false,\"is_shake\":false,\"is_hide\":true,\"is_show_name\":false,\"related\":[],\"scale\":1}", "locationid": "1073", From 3b58106e7d225f0ea60fb17ecf4f4c3c41bc2364 Mon Sep 17 00:00:00 2001 From: pengtao Date: Fri, 27 Sep 2019 15:05:25 +0800 Subject: [PATCH 18/21] =?UTF-8?q?ad=5Finterface=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=A4=9A=E8=BF=9B=E7=A8=8B=E5=90=AF=E5=8A=A8=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_interface_tornado.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index f7c7010..1e0e672 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -2,8 +2,10 @@ # 推广系统对外接口,提供与客户端之间的广告信息接口及每分钟执行一次的缓存变更操作 # http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":1004,"locationid":1001} # http://ad.kingsome.cn/webapp/index.php?c=Ops&a=upAdRecording&adid=1002 +# python ad_interface_tornado.py --port=5013 import tornado.ioloop import tornado.web +import tornado.options import json from myredis.myredis import my_redis import datetime @@ -19,7 +21,7 @@ from urllib.parse import unquote define_logger("/data/logs/ad_interface_tornado.log") log = logging.getLogger(__name__) - +tornado.options.define("port", default=ad_list_interface_port, type=int, help="run server on the given port.") limit = 100 @@ -165,6 +167,7 @@ def make_app(): if __name__ == "__main__": print('start!') + tornado.options.parse_command_line() app = make_app() - app.listen(ad_list_interface_port) + app.listen(tornado.options.options.port) tornado.ioloop.IOLoop.current().start() From f8a6abf81aa14d4376be58dd10d9bb67b0cb7dd0 Mon Sep 17 00:00:00 2001 From: pengtao Date: Fri, 27 Sep 2019 15:06:19 +0800 Subject: [PATCH 19/21] remove no used --- ad_interface_tornado.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 1e0e672..fc79b45 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -15,7 +15,6 @@ from log.mylog import define_logger import logging from prod_config import BEGIN, END, ad_list_interface_port from tornado import gen -import pdb from urllib.parse import unquote From 71aae3af9202cf6e9012b19ba75a4260214a1e05 Mon Sep 17 00:00:00 2001 From: pengtao Date: Fri, 27 Sep 2019 23:04:06 +0800 Subject: [PATCH 20/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=84=E7=90=86locat?= =?UTF-8?q?ionid=E5=BC=82=E5=B8=B8=E7=9A=84=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_tasks.py | 60 +++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/ad_tasks.py b/ad_tasks.py index 7bebc7c..e7d8020 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -8,6 +8,7 @@ import logging import pdb import json import copy + define_logger(f"{log_path}/ad_tasks.log") log = logging.getLogger(__name__) @@ -47,24 +48,22 @@ def split_ad_info(localtionid, line): def sadd_adkey(key, line): - locationid = line['locationid'] redis_key = f"{line['id']}_{locationid}" my_redis.sadd(key, redis_key) - my_redis.expire(key, 60*2) - #log.info(f"add {redis_key} 2 {key}!") + my_redis.expire(key, 60 * 2) + # log.info(f"add {redis_key} 2 {key}!") info_key = f"adinfo::{redis_key}::info" new_line = split_ad_info(locationid, line) if new_line: my_redis.hmset(info_key, new_line) my_redis.expire(info_key, 60 * 60 * 24) - #log.info(f"add info {new_line} 2 {info_key}!") + # log.info(f"add info {new_line} 2 {info_key}!") else: log.error(f"split adinfo about locationid failed! localtionid={locationid} ") - def send_cache_data(): log.info("start update cache !") now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") @@ -102,7 +101,7 @@ def send_cache_data(): try: item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[ 'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], item[ - 'jump_status'], item['locationid'], item['ad_property'],item['createtime'] = line + 'jump_status'], item['locationid'], item['ad_property'], item['createtime'] = line item['createtime'] = datetime.datetime.strftime(item['createtime'], "%Y-%m-%d %H:%M:%S") if item.get('jump_param', "") and (item['ad_property'].find("jump_param") == -1): try: @@ -128,32 +127,35 @@ def send_cache_data(): if all: for line in all: if line: - locationids = json.loads(line.get('locationid')) - for locationid in str(locationids).replace('[','').replace(']','').split(','): - locationid = locationid.strip() - area_all = get_area_by_locationid(locationid) - for area in area_all.split(','): - area = area.strip() - line['locationid'] = locationid - line['area'] = area + try: + locationids = json.loads(line.get('locationid')) + for locationid in str(locationids).replace('[', '').replace(']', '').split(','): + locationid = locationid.strip() + area_all = get_area_by_locationid(locationid) + for area in area_all.split(','): + area = area.strip() + line['locationid'] = locationid + line['area'] = area - key = f"ad::{line.get('gameid', 0)}_{locationid}_{area}::{line.get('channelid', 0)}::{area}::{locationid}" - if int(line['ad_num']) == 0: - sadd_adkey(key, line) - elif int(line['ad_num']) > 0: - num = my_redis.get(f"adnum::{line['id']}_{locationid}::num") - print(f" get {line['id']} {locationid} num was {num}!") - if not num: - num = 0 - if int(line['ad_num']) > int(num): + key = f"ad::{line.get('gameid', 0)}_{locationid}_{area}::{line.get('channelid',0)}::{area}::{locationid}" + if int(line['ad_num']) == 0: sadd_adkey(key, line) + elif int(line['ad_num']) > 0: + num = my_redis.get(f"adnum::{line['id']}_{locationid}::num") + print(f" get {line['id']} {locationid} num was {num}!") + if not num: + num = 0 + if int(line['ad_num']) > int(num): + sadd_adkey(key, line) + else: + redis_key = f"{line['id']}_{locationid}" + if my_redis.sismember(key, redis_key): + my_redis.srem(key, redis_key) + log.info(f"remove {redis_key} from {key}!") else: - redis_key = f"{line['id']}_{locationid}" - if my_redis.sismember(key, redis_key): - my_redis.srem(key, redis_key) - log.info(f"remove {redis_key} from {key}!") - else: - log.error(f"get ad_num from mysql failed! ad_num={line['ad_num']}") + log.error(f"get ad_num from mysql failed! ad_num={line['ad_num']}") + except Exception: + log.error(f"produce data ={line} error !", exc_info=True) # 删除过期的数据 log.info("remove expire data from cache!") From f533ff3ea796c468d02478051bed248cd63641d2 Mon Sep 17 00:00:00 2001 From: pengtao Date: Fri, 27 Sep 2019 23:17:17 +0800 Subject: [PATCH 21/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=84=E7=90=86locat?= =?UTF-8?q?ionid=E5=BC=82=E5=B8=B8=E7=9A=84=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_tasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ad_tasks.py b/ad_tasks.py index e7d8020..73ead7c 100644 --- a/ad_tasks.py +++ b/ad_tasks.py @@ -27,7 +27,7 @@ def get_area_by_locationid(ldid): if data: return data[0][0].replace("[", "").replace("]", "").replace('"', "") else: - log.error(f"get area from location failed!,sql={sql}") + log.error(f"get area from location failed!,sql={sql},idld={ldid}") return area @@ -184,7 +184,7 @@ def send_cache_data(): if my_redis.sismember(key, values): my_redis.srem(key, values) my_redis.expire(f"adinfo::{values}::info", 1) - log.info(f"remove {id} from {key} success!") + #log.info(f"remove {id} from {key} success!") except Exception: log.error("拆解过期数据出错!", exc_info=True)