add find_feed_items method and rename get_feeds to find_feeds, get_user_feeds to find_user_feeds methods
This commit is contained in:
parent
49678a4d6b
commit
dc3889635e
13
database.py
13
database.py
|
@ -8,6 +8,7 @@ class Database():
|
|||
self.cur.execute('CREATE TABLE IF NOT EXISTS subscriptions (user_id INTEGER, feed_id INTEGER, FOREIGN KEY(user_id) REFERENCES users(id), FOREIGN KEY(feed_id) REFERENCES feeds(id))')
|
||||
self.cur.execute('CREATE UNIQUE INDEX IF NOT EXISTS subscriptions_index ON subscriptions (user_id, feed_id)')
|
||||
self.cur.execute('CREATE TABLE IF NOT EXISTS feeds_last_items (feed_id INTEGER, url TEXT NOT NULL UNIQUE, title TEXT, description TEXT, date NUMERIC, FOREIGN KEY(feed_id) REFERENCES feeds(id))')
|
||||
self.cur.execute('CREATE UNIQUE INDEX IF NOT EXISTS feed_item_index ON feeds_last_items (feed_id, date)')
|
||||
|
||||
def add_user(self, telegram_id: str) -> int:
|
||||
self.cur.execute('INSERT INTO users (telegram_id) VALUES (?)', [telegram_id])
|
||||
|
@ -38,16 +39,14 @@ class Database():
|
|||
self.cur.execute('DELETE FROM feeds WHERE id = ?', [feed_id])
|
||||
self.conn.commit()
|
||||
|
||||
def get_feeds(self) -> list:
|
||||
def find_feeds(self) -> list:
|
||||
self.cur.execute('SELECT * FROM feeds')
|
||||
return self.cur.fetchall()
|
||||
|
||||
def get_user_feeds(self, user_id: int) -> list:
|
||||
def find_user_feeds(self, user_id: int) -> list:
|
||||
self.cur.execute('SELECT * FROM feeds WHERE id IN (SELECT feed_id FROM subscriptions WHERE user_id = ?)', [user_id])
|
||||
return self.cur.fetchall()
|
||||
|
||||
def get_feed_items():
|
||||
pass
|
||||
|
||||
def storing_feed_content():
|
||||
pass
|
||||
def find_feed_items(self, feed_id: int) -> list:
|
||||
self.cur.execute('SELECT * FROM feeds_last_items WHERE feed_id = (?)', [feed_id])
|
||||
return self.cur.fetchall()
|
Loading…
Reference in a new issue