Commit 7fce3f9b authored by Mindiell's avatar Mindiell

Issue #27: L'uri donnée peut commencer par http ou https, elle sera considérée comme unique.

parent 394a6205
......@@ -330,12 +330,23 @@ class Wantzel(object):
# Looking for such an article in database
cursor = get_cursor()
cursor.execute("SELECT id, note, provenance FROM presse WHERE url = %s", (url, ))
# We need to be able to retrieve an url with "http" or "https"
if url.startswith("https"):
url2 = "http" + url[5:]
else:
url2 = "https" + url[4:]
cursor.execute("""
SELECT id, note, provenance
FROM presse
WHERE url = %s
OR url = %s""",
(url, url2)
)
rows = cursor.fetchall()
if not rows:
Utils.debug("Adding an article by %s: %s" % (user, url))
cursor.execute(
"""INSERT INTO presse SET
cursor.execute("""
INSERT INTO presse SET
url=%s, provenance=%s, cite=%s, note=%s, datec=NOW(), title='',
lang='', published=0, nid=0, screenshot=0, fetched=0, seemscite=0
""",
......@@ -371,10 +382,18 @@ class Wantzel(object):
# Looking for such an article in database
cursor = get_cursor()
# We need to be able to retrieve an url with "http" or "https"
if url.startswith("https"):
url2 = "http" + url[5:]
else:
url2 = "https" + url[4:]
cursor.execute("""
SELECT cite, nid, note
FROM presse
WHERE url = %s""", (url, ))
WHERE url = %s
OR url = %s""",
(url, url2)
)
rows = cursor.fetchall()
if not rows:
self.send_message(channel, messages["status_unknown_article"] % user)
......@@ -407,7 +426,18 @@ class Wantzel(object):
return
# Looking for such an article in database
cursor = get_cursor()
cursor.execute("SELECT id, note FROM presse WHERE url=%s", (url, ))
# We need to be able to retrieve an url with "http" or "https"
if url.startswith("https"):
url2 = "http" + url[5:]
else:
url2 = "https" + url[4:]
cursor.execute("""
SELECT id, note
FROM presse
WHERE url = %s
OR url = %s""",
(url, url2)
)
rows = cursor.fetchall()
if not rows:
self.send_message(channel, messages["kill_none"] % url)
......@@ -431,8 +461,9 @@ class Wantzel(object):
notnull = 0
period_result = ""
for period in periods:
cursor.execute(
"""SELECT COUNT(id) AS cid FROM presse
cursor.execute("""
SELECT COUNT(id) AS cid
FROM presse
WHERE nid=0
AND datec>(NOW()-INTERVAL %s DAY)
AND note>=%s""",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment