<commit_before>import { createSelector } from 'reselect';
import d3 from 'd3';

const tasksSelector = state => state.tasks;

const getAllTasks = state => (
  // Sort by most recent
  state.allIds.map(id => state.byId[id])
    .sort((a, b) => b.value.updated - a.value.updated)
);

const getCompletedTasks = state => (
  getAllTasks(state)
    .filter(task => task.isCompleted)
);

const getActiveTasks = state => (
  getAllTasks(state)
    .filter(task => !task.isCompleted)
);

const getCurrentTask = state => (
  state.byId[state.currentId]
);

const getCurrentTaskId = state => (
  state.currentId
);

const getTaskSummary = state => (
  getCurrentTask(state).value.stats
);

const getTaskExtent = state => {
  const taskSummary = getTaskSummary(state);
  const createdAt = taskSummary.date * 1000;

  const dateFormat = d3.time.format('%Y-%m-%d');
  const fromDate = dateFormat(new Date(createdAt));
  const toDate = dateFormat(new Date());

  return { fromDate, toDate };
};

const TasksSelectors = {
  getAllTasks: createSelector(tasksSelector, getAllTasks),
  getCompletedTasks: createSelector(tasksSelector, getCompletedTasks),
  getActiveTasks: createSelector(tasksSelector, getActiveTasks),
  getCurrentTask: createSelector(tasksSelector, getCurrentTask),
  getCurrentTaskId: createSelector(tasksSelector, getCurrentTaskId),
  getTaskSummary: createSelector(tasksSelector, getTaskSummary),
  getTaskExtent: createSelector(tasksSelector, getTaskExtent),
};

export default TasksSelectors;<commit_msg>selector for the latest task id<commit_after>import { createSelector } from 'reselect';
import d3 from 'd3';

const tasksSelector = state => state.tasks;

const getAllTasks = state => (
  // Sort by most recent
  state.allIds.map(id => state.byId[id])
    .sort((a, b) => b.value.updated - a.value.updated)
);

const getLatestTaskId = state => {
  if (state.allIds.length !== 0) {
    return getAllTasks(state)[0].idtask;
  }
}

const getCompletedTasks = state => (
  getAllTasks(state)
    .filter(task => task.isCompleted)
);

const getActiveTasks = state => (
  getAllTasks(state)
    .filter(task => !task.isCompleted)
);

const getCurrentTask = state => (
  state.byId[state.currentId]
);

const getCurrentTaskId = state => (
  state.currentId
);

const getTaskSummary = state => (
  getCurrentTask(state).value.stats
);

const getTaskExtent = state => {
  const taskSummary = getTaskSummary(state);
  const createdAt = taskSummary.date * 1000;

  const dateFormat = d3.time.format('%Y-%m-%d');
  const fromDate = dateFormat(new Date(createdAt));
  const toDate = dateFormat(new Date());

  return { fromDate, toDate };
};

const TasksSelectors = {
  getAllTasks: createSelector(tasksSelector, getAllTasks),
  getLatestTaskId: createSelector(tasksSelector, getLatestTaskId),
  getCompletedTasks: createSelector(tasksSelector, getCompletedTasks),
  getActiveTasks: createSelector(tasksSelector, getActiveTasks),
  getCurrentTask: createSelector(tasksSelector, getCurrentTask),
  getCurrentTaskId: createSelector(tasksSelector, getCurrentTaskId),
  getTaskSummary: createSelector(tasksSelector, getTaskSummary),
  getTaskExtent: createSelector(tasksSelector, getTaskExtent),
};

export default TasksSelectors;
{'fraction_non_alphanumeric': 0.12263272275690779, 'fraction_numerical': 0.0049674014281279105, 'mean_word_length': 5.29296875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, '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': '5423977', 'n_tokens_mistral': 1004, 'n_tokens_neox': 989, 'n_words': 213}