rda-python-metrics 1.0.21__py3-none-any.whl → 1.0.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rda-python-metrics might be problematic. Click here for more details.
- rda_python_metrics/fillipinfo.py +47 -39
- rda_python_metrics/fillipinfo.usg +3 -1
- {rda_python_metrics-1.0.21.dist-info → rda_python_metrics-1.0.23.dist-info}/METADATA +1 -1
- {rda_python_metrics-1.0.21.dist-info → rda_python_metrics-1.0.23.dist-info}/RECORD +8 -8
- {rda_python_metrics-1.0.21.dist-info → rda_python_metrics-1.0.23.dist-info}/WHEEL +0 -0
- {rda_python_metrics-1.0.21.dist-info → rda_python_metrics-1.0.23.dist-info}/entry_points.txt +0 -0
- {rda_python_metrics-1.0.21.dist-info → rda_python_metrics-1.0.23.dist-info}/licenses/LICENSE +0 -0
- {rda_python_metrics-1.0.21.dist-info → rda_python_metrics-1.0.23.dist-info}/top_level.txt +0 -0
rda_python_metrics/fillipinfo.py
CHANGED
|
@@ -25,10 +25,11 @@ from rda_python_common import PgDBI
|
|
|
25
25
|
from . import PgIPInfo
|
|
26
26
|
|
|
27
27
|
# the define options for gathering ipinfo data
|
|
28
|
+
DATES = 0x01 # fix data usages for given dates
|
|
28
29
|
MONTH = 0x02 # fix data usages for given months
|
|
29
30
|
YEARS = 0x04 # fix data usages for given years
|
|
30
31
|
NDAYS = 0x08 # fix data usages in recent number of days
|
|
31
|
-
MULTI = (MONTH|YEARS)
|
|
32
|
+
MULTI = (DATES|MONTH|YEARS)
|
|
32
33
|
SINGL = (NDAYS)
|
|
33
34
|
|
|
34
35
|
IPINFO = {
|
|
@@ -49,8 +50,10 @@ def main():
|
|
|
49
50
|
for arg in argv:
|
|
50
51
|
if arg == "-b":
|
|
51
52
|
PgLOG.PGLOG['BCKGRND'] = 1
|
|
52
|
-
elif re.match(r'^-[
|
|
53
|
-
if arg == "-
|
|
53
|
+
elif re.match(r'^-[dmNy]$', arg) and option == 0:
|
|
54
|
+
if arg == "-d":
|
|
55
|
+
option = DATES
|
|
56
|
+
elif arg == "-m":
|
|
54
57
|
option = MONTH
|
|
55
58
|
elif arg == "-y":
|
|
56
59
|
option = YEARS
|
|
@@ -74,17 +77,6 @@ def main():
|
|
|
74
77
|
PgDBI.dssdb_dbname()
|
|
75
78
|
PgLOG.cmdlog("fillipinfo {}".format(' '.join(argv)))
|
|
76
79
|
|
|
77
|
-
if option&NDAYS:
|
|
78
|
-
curdate = IPINFO['CDATE']
|
|
79
|
-
datelimit = PgUtil.adddate(curdate, 0, 0, -int(inputs[0]))
|
|
80
|
-
option = MONTH
|
|
81
|
-
inputs = []
|
|
82
|
-
|
|
83
|
-
while curdate >= datelimit:
|
|
84
|
-
tms = curdate.split('-')
|
|
85
|
-
inputs.append("{}-{}".format(tms[0], tms[1]))
|
|
86
|
-
curdate = PgUtil.adddate(curdate, 0, 0, -int(tms[2]))
|
|
87
|
-
|
|
88
80
|
fill_ip_info(option, inputs, table)
|
|
89
81
|
|
|
90
82
|
sys.exit(0)
|
|
@@ -95,32 +87,48 @@ def main():
|
|
|
95
87
|
def fill_ip_info(option, inputs, table):
|
|
96
88
|
|
|
97
89
|
cntall = 0
|
|
98
|
-
|
|
90
|
+
func = eval('fix_{}_records'.format(table))
|
|
99
91
|
for input in inputs:
|
|
100
92
|
if option&NDAYS:
|
|
101
93
|
edate = IPINFO['CDATE']
|
|
102
|
-
date = PgUtil.adddate(edate, 0, 0, -int(input))
|
|
94
|
+
date = PgUtil.adddate(edate, 0, 0, -int(input))
|
|
95
|
+
elif option&DATES:
|
|
96
|
+
edate = date = input
|
|
103
97
|
elif option&MONTH:
|
|
104
98
|
tms = input.split('-')
|
|
105
99
|
date = "{}-{:02}-01".format(tms[0], int(tms[1]))
|
|
106
100
|
edate = PgUtil.enddate(date, 0, 'M')
|
|
107
|
-
|
|
101
|
+
else:
|
|
108
102
|
date = input + "-01-01"
|
|
109
103
|
edate = input + "-12-31"
|
|
110
|
-
|
|
111
104
|
while date <= edate:
|
|
112
|
-
|
|
113
|
-
cntall += func(date)
|
|
114
|
-
date = PgUtil.adddate(
|
|
115
|
-
|
|
105
|
+
(ndate, cond) = get_next_date(date, edate)
|
|
106
|
+
cntall += func(date, cond)
|
|
107
|
+
date = PgUtil.adddate(ndate, 0, 0, 1)
|
|
108
|
+
|
|
109
|
+
if cntall > 2:
|
|
110
|
+
PgLOG.pglog("{}: Total {} records updated".format(table, cntall), PgLOG.LOGWRN)
|
|
111
|
+
|
|
112
|
+
def get_next_date(date, edate):
|
|
113
|
+
|
|
114
|
+
if date < edate:
|
|
115
|
+
ndate = PgUtil.enddate(date, 'M')
|
|
116
|
+
if ndate > edate: ndate = edate
|
|
117
|
+
if date < ndate:
|
|
118
|
+
cond = f"BETWEEN '{date}' AND '{ndate}'"
|
|
119
|
+
else:
|
|
120
|
+
cond = f"= '{date}'"
|
|
121
|
+
|
|
122
|
+
return (ndate, cond)
|
|
123
|
+
|
|
116
124
|
|
|
117
|
-
def fix_allusage_records(date):
|
|
125
|
+
def fix_allusage_records(date, cnd):
|
|
118
126
|
|
|
119
127
|
cnt = 0
|
|
120
128
|
ms = re.match(r'^(\d+)-', date)
|
|
121
129
|
year = ms.group(1)
|
|
122
130
|
table = 'allusage_' + year
|
|
123
|
-
cond = "date
|
|
131
|
+
cond = f"date {cnd} AND region IS NULL"
|
|
124
132
|
pgrecs = PgDBI.pgmget(table, 'aidx, email, ip', cond, PgLOG.LGEREX)
|
|
125
133
|
if not pgrecs: return 0
|
|
126
134
|
cnt = len(pgrecs['ip']) if pgrecs else 0
|
|
@@ -131,15 +139,15 @@ def fix_allusage_records(date):
|
|
|
131
139
|
mcnt += PgDBI.pgupdt(table, record, "aidx = '{}'".format(pgrecs['aidx'][i]))
|
|
132
140
|
|
|
133
141
|
s = 's' if cnt > 1 else ''
|
|
134
|
-
PgLOG.pglog("{}: {} of {} record{} updated for {}"
|
|
142
|
+
PgLOG.pglog(f"{table}: {mcnt} of {cnt} record{s} updated for date {cnd}", PgLOG.LOGWRN)
|
|
135
143
|
|
|
136
144
|
return mcnt
|
|
137
145
|
|
|
138
|
-
def fix_tdsusage_records(date):
|
|
146
|
+
def fix_tdsusage_records(date, cnd):
|
|
139
147
|
|
|
140
148
|
table = 'tdsusage'
|
|
141
|
-
cond = "date
|
|
142
|
-
pgrecs = PgDBI.pgmget(table, 'time, email, ip', cond, PgLOG.LGEREX)
|
|
149
|
+
cond = f"date {cnd} AND region IS NULL"
|
|
150
|
+
pgrecs = PgDBI.pgmget(table, 'date, time, email, ip', cond, PgLOG.LGEREX)
|
|
143
151
|
if not pgrecs: return 0
|
|
144
152
|
cnt = len(pgrecs['ip']) if pgrecs else 0
|
|
145
153
|
mcnt = 0
|
|
@@ -147,18 +155,18 @@ def fix_tdsusage_records(date):
|
|
|
147
155
|
ip = pgrecs['ip'][i]
|
|
148
156
|
record = PgIPInfo.get_missing_ipinfo(ip, pgrecs['email'][i])
|
|
149
157
|
if record:
|
|
150
|
-
cond = "date = '{}' AND time = '{}' AND ip = '{}'".format(date, pgrecs['time'][i], ip)
|
|
158
|
+
cond = "date = '{}' AND time = '{}' AND ip = '{}'".format(pgrecs['date'][i], pgrecs['time'][i], ip)
|
|
151
159
|
mcnt += PgDBI.pgupdt(table, record, cond)
|
|
152
160
|
|
|
153
161
|
s = 's' if cnt > 1 else ''
|
|
154
|
-
PgLOG.pglog("{}: {} of {} record{} updated for {}"
|
|
162
|
+
PgLOG.pglog(f"{table}: {mcnt} of {cnt} record{s} updated for date {cnd}", PgLOG.LOGWRN)
|
|
155
163
|
|
|
156
164
|
return mcnt
|
|
157
165
|
|
|
158
|
-
def fix_codusage_records(date):
|
|
166
|
+
def fix_codusage_records(date, cnd):
|
|
159
167
|
|
|
160
168
|
table = 'codusage'
|
|
161
|
-
cond = "date
|
|
169
|
+
cond = f"date {cnd} AND region IS NULL"
|
|
162
170
|
pgrecs = PgDBI.pgmget(table, 'codidx, email, ip', cond, PgLOG.LGEREX)
|
|
163
171
|
if not pgrecs: return 0
|
|
164
172
|
cnt = len(pgrecs['ip']) if pgrecs else 0
|
|
@@ -169,14 +177,14 @@ def fix_codusage_records(date):
|
|
|
169
177
|
mcnt += PgDBI.pgupdt(table, record, "codidx = '{}'".format(pgrecs['codidx'][i]))
|
|
170
178
|
|
|
171
179
|
s = 's' if cnt > 1 else ''
|
|
172
|
-
PgLOG.pglog("{}: {} of {} record{} updated for {}"
|
|
180
|
+
PgLOG.pglog(f"{table}: {mcnt} of {cnt} record{s} updated for date {cnd}", PgLOG.LOGWRN)
|
|
173
181
|
|
|
174
182
|
return mcnt
|
|
175
183
|
|
|
176
|
-
def fix_wuser_records(date):
|
|
184
|
+
def fix_wuser_records(date, cnd):
|
|
177
185
|
|
|
178
186
|
table = 'wuser'
|
|
179
|
-
cond = "start_date
|
|
187
|
+
cond = f"start_date {cnd} AND region IS NULL"
|
|
180
188
|
pgrecs = PgDBI.pgmget(table, 'wuid, email, ip', cond, PgLOG.LGEREX)
|
|
181
189
|
if not pgrecs: return 0
|
|
182
190
|
cnt = len(pgrecs['ip']) if pgrecs else 0
|
|
@@ -189,14 +197,14 @@ def fix_wuser_records(date):
|
|
|
189
197
|
mcnt += PgDBI.pgupdt(table, record, "wuid = '{}'".format(pgrecs['wuid'][i]))
|
|
190
198
|
|
|
191
199
|
s = 's' if cnt > 1 else ''
|
|
192
|
-
PgLOG.pglog("{}: {} of {} record{} updated for {}"
|
|
200
|
+
PgLOG.pglog(f"{table}: {mcnt} of {cnt} record{s} updated for start_date {cnd}", PgLOG.LOGWRN)
|
|
193
201
|
|
|
194
202
|
return mcnt
|
|
195
203
|
|
|
196
|
-
def fix_ipinfo_records(date):
|
|
204
|
+
def fix_ipinfo_records(date, cnd):
|
|
197
205
|
|
|
198
206
|
table = 'ipinfo'
|
|
199
|
-
cond = "adddate
|
|
207
|
+
cond = f"adddate {cnd} AND region IS NULL"
|
|
200
208
|
pgrecs = PgDBI.pgmget(table, 'ip', cond, PgLOG.LGEREX)
|
|
201
209
|
if not pgrecs: return 0
|
|
202
210
|
cnt = len(pgrecs['ip']) if pgrecs else 0
|
|
@@ -205,7 +213,7 @@ def fix_ipinfo_records(date):
|
|
|
205
213
|
if PgIPInfo.set_ipinfo(pgrecs['ip'][i]): mcnt +=1
|
|
206
214
|
|
|
207
215
|
s = 's' if cnt > 1 else ''
|
|
208
|
-
PgLOG.pglog("{}: {} of {} record{} updated
|
|
216
|
+
PgLOG.pglog(f"{table}: {mcnt} of {cnt} record{s} updated for adddate {cnd}", PgLOG.LOGWRN)
|
|
209
217
|
|
|
210
218
|
return mcnt
|
|
211
219
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
Usage: fillipinfo [-b] -t TableName [-N NumberDay] [-m YearMonths] [-y Years]
|
|
5
5
|
|
|
6
|
-
select option, -t and -m, -N or -y to run this application.
|
|
6
|
+
select option, -t and -d, -m, -N or -y to run this application.
|
|
7
7
|
|
|
8
8
|
- Option -b, log process information into logfile only;
|
|
9
9
|
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
- Option -N, fix usage info in recent NumberDay days;
|
|
15
15
|
|
|
16
|
+
- Option -d, fix usage info in given dates;
|
|
17
|
+
|
|
16
18
|
- Option -m, fix usage info in given months;
|
|
17
19
|
|
|
18
20
|
- Option -y, fix usage info in given years.
|
|
@@ -11,8 +11,8 @@ rda_python_metrics/fillcountry.py,sha256=7i5LNi3scRoyRCT6t7aeNTGKOpxzJ2mA9tnvUqj
|
|
|
11
11
|
rda_python_metrics/fillendtime.py,sha256=skZttlpoY19g0dGwqGQI8t_1YPPTPEXwg3EfNlfL90I,2533
|
|
12
12
|
rda_python_metrics/fillglobususage.py,sha256=ahz8XnnJdD_AbSYqJ34lWmDuzws_-SNmCR8QE20aovA,8539
|
|
13
13
|
rda_python_metrics/fillglobususage.usg,sha256=1GgmCP22IQZdADwL5Mmkz3v8Ws-G7U3teQ1AxRJfV_4,637
|
|
14
|
-
rda_python_metrics/fillipinfo.py,sha256=
|
|
15
|
-
rda_python_metrics/fillipinfo.usg,sha256=
|
|
14
|
+
rda_python_metrics/fillipinfo.py,sha256=w3IEyxFo8oVGWw8ILAr_GHZ4d8BOf1wWcChIp6OQAtk,6745
|
|
15
|
+
rda_python_metrics/fillipinfo.usg,sha256=YeCR58xGv0emqHUZ_9R977HrqaeBwbd6j5QRF2Lc7TA,702
|
|
16
16
|
rda_python_metrics/filloneorder.py,sha256=ADHbcKCDh9bJunnxYbkbjwU2QpC43hvGlLWaURHNxkg,5433
|
|
17
17
|
rda_python_metrics/filloneorder.usg,sha256=mtOySKx6-D4k2bbTcmi6cSYtINiycRyHQkHozi0CQu0,1466
|
|
18
18
|
rda_python_metrics/fillosdfusage.py,sha256=z62l7RtbcfnR84xn2ffQXq0cPfcBkvUciP3u6vb09JI,7855
|
|
@@ -44,9 +44,9 @@ rda_python_metrics/viewwebfile.py,sha256=HSMNkQQawonu6W3blV7g9UbJuNy9VAOn9COqgmj
|
|
|
44
44
|
rda_python_metrics/viewwebfile.usg,sha256=lTNi8Yu8BUJuExEDJX-vsJyWUSUIQTS-DiiBEVFo33s,10054
|
|
45
45
|
rda_python_metrics/viewwebusage.py,sha256=ES2lI8NaCeCpTGi94HU-cDRBxHMiUBbplyYsZf2KqF0,16650
|
|
46
46
|
rda_python_metrics/viewwebusage.usg,sha256=OVDZ78p87E3HLW34ZhasNJ7Zmw8XXjmZPPWZfRhPLXo,9936
|
|
47
|
-
rda_python_metrics-1.0.
|
|
48
|
-
rda_python_metrics-1.0.
|
|
49
|
-
rda_python_metrics-1.0.
|
|
50
|
-
rda_python_metrics-1.0.
|
|
51
|
-
rda_python_metrics-1.0.
|
|
52
|
-
rda_python_metrics-1.0.
|
|
47
|
+
rda_python_metrics-1.0.23.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
|
|
48
|
+
rda_python_metrics-1.0.23.dist-info/METADATA,sha256=FIeMLBkhmlMKHNmm7Uq74ipwiT6L-u4lTL5lVGl8AjI,761
|
|
49
|
+
rda_python_metrics-1.0.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
50
|
+
rda_python_metrics-1.0.23.dist-info/entry_points.txt,sha256=YfFLzlE3rdufSV471VsDnfYptnt1lR08aSrxPXlKqlY,1185
|
|
51
|
+
rda_python_metrics-1.0.23.dist-info/top_level.txt,sha256=aoBgbR_o70TP0QmMW0U6inRHYtfKld47OBmnWnLnDOs,19
|
|
52
|
+
rda_python_metrics-1.0.23.dist-info/RECORD,,
|
|
File without changes
|
{rda_python_metrics-1.0.21.dist-info → rda_python_metrics-1.0.23.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{rda_python_metrics-1.0.21.dist-info → rda_python_metrics-1.0.23.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|