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
Pipeline #39 skipped
...@@ -330,12 +330,23 @@ class Wantzel(object): ...@@ -330,12 +330,23 @@ class Wantzel(object):
# Looking for such an article in database # Looking for such an article in database
cursor = get_cursor() 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() rows = cursor.fetchall()
if not rows: if not rows:
Utils.debug("Adding an article by %s: %s" % (user, url)) Utils.debug("Adding an article by %s: %s" % (user, url))
cursor.execute( cursor.execute("""
"""INSERT INTO presse SET INSERT INTO presse SET
url=%s, provenance=%s, cite=%s, note=%s, datec=NOW(), title='', url=%s, provenance=%s, cite=%s, note=%s, datec=NOW(), title='',
lang='', published=0, nid=0, screenshot=0, fetched=0, seemscite=0 lang='', published=0, nid=0, screenshot=0, fetched=0, seemscite=0
""", """,
...@@ -371,10 +382,18 @@ class Wantzel(object): ...@@ -371,10 +382,18 @@ class Wantzel(object):
# Looking for such an article in database # Looking for such an article in database
cursor = get_cursor() 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(""" cursor.execute("""
SELECT cite, nid, note SELECT cite, nid, note
FROM presse FROM presse
WHERE url = %s""", (url, )) WHERE url = %s
OR url = %s""",
(url, url2)
)
rows = cursor.fetchall() rows = cursor.fetchall()
if not rows: if not rows:
self.send_message(channel, messages["status_unknown_article"] % user) self.send_message(channel, messages["status_unknown_article"] % user)
...@@ -407,7 +426,18 @@ class Wantzel(object): ...@@ -407,7 +426,18 @@ class Wantzel(object):
return return
# Looking for such an article in database # Looking for such an article in database
cursor = get_cursor() 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() rows = cursor.fetchall()
if not rows: if not rows:
self.send_message(channel, messages["kill_none"] % url) self.send_message(channel, messages["kill_none"] % url)
...@@ -431,8 +461,9 @@ class Wantzel(object): ...@@ -431,8 +461,9 @@ class Wantzel(object):
notnull = 0 notnull = 0
period_result = "" period_result = ""
for period in periods: for period in periods:
cursor.execute( cursor.execute("""
"""SELECT COUNT(id) AS cid FROM presse SELECT COUNT(id) AS cid
FROM presse
WHERE nid=0 WHERE nid=0
AND datec>(NOW()-INTERVAL %s DAY) AND datec>(NOW()-INTERVAL %s DAY)
AND note>=%s""", 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