mirror of
https://github.com/wassname/ray.git
synced 2026-09-10 12:38:43 +08:00
ci: Redo format.sh --all script & backfill lint fixes (#9956)
This commit is contained in:
@@ -9,7 +9,6 @@ import ray
|
||||
|
||||
@ray.remote
|
||||
class NewsServer(object):
|
||||
|
||||
def __init__(self):
|
||||
self.conn = sqlite3.connect("newsreader.db")
|
||||
c = self.conn.cursor()
|
||||
@@ -25,29 +24,36 @@ class NewsServer(object):
|
||||
items = []
|
||||
c = self.conn.cursor()
|
||||
for item in feed.items:
|
||||
items.append({"title": item.title,
|
||||
"link": item.link,
|
||||
"description": item.description,
|
||||
"description_text": item.description,
|
||||
"pubDate": str(item.pub_date)})
|
||||
c.execute("""INSERT INTO news (title, link, description,
|
||||
items.append({
|
||||
"title": item.title,
|
||||
"link": item.link,
|
||||
"description": item.description,
|
||||
"description_text": item.description,
|
||||
"pubDate": str(item.pub_date)
|
||||
})
|
||||
c.execute(
|
||||
"""INSERT INTO news (title, link, description,
|
||||
published, feed, liked) values
|
||||
(?, ?, ?, ?, ?, ?)""", (
|
||||
item.title, item.link, item.description,
|
||||
item.pub_date, feed.link, False))
|
||||
(?, ?, ?, ?, ?, ?)""",
|
||||
(item.title, item.link, item.description, item.pub_date,
|
||||
feed.link, False))
|
||||
self.conn.commit()
|
||||
|
||||
return {"channel": {"title": feed.title,
|
||||
"link": feed.link,
|
||||
"url": feed.link},
|
||||
"items": items}
|
||||
return {
|
||||
"channel": {
|
||||
"title": feed.title,
|
||||
"link": feed.link,
|
||||
"url": feed.link
|
||||
},
|
||||
"items": items
|
||||
}
|
||||
|
||||
def like_item(self, url, is_faved):
|
||||
c = self.conn.cursor()
|
||||
if is_faved:
|
||||
c.execute("UPDATE news SET liked = 1 WHERE link = ?", (url,))
|
||||
c.execute("UPDATE news SET liked = 1 WHERE link = ?", (url, ))
|
||||
else:
|
||||
c.execute("UPDATE news SET liked = 0 WHERE link = ?", (url,))
|
||||
c.execute("UPDATE news SET liked = 0 WHERE link = ?", (url, ))
|
||||
self.conn.commit()
|
||||
|
||||
|
||||
@@ -71,8 +77,9 @@ def dispatcher():
|
||||
result = ray.get(method.remote(*method_args))
|
||||
return jsonify(result)
|
||||
else:
|
||||
return jsonify(
|
||||
{"error": "method_name '" + method_name + "' not found"})
|
||||
return jsonify({
|
||||
"error": "method_name '" + method_name + "' not found"
|
||||
})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user