mirror of https://gitlab.com/bashrc2/epicyon
More efficient reading of tag index
parent
d4536a9dd8
commit
a30c1c1044
|
@ -76,6 +76,7 @@ def htmlHashTagSwarm(baseDir: str, actor: str, translate: {}) -> str:
|
||||||
currTime = datetime.utcnow()
|
currTime = datetime.utcnow()
|
||||||
daysSinceEpoch = (currTime - datetime(1970, 1, 1)).days
|
daysSinceEpoch = (currTime - datetime(1970, 1, 1)).days
|
||||||
daysSinceEpochStr = str(daysSinceEpoch) + ' '
|
daysSinceEpochStr = str(daysSinceEpoch) + ' '
|
||||||
|
daysSinceEpochStr2 = str(daysSinceEpoch - 1) + ' '
|
||||||
recently = daysSinceEpoch - 1
|
recently = daysSinceEpoch - 1
|
||||||
tagSwarm = []
|
tagSwarm = []
|
||||||
domainHistogram = {}
|
domainHistogram = {}
|
||||||
|
@ -99,8 +100,12 @@ def htmlHashTagSwarm(baseDir: str, actor: str, translate: {}) -> str:
|
||||||
hashTagName = f.split('.')[0]
|
hashTagName = f.split('.')[0]
|
||||||
if isBlockedHashtag(baseDir, hashTagName):
|
if isBlockedHashtag(baseDir, hashTagName):
|
||||||
continue
|
continue
|
||||||
if daysSinceEpochStr not in open(tagsFilename).read():
|
with open(tagsFilename, 'r') as fp:
|
||||||
continue
|
# only read one line, which saves time and memory
|
||||||
|
lastTag = fp.readline()
|
||||||
|
if not lastTag.startswith(daysSinceEpochStr):
|
||||||
|
if not lastTag.startswith(daysSinceEpochStr2):
|
||||||
|
continue
|
||||||
with open(tagsFilename, 'r') as tagsFile:
|
with open(tagsFilename, 'r') as tagsFile:
|
||||||
while True:
|
while True:
|
||||||
line = tagsFile.readline()
|
line = tagsFile.readline()
|
||||||
|
|
Loading…
Reference in New Issue