Skip to content

Commit

Permalink
地址显示bug
Browse files Browse the repository at this point in the history
  • Loading branch information
smallevil committed Dec 4, 2020
1 parent 639c100 commit e5df791
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
4 changes: 2 additions & 2 deletions code/apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: smallevil
# @Date: 2020-11-24 10:48:40
# @Last Modified by: smallevil
# @Last Modified time: 2020-11-30 11:37:59
# @Last Modified time: 2020-12-02 13:34:28

from flask import Flask
from .views.share import share
Expand Down Expand Up @@ -33,4 +33,4 @@
chlr.setFormatter(formatter)
logger.addHandler(chlr)
else:
logger.setLevel(logging.ERROR)
logger.setLevel(logging.INFO)
10 changes: 9 additions & 1 deletion code/apps/templates/admin/stat_view_history.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@
{{ info.record_ip }}
</td>
<td>
{{ info.record_country }}/{{ info.record_province }}/{{ info.record_city }}
{{ info.record_country }}

{% if info.record_province|length > 0 %}
/{{ info.record_province }}
{% endif %}

{% if info.record_city|length > 0 %}
/{{ info.record_city }}
{% endif %}
</td>
<td>
{% if info.record_ua_type == 1 %}
Expand Down
10 changes: 7 additions & 3 deletions code/apps/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: smallevil
# @Date: 2020-11-24 10:48:40
# @Last Modified by: smallevil
# @Last Modified time: 2020-11-30 11:09:50
# @Last Modified time: 2020-12-04 16:00:09

from flask import Blueprint, render_template, redirect, session, request, current_app
import functools
Expand Down Expand Up @@ -355,10 +355,14 @@ def adminStatAddr(linkID, date):

charts = {'legend_data':[], 'series_data':[]}
for info in model.statAddr(linkID, date):
charts['legend_data'].append(info['address'] + ': ' + str(info['total']))

address = '未知'
if len(info['address']) > 0:
address = info['address']
charts['legend_data'].append(address + ': ' + str(info['total']))

t = {}
t['name'] = info['address'] + ': ' + str(info['total'])
t['name'] = address + ': ' + str(info['total'])
t['value'] = info['total']
charts['series_data'].append(t)
del t
Expand Down
9 changes: 8 additions & 1 deletion code/apps/views/front.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: smallevil
# @Date: 2020-11-24 10:48:40
# @Last Modified by: smallevil
# @Last Modified time: 2020-11-27 18:12:40
# @Last Modified time: 2020-12-04 15:53:23

import arrow, urllib
import geoip2.database
Expand Down Expand Up @@ -81,6 +81,13 @@ def getAddressByIP(ip):
except:
address = getAddressFromRegion(ip)

if str(address['province']) == '0':
address['province'] = ''
address['city'] = ''

if str(address['city']) == '0':
address['city'] = ''

return address


Expand Down
6 changes: 3 additions & 3 deletions code/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: smallevil
# @Date: 2020-11-24 10:48:40
# @Last Modified by: smallevil
# @Last Modified time: 2020-11-28 19:31:52
# @Last Modified time: 2020-12-02 13:33:47


from apps import app
Expand All @@ -15,12 +15,12 @@


def statMinute():
#app.logger.info('start stat minute')
app.logger.info('start stat minute')
model = AdminModel(app.config['DATABASE_URI'])
model.setStatDay('minute', arrow.now())

def statDay():
#app.logger.info('start stat day')
app.logger.info('start stat day')
model = AdminModel(app.config['DATABASE_URI'])
model.setStatDay('day', arrow.now())

Expand Down

0 comments on commit e5df791

Please sign in to comment.