<commit_before>/// <reference path="../../apis/registration.d.ts" />
import * as request from "request-promise-native";

interface IRegistrationOpts {
	url: string;
	key: string;
}

export class Registration {
	url: string;
	key: string;

	constructor(opts: IRegistrationOpts) {
		this.url = opts.url;
		this.key = new Buffer(opts.key).toString("base64");
	}

	async user(id: string, selection_set: string[]) {
		const vars = selection_set.map((_, i) => `$select_${i}`).join(" ");
		const var_map: {[selection: string]: string} = {};

		selection_set.forEach((selection, i, _) => {
			var_map[`$select_${i}`] = selection;
		}, {});

		const result = await this.query(`{
			user(id: $id) {
				${vars}
			}
		}`, var_map);
		return result.user;
	}

	async question_branches() {
		const result = await this.query(`{ question_branches }`);
		return result.question_branches;
	}<commit_msg>Temporary fix for querying registration users<commit_after>/// <reference path="../../apis/registration.d.ts" />
import * as request from "request-promise-native";

interface IRegistrationOpts {
	url: string;
	key: string;
}

export class Registration {
	url: string;
	key: string;

	constructor(opts: IRegistrationOpts) {
		this.url = opts.url;
		this.key = new Buffer(opts.key).toString("base64");
	}

	async user(id: string, selection_set: string[]) {
		let vars: string = selection_set.join(' ');

		const result = await this.query(`{
			user(id: "${id}") {
				${vars}
			}
		}`);
		return result.user;
	}

	async question_branches() {
		const result = await this.query(`{ question_branches }`);
		return result.question_branches;
	}
{'fraction_non_alphanumeric': 0.1687192118226601, 'fraction_numerical': 0.0024630541871921183, 'mean_word_length': 4.046583850931677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7531786', 'n_tokens_mistral': 588, 'n_tokens_neox': 546, 'n_words': 126}