<commit_before>import {Meteor} from 'meteor/meteor';
import React from 'react';
import {createContainer} from 'meteor/react-meteor-data';
import {Session} from 'meteor/session';
import _ from 'lodash';

import {buildGraph, distances} from '../src/graph';
import {Cards, Types, CardLinks} from '../src/collections';

import Card, {EditCard} from './card';
import {Grid, Card as CardPrimitive, List, Label} from './primitives';

import findJoined from '../src/find-joined';

const CardList = ({cards}) =>
	<Grid>
		{cards.map(card =>
			<Card
				key={card._id}
				card={card}
			/>
		)}
	</Grid>;

const CardColumnContainer = createContainer(({type}) => {
	const cards$ = Meteor.subscribe('cards.all');
	const links$ = Meteor.subscribe('cards.links');

	const selectedCard = Session.get('selectedCard');

	const links = findJoined(CardLinks, {
		type: type._id,
	});

	const graph = buildGraph(links);
	const d = distances(graph, selectedCard);

	const cards = links.map(link => link.cards[1]);

	cards.forEach(card => {
		card.distance = d[card._id] || Infinity;
	});

	return {
		cards: _.orderBy(cards, ['distance', 'title']),

		addCard(card) {
			Cards.insert(card, (err, added) => {
				if(err) return;

				CardLinks.insert({
					cards: [selectedCard, added],
					type: type._id,
				});
			});
		}
	};
}, ({cards, addCard}) => <List vertical>
	{cards.map(card => <Card key={card._id} card={card} />)}

	<CardPrimitive>
		<EditCard card={{}} saveCard={addCard} />
	</CardPrimitive>
</List>);

const CardColumns = ({types, selectedCard}) => <Grid>
	{selectedCard && <Card large card={selectedCard} />}<commit_msg>only show cards in column that are actually linked<commit_after>import {Meteor} from 'meteor/meteor';
import React from 'react';
import {createContainer} from 'meteor/react-meteor-data';
import {Session} from 'meteor/session';
import _ from 'lodash';

import {buildGraph, distances} from '../src/graph';
import {Cards, Types, CardLinks} from '../src/collections';

import Card, {EditCard} from './card';
import {Grid, Card as CardPrimitive, List, Label} from './primitives';

import findJoined from '../src/find-joined';

const CardList = ({cards}) =>
	<Grid>
		{cards.map(card =>
			<Card
				key={card._id}
				card={card}
			/>
		)}
	</Grid>;

const CardColumnContainer = createContainer(({type}) => {
	const cards$ = Meteor.subscribe('cards.all');
	const links$ = Meteor.subscribe('cards.links');

	const selectedCard = Session.get('selectedCard');

	const links = findJoined(CardLinks, {
		type: type._id,
	});

	const graph = buildGraph(links);
	const d = distances(graph, selectedCard);

	const cards = links.map(link => link.cards[1]);

	cards.forEach(card => {
		card.distance = d[card._id];
	});

	return {
		cards: _.orderBy(_.reject(cards, ['distance', undefined]), ['distance', 'title']),

		addCard(card) {
			Cards.insert(card, (err, added) => {
				if(err) return;

				CardLinks.insert({
					cards: [selectedCard, added],
					type: type._id,
				});
			});
		}
	};
}, ({cards, addCard}) => <List vertical>
	{cards.map(card => <Card key={card._id} card={card} />)}

	<CardPrimitive>
		<EditCard card={{}} saveCard={addCard} />
	</CardPrimitive>
</List>);

const CardColumns = ({types, selectedCard}) => <Grid>
	{selectedCard && <Card large card={selectedCard} />}
{'fraction_non_alphanumeric': 0.18564506359781952, 'fraction_numerical': 0.0006056935190793458, 'mean_word_length': 4.276357827476039, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 43, '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': '3994000', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1095, 'n_words': 267}