Commit 56251341 authored by Knut Behrends's avatar Knut Behrends
Browse files

add src/ subdir with 3 js files

parent 470f8c60
#!/usr/bin/env node
"use strict"
var faker = require("faker")
var axios = require("axios")
var util = require("./fake-util")
// var randomName = faker.name.findName(); // Rowan Nikolaus
// var randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
// var randomCard = faker.util..createCard(); // random contact card containing many properties
faker.seed(112)
let mydate = faker.date.recent()
let curdate = faker.date.recent()
let mins = 0
let my_core_type = util.find_core_type()
let top_depth = 0.0
let max_temp = 12.0001
let barrel_length = 3
let core_diameter = "HQ"
let current_next_core_id = 7
let bottom_depth = 8.47
const instance = axios.create({
baseURL: "https://jet.rundis.com/",
timeout: 1000,
headers: { "Authorization": "Bearer cP9x6eOP3GQ9Qnqp03ky6oynglqR71ir" },
})
for (let i = 0; i < 300; i++) {
let row = {}
let drilled_length =
Math.round(
util.shuffle([1, 2, 2, 2, 3, 3, 3, 3]).pop() * Math.random() * 100,
2
) / 100
let recovered_length = util.frac_above(drilled_length) * drilled_length
row["core"] = i + current_next_core_id
if (typeof row["bottom_depth"]) {
row["top_depth"] = bottom_depth
} else {
row["top_depth"] = row["bottom_depth"]
}
row["hole_id"] = 2
row["analyst"] = util.shuffle(["KB", "CK", "KH"]).pop()
curdate = util.add_date_offset(curdate)
row["core_ondeck"] = util.find_core_on_deck(
curdate,
util.shuffle([23, 42, 66])
)
row["core_type"] = `${my_core_type}`
row["drilled_length"] = drilled_length
row["core_recovery"] = Math.round(recovered_length * 100, 2) / 100
row["bottom_depth"] = bottom_depth + row["core_recovery"]
top_depth = Math.round(row["bottom_depth"] * 100, 2) / 100
row["core_recovery_pc"] = Math.abs(
Math.round((recovered_length / drilled_length) * 100, 2) / 100
)
row["continuity"] = util
.shuffle([
"broken",
"continuous",
"continuous",
"continuous",
"rubble",
"fractures",
])
.pop()
row["last_section"] = util.shuffle([1, 2, 2, 2, 3, 4, 4]).pop()
row["core_catcher"] = 0
row["core_diameter"] = core_diameter
row["oriented"] = 0
row["core_loss_reason"] = util
.shuffle(["unknown", "fallback", "-", "-", "-", "-"])
.pop()
row["mcd_offset"] = 0
row["rqd_abundance"] = "abundant"
row["rqd_intensity"] = "intense"
max_temp +=
Math.random() < 0.005 ? Math.round(Math.random() * 100, 4) / 10000 : 0
row["temperature"] = max_temp
row["comments"] = faker.name.findName()
row["igsn"] = null
row["fluid_type"] = util
.shuffle(["salty", "fresh", "fresh", "fresh", "fresh", "fresh"])
.pop()
row["bit_type"] = Math.random() < 0.005 ? "new" : "used"
row["barrel_length"] = barrel_length
row["drillers_depth"] = row["bottom_depth"]
row["comments_2"] = "check drillers depth"
row["mcd_top_depth"] = parseInt(row["top_depth"])
row["methods_core"] = util
.shuffle([
["MSCL", "Core Section Scan"],
["MSCL", "Core Section Scan"],
["MSCL", "Core Section Scan"],
["MSCL"],
["Core Section Scan"],
])
.pop()
row["igsn_ukbgs"] = null
bottom_depth += drilled_length
/*
for (let [key, value] of Object.entries(row)) {
console.log(`${key}: ${value}`);
}*/
console.log(JSON.stringify(row))
/*
console.log(Object.values(row).map(_ => {
if( Number.parseFloat(_) || Number.parseInt(_) ){
return _
} else {
return `"${_}"`
}
}).join(", "))
*/
/*console.log(Object.entries (k, v).map((k, _) => {
if( Number.parseFloat(_) || Number.parseInt(_) ){
return _
} else {
return `"${_}"`
}
}).join(", "))*/
let endpoint = "/api/v1/form?name=core"
instance
.post(endpoint, row)
.then(function (response) {
console.log(response)
})
.catch(function (error) {
console.error(error)
})
//TODO: sleep for a few ms
}
#!/usr/bin/env node
"use strict"
var faker = require('faker')
var moment = require('moment')
var axios = require('axios')
// var randomName = faker.name.findName(); // Rowan Nikolaus
// var randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
// var randomCard = faker.helpers.createCard(); // random contact card containing many properties
faker.seed(112)
let mydate = faker.date.recent()
let mins = 0
let my_core_type = find_core_type()
let top_depth = 0.0
let max_temp = 12.0001
let barrel_length = 3
let core_diameter = "HQ"
let current_next_core_id = 7
let bottom_depth = 8.47
const instance = axios.create({
baseURL: 'https://jet.rundis.com/',
timeout: 1000,
headers: {"Authorization": "Bearer cP9x6eOP3GQ9Qnqp03ky6oynglqR71ir"}
});
let curdate = faker.date.recent()
for(let i = 0; i < 300; i++){
let endpoint = '/api/v1/form?name=core'
instance.post(endpoint, row)
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.error(error);
});
//TODO: sleep for a few ms
}
let faker = require("faker")
let moment = require("moment")
function shuffle(array) {
return array.sort(function (a, b) {
return 0.5 - Math.random()
})
}
function add_date_offset(dt, minutes = 0) {
return new Date(dt.getTime() + minutes * 60000)
}
function find_core_on_deck(curdate = faker.date.recent(), diff) {
curdate = add_date_offset(curdate, diff)
return moment(curdate).format("YYYY-MM-DD HH:mm:ss")
}
function find_core_type(
array = ["B", "H", "L", "M", "N", "O", "P", "R", "S", "T", "W", "X", "Z"]
) {
return shuffle(array).pop()
}
function frac_above(x, thresh = 0.5) {
return Math.round(Math.random() * 100, 2) / 100
}
module.exports = {
shuffle,
add_date_offset,
find_core_on_deck,
find_core_type,
frac_above,
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment