<commit_before>import {Router} from 'express';

import SoundCloud from './SoundCloud.js';
import Soundcast from './Soundcast.js';
import CONSTANTS from './constants.js';


var router = Router();
export default router;

var soundCloud = new SoundCloud(CONSTANTS.CLIENT_ID);


router.get('/', function(req, res) {
  res.send('hello world');
});


router.get('/search', (req, res) => {
  var query = req.query.query;
  soundCloud.searchUsers(query)
    .then((data) => {
      res.send(data);
    })
    .catch(err => {
      console.log(err.stack);
    });
});


router.get('/soundcasts', (req, res) => {
  Soundcast
    .find({})
    .select('title userId regexString')
    .then((soundcasts) => {
      res.send(soundcasts);
    });
});


router.get('/soundcast', (req, res) => {
  var q = req.query;
  if (q.title && q.userId && q.regexString) {
    var options = {
      title: q.title,
      userId: q.userId,
      regexString: q.regexString
    };

    Soundcast
      .findOne(options)
      .then((soundcast) => {
        if (!soundcast) {
          soundcast = new Soundcast(options);
          return soundcast.save();
        }
        else return soundcast;
      })
      .then((soundcast) => {
        if (soundcast.needsUpdate()) return soundcast.update();
        else return soundcast;
      })
      .then((soundcast) => {
        res.send(soundcast);<commit_msg>oops, should have been XML<commit_after>import {Router} from 'express';

import SoundCloud from './SoundCloud.js';
import Soundcast from './Soundcast.js';
import CONSTANTS from './constants.js';


var router = Router();
export default router;

var soundCloud = new SoundCloud(CONSTANTS.CLIENT_ID);


router.get('/', function(req, res) {
  res.send('hello world');
});


router.get('/search', (req, res) => {
  var query = req.query.query;
  soundCloud.searchUsers(query)
    .then((data) => {
      res.send(data);
    })
    .catch(err => {
      console.log(err.stack);
    });
});


router.get('/soundcasts', (req, res) => {
  Soundcast
    .find({})
    .select('title userId regexString')
    .then((soundcasts) => {
      res.send(soundcasts);
    });
});


router.get('/soundcast', (req, res) => {
  var q = req.query;
  if (q.title && q.userId && q.regexString) {
    var options = {
      title: q.title,
      userId: q.userId,
      regexString: q.regexString
    };

    Soundcast
      .findOne(options)
      .then((soundcast) => {
        if (!soundcast) {
          soundcast = new Soundcast(options);
          return soundcast.save();
        }
        else return soundcast;
      })
      .then((soundcast) => {
        if (soundcast.needsUpdate()) return soundcast.update();
        else return soundcast;
      })
      .then((soundcast) => {
        res.set('Content-Type', 'application/xml').send(soundcast.toXml());
{'fraction_non_alphanumeric': 0.17163120567375886, 'fraction_numerical': 0.0, 'mean_word_length': 2.5982142857142856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '6762212', 'n_tokens_mistral': 921, 'n_tokens_neox': 912, 'n_words': 190}