Пример #1
0
 def get(self):
     table_name = "pdops.org"
     sql_query = "SELECT * FROM pdops.org_location"
     sql_cursor = getDatabaseCursor()
     sql_response = sql_cursor.executefetchall(sql_query)
     json = dumpjson({"brandLocation": sql_response})
     self.SendJson(json)
Пример #2
0
 def get(self):
     table_name = "pdops.org"
     sql_query = "SELECT org_id,name,category_ids,org_pic, description,  exclude_googlemap FROM " + table_name + " where featured like '%1%' order by name"
     sql_cursor = getDatabaseCursor()
     sql_response = sql_cursor.executefetchall(sql_query)
     json = dumpjson({"brandList": sql_response})
     self.SendJson(json)
Пример #3
0
 def get(self):
     authorid = int(self.request.params.get('author_id', None))
     res = getDatabaseCursor()
     r = res.executefetchone(
         "SELECT least(count(*)/40,1.0) as pctcomplete from (select distinct statement_id FROM pdops.incoming_author_reactions where author_id=%s) as a"
         % authorid)
     json = dumpjson({"reactionstats": r})
     self.SendJson(json)
Пример #4
0
 def get(self):
     opaquelink = self.requestParam("opaquelink")
     logging.info("Opaque link is %s" % opaquelink)
     partyid = getlink(opaquelink, "ppc2015", "party")
     res = getDatabaseCursor()
     r = res.executefetchall(
         "select * from incoming_party_reactions where party_id = %s" %
         partyid)
     json = dumpjson({"reactions": r})
     self.SendJson(json)
Пример #5
0
 def any(self, visitorid):
     logging.debug("Publish %s" % (visitorid))
     cur = getDatabaseCursor("research")
     res = cur.executefetchasdictlist(
         "select * from visitor_statement_reaction where visitor_id=" +
         str(visitorid))
     if len(res) == 0:
         return
     tab = maptoqfromobjlistordict(
         res, ("id", "visitor_id", "statement_id", "time", "reaction"),
         rename=("id", "person", "entity", "time", "reaction"))
     upd('feed', 'visitorstatementreaction', tab)
Пример #6
0
 def get(self):
     opaquelink = self.requestParam("opaquelink")
     logging.info("Opaque link is %s" % opaquelink)
     authorid = getlink(opaquelink, "ppc2015", "author")
     res = getDatabaseCursor()
     statements = res.executefetchall(
         "select statement from incoming_author_statements where author_id = %s"
         % authorid)
     if len(statements) == 0:
         return
     json = dumpjson(statements[-1])
     self.SendJson(json)
Пример #7
0
    def any(self):
        res = getDatabaseCursor()
        lastchangedid = memcacheclient.get("cmslatestchangeditemid")
        logging.info("Looking for changes beyond %s" % lastchangedid)
        if lastchangedid is None:  # pick up id from a week ago if none
            r = res.executefetchasdictlist(
                "select * from changed_items where last_changed < DATE_ADD(CURDATE(), INTERVAL - 7 DAY) ORDER BY last_changed DESC limit 10"
            )
            lastchangedid = r[0]["changed_id"]
        items = res.executefetchasdictlist(
            "select * from changed_items where changed_id > %s ORDER BY changed_id ASC limit 1000"
            % lastchangedid)
        allauthors = True
        for item in items:
            if item["name"] != "author":
                allauthors = False
        if allauthors:
            logging.info("Stopping authors waking us up since %s" %
                         lastchangedid)
            return

        currenttype = None
        lastsentid = None
        for item in items:
            name = item["name"]
            itemid = item["id"]
            changeid = item["changed_id"]
            if name in STATS:
                if (currenttype != None and currenttype != name) or (
                        lastsentid != None
                        and abs(itemid - lastsentid) > BATCHLIMIT):
                    recachenow(name.replace("_", ""),
                               id=itemid,
                               endid=lastsentid,
                               eventid=changeid)
                    lastchangedid = changeid
                    memcacheclient.set("cmslatestchangeditemid", lastchangedid)
                    lastsentid = None
                lastsentid = itemid
            else:
                recachenow(name.replace("_", ""), id=itemid, eventid=changeid)
                lastchangedid = changeid
                memcacheclient.set("cmslatestchangeditemid", lastchangedid)
            currenttype = name
        if lastsentid != None:
            recachenow(name.replace("_", ""),
                       id=itemid,
                       endid=lastsentid,
                       eventid=changeid)
            lastchangedid = changeid
            memcacheclient.set("cmslatestchangeditemid", lastchangedid)
        logging.info("Remembering last changed item was %s" % lastchangedid)
Пример #8
0
 def post(self):
     reaction = int(self.requestParam("reaction"))
     statementid = self.requestParam("statementid")
     comment = str(self.requestParam("comment"))
     visitorid = self.session.get("visitorid", None)
     source = "PositionDial comment"
     comment_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     sql_query = "INSERT INTO pdops.reaction_citation (reaction, statement_id, visitor_id,  origin, citation, made_date) VALUES (%s,%s,%s,\'%s\',\'%s\',\'%s\')" % (
         reaction, statementid, visitorid, source, comment, comment_date)
     logging.info(sql_query)
     sql_cursor = getDatabaseCursor()
     sql_response = sql_cursor.executefetchall(sql_query)
     logging.info("sql_response = %s", sql_response)
     json = dumpjson({"success": True})
     self.SendJson(json, expiry=1)
Пример #9
0
 def any(self):
     cursor = getDatabaseCursor()
     args = {'authorid':int(self.request.params.get("authorid", None)), 'statement': self.request.params.get("statement", None)}
     logging.debug(args)
     cursor.execute("INSERT INTO incoming_author_statements (author_id, statement) VALUES (%(authorid)s,%(statement)s)", args)
     pass
Пример #10
0
 def any(self):
     cursor = getDatabaseCursor()
     cursor.execute("INSERT INTO incoming_party_reactions (party_id, statement_id, reaction, asof) VALUES (%(partyid)s,%(statementid)s,%(reaction)s,%(when)s)", dict(self.request.params))
     pass