def getExploredJournals(uid, geo_info): journals = [] # get recommended place_ids place_ids = getRecommendedPlaces(uid, geo_info) conn = sqlite3.connect('traceshare_test.db') c = conn.cursor() # get public checkins with thoes place_ids checkin_set = set() for pid in place_ids: for cid in c.execute(GET_PUBLIC_CHECKINS_PID_EXPR, (str(pid), )): checkin_set.add(cid[0]) # get public journa_ids with thoes place_ids jid_set = set() for cid in checkin_set: for j in c.execute(GET_JOURNALS_FROM_CIDS_EXPR, (str(cid), )): jid_set.add(j[0]) # get public journals with thoes place_ids (get jid, time, name, desp, perm, uid) for jid in jid_set: for j in c.execute(GET_JOURNALS_EXPR, (jid, )): journal_info = {} journal_info['jid'] = j[0] journal_info['time'] = datetime.datetime.fromtimestamp(int( j[1])).strftime('%Y-%m-%d %H:%M:%S') journal_info['name'] = j[2] journal_info['desp'] = j[3] journal_info['perm'] = j[4] journal_info['uid'] = j[5] journals.append(journal_info) # get checkins in journal for journal_info in journals: journal_info['checkins'] = [] for cid in c.execute(GET_JOURNAL_CHECKINS_EXPR, (journal_info['jid'], )): checkin = {} checkin['cid'] = cid[0] journal_info['checkins'].append(checkin) # get place_id, lat, long of the checkins for journal_info in journals: for checkin in journal_info['checkins']: # get place_id c.execute(GET_CHECKIN_PLACEID_EXPR, (str(checkin['cid']), )) checkin['place_id'] = c.fetchone()[0] # get lat, long c.execute(GET_CHECKIN_LAT_LONG_EXPR, (str(checkin['place_id']), )) (checkin['lat'], checkin['long']) = c.fetchone() conn.close() return journals
def getExploredJournals(uid, geo_info): journals = [] # get recommended place_ids place_ids = getRecommendedPlaces(uid, geo_info) conn = sqlite3.connect('traceshare_test.db') c = conn.cursor() # get public checkins with thoes place_ids checkin_set = set() for pid in place_ids: for cid in c.execute(GET_PUBLIC_CHECKINS_PID_EXPR, (str(pid),)): checkin_set.add(cid[0]) # get public journa_ids with thoes place_ids jid_set = set() for cid in checkin_set: for j in c.execute(GET_JOURNALS_FROM_CIDS_EXPR, (str(cid),)): jid_set.add(j[0]) # get public journals with thoes place_ids (get jid, time, name, desp, perm, uid) for jid in jid_set: for j in c.execute(GET_JOURNALS_EXPR, (jid,)): journal_info = {} journal_info['jid'] = j[0] journal_info['time'] = datetime.datetime.fromtimestamp(int(j[1])).strftime('%Y-%m-%d %H:%M:%S') journal_info['name'] = j[2] journal_info['desp'] = j[3] journal_info['perm'] = j[4] journal_info['uid'] = j[5] journals.append(journal_info) # get checkins in journal for journal_info in journals: journal_info['checkins'] = [] for cid in c.execute(GET_JOURNAL_CHECKINS_EXPR, (journal_info['jid'],)): checkin = {} checkin['cid'] = cid[0] journal_info['checkins'].append(checkin) # get place_id, lat, long of the checkins for journal_info in journals: for checkin in journal_info['checkins']: # get place_id c.execute(GET_CHECKIN_PLACEID_EXPR, (str(checkin['cid']),)) checkin['place_id'] = c.fetchone()[0] # get lat, long c.execute(GET_CHECKIN_LAT_LONG_EXPR, (str(checkin['place_id']),)) (checkin['lat'], checkin['long']) = c.fetchone() conn.close() return journals
def getExploredPlaces(uid, geo_info): places = [] # get recommended place_ids place_ids = getRecommendedPlaces(uid, geo_info) conn = sqlite3.connect('traceshare_test.db') c = conn.cursor() # get public checkins with thoes place_ids (get cid, time) checkin_set = set() for pid in place_ids: for cid in c.execute(GET_PUBLIC_CHECKINS_PID_EXPR, (str(pid), )): checkin_set.add(cid[0]) for cid in checkin_set: place_info = {} c.execute(GET_CHECKIN_INFO_CID_EXPR, (str(cid), )) p = c.fetchone() place_info['cid'] = p[0] place_info['time'] = datetime.datetime.fromtimestamp(int( p[1])).strftime('%Y-%m-%d %H:%M:%S') place_info['place_id'] = p[2] places.append(place_info) # get place info for p in places: # get photo_url c.execute(GET_ONE_PHOTO_URL_EXPR, (str(p['cid']), )) p['photo_url'] = c.fetchone()[0] # get place name, lat, long c.execute(GET_PLACE_NAME_LAT_LONG_EXPR, (str(p['place_id'], ))) (p['place_name'], p['lat'], p['long']) = c.fetchone() conn.close() return places
def getExploredPlaces(uid, geo_info): places = [] # get recommended place_ids place_ids = getRecommendedPlaces(uid, geo_info) conn = sqlite3.connect('traceshare_test.db') c = conn.cursor() # get public checkins with thoes place_ids (get cid, time) checkin_set = set() for pid in place_ids: for cid in c.execute(GET_PUBLIC_CHECKINS_PID_EXPR, (str(pid),)): checkin_set.add(cid[0]) for cid in checkin_set: place_info = {} c.execute(GET_CHECKIN_INFO_CID_EXPR, (str(cid),)) p = c.fetchone() place_info['cid'] = p[0] place_info['time'] = datetime.datetime.fromtimestamp(int(p[1])).strftime('%Y-%m-%d %H:%M:%S') place_info['place_id'] = p[2] places.append(place_info) # get place info for p in places: # get photo_url c.execute(GET_ONE_PHOTO_URL_EXPR, (str(p['cid']),)) p['photo_url'] = c.fetchone()[0] # get place name, lat, long c.execute(GET_PLACE_NAME_LAT_LONG_EXPR, (str(p['place_id'],))) (p['place_name'], p['lat'], p['long']) = c.fetchone() conn.close() return places