Example #1
0
                      FROM at_least_3_ext as al31,
                           at_least_3_ext as al32,
                           followerships as f
                      WHERE al31.id = f.follower_id AND
                            f.followed_id = al32.id
                      UNION
                      SELECT al31.id
                      FROM at_least_3_ext as al31,
                           at_least_3_ext as al32,
                           followerships as f
                      WHERE al31.id = f.followed_id AND
                            f.follower_id = al32.id
                   """)
    v_users = [u[0] for u in cursor.fetchall()]
    u_to_i = Indexer(join(processed_data_dir, args.version, VU_TO_I_FN))
    u_to_i.clear()
    for u in v_users:
        tmp = u_to_i[u]
    u_to_i.save()
    cursor.execute("""DROP TABLE IF EXISTS {}_users""".format(args.version))
    cursor.execute("""CREATE TABLE {}_users
                      (id INTEGER PRIMARY KEY,
                       FOREIGN KEY (id) REFERENCES users)
                   """.format(args.version))
    cursor.executemany("""INSERT INTO {}_users (id) VALUES (%s)""".format(
                        args.version), ((u,) for u in v_users))

    #Get valid repositories
    cursor.execute("""SELECT DISTINCT nai.repository_id
                      FROM non_artefact_interests as nai,
                           {0}_users as u