<commit_before>#!/usr/bin/env ruby

require 'rubygems'
require 'jcron'
require 'json'

dbserver = 'couchdb'
dbport = 5984
db = 'jcron'
dburi = "/#{db}/"
viewuri = "#{dburi}/_design/cronview"

# Create DB
couch = Jcron::Couch.new(dbserver, dbport)
# put requires json content, but db server ignores this content anyway
nothing = {}
couch.put(dburi, nothing.to_json)

# Create View
view = {
  "_id" => "_design/cronview",
  "language" => "javascript",
  "views" =>
	{
	   "by_host" => {
	       "map" => "function(doc) { if (doc.host)  emit(doc.host, doc) }"
	   },
	   "by_runtime" => {
	       "map" => "function(doc) { if (doc.runtime)  emit(doc.runtime, doc) }"
	   },
	   "by_starttime" => {
	       "map" => "function(doc) { if (doc.starttime)  emit(doc.starttime, doc) }"
	   },
	   "by_endtime" => {
	       "map" => "function(doc) { if (doc.endtime)  emit(doc.endtime, doc) }"
	   },
	   "by_cmd" => {
	       "map" => "function(doc) { if (doc.cmd)  emit(doc.cmd, doc) }"
	   },
	   "by_exitcode" => {
	       "map" => "function(doc) { if (doc.exitcode)  emit(doc.exitcode, doc) }"
	   },
	   "by_cmd_keyword" => {
         "map" => "function(doc) { var stringarray = doc.cmd.split(/[^A-Z0-9\-_]+/i); for(var idx in stringarray) emit(stringarray[idx],doc); }"
     }
	}
}
couch.put(viewuri, view.to_json)<commit_msg>Fix dbname<commit_after>#!/usr/bin/env ruby

require 'rubygems'
require 'json'
require 'jcron'

dbserver = 'couchdb'
dbport = 5984
db = 'cron'
dburi = "/#{db}/"
viewuri = "#{dburi}/_design/cronview"

# Create DB
couch = Jcron::Couch.new(dbserver, dbport)
# put requires json content, but db server ignores this content anyway
nothing = {}
couch.put(dburi, nothing.to_json)

# Create View
view = {
  "_id" => "_design/cronview",
  "language" => "javascript",
  "views" =>
	{
	   "by_host" => {
	       "map" => "function(doc) { if (doc.host)  emit(doc.host, doc) }"
	   },
	   "by_runtime" => {
	       "map" => "function(doc) { if (doc.runtime)  emit(doc.runtime, doc) }"
	   },
	   "by_starttime" => {
	       "map" => "function(doc) { if (doc.starttime)  emit(doc.starttime, doc) }"
	   },
	   "by_endtime" => {
	       "map" => "function(doc) { if (doc.endtime)  emit(doc.endtime, doc) }"
	   },
	   "by_cmd" => {
	       "map" => "function(doc) { if (doc.cmd)  emit(doc.cmd, doc) }"
	   },
	   "by_exitcode" => {
	       "map" => "function(doc) { if (doc.exitcode)  emit(doc.exitcode, doc) }"
	   },
	   "by_cmd_keyword" => {
         "map" => "function(doc) { var stringarray = doc.cmd.split(/[^A-Z0-9\-_]+/i); for(var idx in stringarray) emit(stringarray[idx],doc); }"
     }
	}
}
couch.put(viewuri, view.to_json)
{'fraction_non_alphanumeric': 0.2036336109008327, 'fraction_numerical': 0.004542013626040878, 'mean_word_length': 3.041284403669725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, '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': '6394809', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1049, 'n_words': 200}