load Hash List only when needed
This commit is contained in:
@@ -191,6 +191,7 @@ class RSSEntry:
|
|||||||
self._settings = {}
|
self._settings = {}
|
||||||
self.chatList = []
|
self.chatList = []
|
||||||
self.hashList = HashEntries(maxCount)
|
self.hashList = HashEntries(maxCount)
|
||||||
|
self.hashListLoaded = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def title(self) -> str:
|
def title(self) -> str:
|
||||||
|
|||||||
19
database.py
19
database.py
@@ -313,10 +313,6 @@ class database:
|
|||||||
for i2 in cur2:
|
for i2 in cur2:
|
||||||
temp2 = ChatEntry(i2, temp._settings)
|
temp2 = ChatEntry(i2, temp._settings)
|
||||||
temp.chatList.append(temp2)
|
temp.chatList.append(temp2)
|
||||||
cur3 = self._db.execute(
|
|
||||||
f"SELECT * FROM hashList WHERE id=? ORDER BY time;", (temp.id,))
|
|
||||||
for i3 in cur3:
|
|
||||||
temp.hashList.add(HashEntry(i3))
|
|
||||||
if len(temp.chatList) == 0:
|
if len(temp.chatList) == 0:
|
||||||
self.__removeRSSEntry(temp.id)
|
self.__removeRSSEntry(temp.id)
|
||||||
else:
|
else:
|
||||||
@@ -367,10 +363,23 @@ class database:
|
|||||||
return i[0]
|
return i[0]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def getRSSHashList(self, i: RSSEntry):
|
||||||
|
if i.hashListLoaded:
|
||||||
|
return True
|
||||||
|
with self._value_lock:
|
||||||
|
cur = self._db.execute("SELECT * FROM RSSList WHERE id = ?;", (i.id,))
|
||||||
|
if cur.rowcount == 0:
|
||||||
|
return False
|
||||||
|
cur = self._db.execute("SELECT * FROM hashList WHERE id = ?;", (i.id,))
|
||||||
|
for j in cur:
|
||||||
|
i.hashList.add(HashEntry(j))
|
||||||
|
i.hashListLoaded = True
|
||||||
|
return True
|
||||||
|
|
||||||
def getRSSList(self) -> Optional[List[RSSEntry]]:
|
def getRSSList(self) -> Optional[List[RSSEntry]]:
|
||||||
'''返回不带chatList和hashList的RSS列表'''
|
'''返回不带chatList和hashList的RSS列表'''
|
||||||
with self._value_lock:
|
with self._value_lock:
|
||||||
cur = self._db.execute(f'SELECT * FROM RSSList;')
|
cur = self._db.execute('SELECT * FROM RSSList;')
|
||||||
r = []
|
r = []
|
||||||
for i in cur:
|
for i in cur:
|
||||||
r.append(RSSEntry(i, self._main._setting.maxCount))
|
r.append(RSSEntry(i, self._main._setting.maxCount))
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ class RSSCheckerThread(Thread):
|
|||||||
def __loop(self):
|
def __loop(self):
|
||||||
for rss in self._main._db.getAllRSSList():
|
for rss in self._main._db.getAllRSSList():
|
||||||
if self.__needUpdate(rss) or self._main._commandLine.rebuildHashlist:
|
if self.__needUpdate(rss) or self._main._commandLine.rebuildHashlist:
|
||||||
|
if self._main._db.getRSSHashList(rss) is False:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
p = RSSParser()
|
p = RSSParser()
|
||||||
p.parse(rss.url, self._main._setting.RSSTimeout)
|
p.parse(rss.url, self._main._setting.RSSTimeout)
|
||||||
|
|||||||
Reference in New Issue
Block a user