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