Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
icdp-osg
mdis-datagen
Commits
380bed30
Commit
380bed30
authored
Aug 02, 2020
by
Knut Behrends
Browse files
JS linting: remove whitespace, semis
parent
bd6e5f21
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
src/classes/fake-lithology.js
View file @
380bed30
...
...
@@ -28,36 +28,37 @@ module.exports = class LithologyGeology {
return
this
.
_props
.
section_split_id
}
find_bottom_depth
()
{
const
b
=
util
.
round
((
this
.
top
+
this
.
interval
),
1
)
const
b
=
util
.
round
(
this
.
top
+
this
.
interval
,
1
)
this
.
_props
.
bottom_depth
=
b
return
b
}
find_top_depth
()
{
const
t
=
util
.
round
(
(
this
.
_section
.
top_depth
+
util
.
frac_below
(
0.3
)
*
(
this
.
_props
.
offset_m
)
//cm
)
,
1
)
const
t
=
util
.
round
(
this
.
_section
.
top_depth
+
util
.
frac_below
(
0.3
)
*
this
.
_props
.
offset_m
,
//cm
1
)
this
.
_props
.
top_depth
=
t
return
t
}
find_interval
()
{
const
sl
=
this
.
_props
.
interval_cm
const
sl
=
this
.
_props
.
interval_cm
const
minlen
=
0.03
*
(
sl
+
1
)
let
len
=
0
if
(
sl
<
10
){
if
(
sl
<
10
)
{
// allow larger pieces for smaller sections
len
=
sl
*
util
.
frac_above
(
0.3
)
}
else
{
len
=
sl
*
util
.
frac_below
(
0.2
)
}
const
int
=
util
.
round
(
(
minlen
+
len
)
,
1
)
this
.
_props
.
interval
=
int
const
int
=
util
.
round
(
minlen
+
len
,
1
)
this
.
_props
.
interval
=
int
return
int
}
find_analyst
()
{
...
...
@@ -82,9 +83,9 @@ module.exports = class LithologyGeology {
return
`core id:
${
this
.
_section
.
core_id
}
${
this
.
_props
.
remarks
}
`
}
find_color
()
{
return
util
.
round
(
faker
.
fake
(
"
{{random.color}}
"
)
)
return
util
.
round
(
faker
.
fake
(
"
{{random.color}}
"
))
}
fake
()
{
Object
.
keys
(
this
.
_props
).
forEach
((
property
)
=>
{
this
.
_props
[
property
]
=
this
[
property
]
...
...
@@ -93,10 +94,14 @@ module.exports = class LithologyGeology {
}
get
section_split_id
()
{
return
this
.
_props
.
section_split_id
?
this
.
_props
.
section_split_id
:
this
.
find_section_split_id
()
return
this
.
_props
.
section_split_id
?
this
.
_props
.
section_split_id
:
this
.
find_section_split_id
()
}
get
litho_unit
()
{
return
this
.
_props
.
litho_unit
?
this
.
_props
.
litho_unit
:
this
.
find_litho_unit
()
return
this
.
_props
.
litho_unit
?
this
.
_props
.
litho_unit
:
this
.
find_litho_unit
()
}
get
top_depth
()
{
return
this
.
_props
.
top_depth
?
this
.
_props
.
top_depth
:
this
.
find_top_depth
()
...
...
@@ -105,16 +110,22 @@ module.exports = class LithologyGeology {
return
this
.
_props
.
interval
?
this
.
_props
.
interval
:
this
.
find_interval
()
}
get
bottom_depth
()
{
return
this
.
_props
.
bottom_depth
?
this
.
_props
.
bottom_depth
:
this
.
find_bottom_depth
()
return
this
.
_props
.
bottom_depth
?
this
.
_props
.
bottom_depth
:
this
.
find_bottom_depth
()
}
get
rock_class
()
{
return
this
.
_props
.
rock_class
?
this
.
_props
.
rock_class
:
this
.
find_rock_class
()
return
this
.
_props
.
rock_class
?
this
.
_props
.
rock_class
:
this
.
find_rock_class
()
}
get
rock_type
()
{
return
this
.
_props
.
rock_type
?
this
.
_props
.
rock_type
:
this
.
find_rock_type
()
}
get
description
()
{
return
this
.
_props
.
description
?
this
.
_props
.
description
:
this
.
find_description
()
return
this
.
_props
.
description
?
this
.
_props
.
description
:
this
.
find_description
()
}
get
analyst
()
{
return
this
.
_props
.
analyst
?
this
.
_props
.
analyst
:
this
.
find_analyst
()
...
...
@@ -123,27 +134,36 @@ module.exports = class LithologyGeology {
return
this
.
_props
.
color
?
this
.
_props
.
color
:
this
.
find_color
()
}
get
composition
()
{
return
this
.
_props
.
composition
?
this
.
_props
.
composition
:
this
.
find_composition
()
return
this
.
_props
.
composition
?
this
.
_props
.
composition
:
this
.
find_composition
()
}
get
combined_id
()
{
return
this
.
_props
.
combined_id
?
this
.
_props
.
combined_id
:
this
.
find_combined_id
()
return
this
.
_props
.
combined_id
?
this
.
_props
.
combined_id
:
this
.
find_combined_id
()
}
get
mcd_top
()
{
return
this
.
_props
.
mcd_top
?
this
.
_props
.
mcd_top
:
this
.
find_mcd_top
()
}
get
mcd_top_depth_unit
()
{
return
this
.
_props
.
mcd_top_depth_unit
?
this
.
_props
.
mcd_top_depth_unit
:
this
.
find_mcd_top_depth_unit
()
return
this
.
_props
.
mcd_top_depth_unit
?
this
.
_props
.
mcd_top_depth_unit
:
this
.
find_mcd_top_depth_unit
()
}
get
mcd_bottom
()
{
return
this
.
_props
.
mcd_bottom
?
this
.
_props
.
mcd_bottom
:
this
.
find_mcd_bottom
()
return
this
.
_props
.
mcd_bottom
?
this
.
_props
.
mcd_bottom
:
this
.
find_mcd_bottom
()
}
get
mcd_bottom_unit
()
{
return
this
.
_props
.
mcd_bottom_unit
?
this
.
_props
.
mcd_bottom_unit
:
this
.
find_mcd_bottom_unit
()
return
this
.
_props
.
mcd_bottom_unit
?
this
.
_props
.
mcd_bottom_unit
:
this
.
find_mcd_bottom_unit
()
}
get
section_length
()
{
return
this
.
_props
.
section_length
?
this
.
_props
.
section_length
:
this
.
find_section_length
()
return
this
.
_props
.
section_length
?
this
.
_props
.
section_length
:
this
.
find_section_length
()
}
}
src/geology-inserter.js
View file @
380bed30
This diff is collapsed.
Click to expand it.
src/sample-inserter.js
View file @
380bed30
...
...
@@ -182,8 +182,8 @@ Promise.all(queries_map.values())
let
randsection
=
util
.
shuffle
(
Array
.
from
(
section_split_id_set
.
values
()))
.
pop
()
// This step might pick "untouchable" "A" section-splits for sampling,
// but that's okay. Correct manually later
// This step might pick "untouchable" "A" section-splits for sampling,
// but that's okay. Correct manually later
let
sections_split_ids
=
Array
.
of
(
randsection
-
Math
.
trunc
(
Math
.
random
()
*
10
),
randsection
,
...
...
@@ -209,20 +209,27 @@ Promise.all(queries_map.values())
})
.
then
(()
=>
{
let
curation_sample_columns
=
{}
axutil
.
get_columns
(
ax
,
"
curation_sample_2
"
)
axutil
.
get_columns
(
ax
,
"
curation_sample_2
"
)
.
then
((
curation_sample
)
=>
{
let
fake_sample_data
=
[]
let
i
=
0
for
(
let
s
of
scientists_by_city
.
values
())
{
// create an array of 0-10 requests per scientist,
// assign a few echo sections_split(s) "reserved" for this team
// create an array of 0-10 requests per scientist,
// assign a few echo sections_split(s) "reserved" for this team
// (usually there are only 1-2 splits for this team)
for
(
let
sp
of
s
.
split_section
){
let
n_picked
=
Number
.
parseInt
(
util
.
frac_below
(
0.666
)
*
s
.
requests
.
length
)
let
request_ids_per_city
=
util
.
shuffle
(
s
.
requests
).
slice
(
-
n_picked
)
for
(
let
sp
of
s
.
split_section
)
{
let
n_picked
=
Number
.
parseInt
(
util
.
frac_below
(
0.666
)
*
s
.
requests
.
length
)
let
request_ids_per_city
=
util
.
shuffle
(
s
.
requests
)
.
slice
(
-
n_picked
)
// ~ 5 requests for this split
for
(
let
r
of
request_ids_per_city
)
{
let
sec_len
=
sp
.
section_length
?
sp
.
section_length
:
util
.
round
(
util
.
frac_above
(
0.5
),
2
)
let
sec_len
=
sp
.
section_length
?
sp
.
section_length
:
util
.
round
(
util
.
frac_above
(
0.5
),
2
)
let
fake_sample
=
new
CurationSample
(
Object
.
assign
({},
curation_sample
,
{
request_id
:
r
.
request_id
,
...
...
@@ -231,16 +238,24 @@ Promise.all(queries_map.values())
scientist_2
:
r
.
scientist_2
,
scientist_3
:
r
.
scientist_3
,
section_split_id
:
sp
.
id
,
section_length_cm
:
util
.
round
(((
util
.
frac_below
(
0.1
)
*
sec_len
*
100
)
+
1
),
0
),
remarks
:
`SecId:
${
sp
.
section_id
}
, secLen
${
util
.
round
(
sp
.
section_length
,
1
)}
m`
,
sample_date
:
Array
.
of
(
r
.
completion_date
,
r
.
approval_date
,
r
.
request_date
,
util
.
date_between
()).
find
(
d
=>
d
!=
null
)
section_length_cm
:
util
.
round
(
util
.
frac_below
(
0.1
)
*
sec_len
*
100
+
1
,
0
),
remarks
:
`SecId:
${
sp
.
section_id
}
, secLen
${
util
.
round
(
sp
.
section_length
,
1
)}
m`
,
sample_date
:
Array
.
of
(
r
.
completion_date
,
r
.
approval_date
,
r
.
request_date
,
util
.
date_between
()
).
find
((
d
)
=>
d
!=
null
),
}),
sp
).
fake
()
fake_sample_data
.
push
(
Object
.
assign
({},
fake_sample
)
)
fake_sample_data
.
push
(
Object
.
assign
({},
fake_sample
))
i
++
}
}
...
...
@@ -253,12 +268,7 @@ Promise.all(queries_map.values())
})
.
then
((
fake_sample_data
)
=>
{
return
fake_sample_data
.
flat
().
map
((
fake_sample
,
i
)
=>
{
axutil
.
upload
(
ax
,
samples_post_url
,
fake_sample
,
i
)
axutil
.
upload
(
ax
,
samples_post_url
,
fake_sample
,
i
)
})
})
.
then
((
fake_request_promises
)
=>
...
...
@@ -269,9 +279,9 @@ Expedition ${options.expedition}: Tried to upload ${fake_request_promises.lengt
############################################################# `
)
)
)
})
})
.
catch
((
error
)
=>
console
.
dir
(
error
,
{
depth
:
0
}))
})
.
catch
((
error
)
=>
console
.
dir
(
error
,
{
depth
:
0
}))
function
str_sort_by_city
(
a
,
b
)
{
let
A
=
a
.
city
.
toUpperCase
()
...
...
@@ -296,39 +306,3 @@ function str_sort_by_site_hole(a, b) {
}
return
0
}
// return new Promise((resolve, reject) => {
// resolve(scientists)
// reject(scientists)
// })
// })
// .then((scientists) => {
// // create template object-literals for fake splits
// axutil
// .get_columns(ax, "sample_request")
// .
// .catch((error) => console.dir(error, { depth: 0 }))
// // .then((_) => {
// // // set 'sampling' attribute from '-' to 'Y', or similar
// // for (let s of suitable_sections) {
// // let url = `${api_url_frag}/${s.id}?name=split`
// // let put_data = {
// // sampleable: "",
// // remarks: `core ${options.expdition_id}`,
// // }
// // axutil.update_item(ax, url, put_data, s.id).then((updated) => {
// // console.log(
// // {
// // "'sampleable' is now:": `${updated?.data?.sampleable}`,
// // },
// // { [`id_${updated?.data?.combined_id}`]: updated?.data?.id }
// // )
// // })
// // }
// // })
// })
// })
// })
// .catch((error) => console.dir(error, { depth: 0 }))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment