<commit_before>var http = require('http')
  , url = require('url')
  , qs = require('querystring')
  , github = require('octonode')
  , app = require("./app.js")
  , Q = require('q')
  , dao = require("./dao.js")

exports.initialize = function(app) {

var authURL = github.auth.config({
  id: process.env.GITHUB_OAUTH_ID,
  secret: process.env.GITHUB_OAUTH_SECRET,
  }).login(['user', 'repo', 'gist'])
var state = authURL.match(/&state=([0-9a-z]{32})/i);

app.get('/github/oauth/login', function *() {
	this.status = 301
	this.redirect(authURL)
})

app.get('/github/oauth/', function *(next) {
  var query = this.query;
 
  self = this
  yield function () {
  	var deferred = Q.defer()
    github.auth.login(query.code, function (err, token) {
        if (err) {
        	self.status = 403
        	self.body = "error"
          console.error(err)
        } else {
	        require("./app.js").setToken(token)
          client = github.client(token)
	        self.status = 301
          client.me().info(function(err, data, h) {
            console.log("receive user info")
            client.me().repos(data.login, function(err, repo, h) {
              console.log("recive user repositories")

              dao.mongo_connect().then(function(db) {
                db.collection('spm')
                  .insert(repo, function(err, result) {
                  })
              })
              self.redirect("/")
              deferred.resolve()
            })
          })
	        
    		}
    		
    	})
    return deferred.promise
  }()
  // }
})

}<commit_msg>修正collection名字<commit_after>var http = require('http')
  , url = require('url')
  , qs = require('querystring')
  , github = require('octonode')
  , app = require("./app.js")
  , Q = require('q')
  , dao = require("./dao.js")

exports.initialize = function(app) {

var authURL = github.auth.config({
  id: process.env.GITHUB_OAUTH_ID,
  secret: process.env.GITHUB_OAUTH_SECRET,
  }).login(['user', 'repo', 'gist'])
var state = authURL.match(/&state=([0-9a-z]{32})/i);

app.get('/github/oauth/login', function *() {
	this.status = 301
	this.redirect(authURL)
})

app.get('/github/oauth/', function *(next) {
  var query = this.query;
 
  self = this
  yield function () {
  	var deferred = Q.defer()
    github.auth.login(query.code, function (err, token) {
        if (err) {
        	self.status = 403
        	self.body = "error"
          console.error(err)
        } else {
	        require("./app.js").setToken(token)
          client = github.client(token)
	        self.status = 301
          client.me().info(function(err, data, h) {
            console.log("receive user info")
            client.me().repos(data.login, function(err, repo, h) {
              console.log("recive user repositories")

              dao.mongo_connect().then(function(db) {
                db.collection('user_repos')
                  .insert(repo, function(err, result) {
                  })
              })
              self.redirect("/")
              deferred.resolve()
            })
          })
	        
    		}
    		
    	})
    return deferred.promise
  }()
  // }
})

}
{'fraction_non_alphanumeric': 0.16751592356687897, 'fraction_numerical': 0.008280254777070064, 'mean_word_length': 2.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1724722', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1021, 'n_words': 174}