mawsitsit 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/mawsitsit/src/parser/manipulators.rs +20 -8
- data/lib/mawsitsit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 867a21589845a2651d16c5c86908df9f874cbc57e7ddd473ced0ac31c9fb94f6
|
|
4
|
+
data.tar.gz: ed926d39b4e8f5be4f7aa97438647ea6c5133ebb836ad94cdc44f8f7eef4bfa4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6b41088df4958a5455c001666ba612682d4d34a2cd357215e1236ff0ed9b79543db611b324b159601508e39c27917f8d21376df58c10da7c5aa561c8e6a86e5
|
|
7
|
+
data.tar.gz: e4e55eeddbf84e319d8719871e42c0322680dce69a93c85c7f88c1f3c41492238c9e6186482266d4e588bc4bcbb03bff97bd4487299697dd45df650aeee884e3
|
|
@@ -3,7 +3,7 @@ use serde_json::{Map, Value, json};
|
|
|
3
3
|
use std::collections::HashMap;
|
|
4
4
|
use serde_json::Value::Null;
|
|
5
5
|
use crate::parser::parser::JsonValue;
|
|
6
|
-
use super::utils::application_option::{parse_ashby_type, parse_lever_type};
|
|
6
|
+
use super::utils::application_option::{parse_ashby_type, parse_lever_type, QuestionType};
|
|
7
7
|
use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
|
|
8
8
|
|
|
9
9
|
pub enum EnumValue {
|
|
@@ -140,10 +140,11 @@ pub fn like_lever(_args: &Value) -> Value {
|
|
|
140
140
|
if let Some(Value::Array(arr)) = map.get("customQuestions") {
|
|
141
141
|
for value in arr {
|
|
142
142
|
if let Value::Object(map) = value {
|
|
143
|
+
let id = map.get("id").and_then(Value::as_str).unwrap_or("Unknown id");
|
|
143
144
|
if let Some(Value::Array(fields)) = map.get("fields") {
|
|
144
145
|
let mut num = 0;
|
|
145
146
|
for field in fields {
|
|
146
|
-
process_field(field, &mut new_appl, "customQuestions", Some(num));
|
|
147
|
+
process_field(field, &mut new_appl, "customQuestions", Some(id),Some(num), None);
|
|
147
148
|
num += 1;
|
|
148
149
|
}
|
|
149
150
|
}
|
|
@@ -154,7 +155,7 @@ pub fn like_lever(_args: &Value) -> Value {
|
|
|
154
155
|
if let Some(Value::Array(arr)) = map.get("personalInformation") {
|
|
155
156
|
for value in arr {
|
|
156
157
|
if let Value::Object(_) = value {
|
|
157
|
-
process_field(value, &mut new_appl, "personalInformation", None);
|
|
158
|
+
process_field(value, &mut new_appl, "personalInformation", None, None, None);
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
}
|
|
@@ -162,7 +163,7 @@ pub fn like_lever(_args: &Value) -> Value {
|
|
|
162
163
|
if let Some(Value::Array(arr)) = map.get("urls") {
|
|
163
164
|
for value in arr {
|
|
164
165
|
if let Value::Object(_) = value {
|
|
165
|
-
process_field(value, &mut new_appl, "urls", None);
|
|
166
|
+
process_field(value, &mut new_appl, "urls", None, None, Some(QuestionType::Link));
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
}
|
|
@@ -179,10 +180,18 @@ pub fn like_lever(_args: &Value) -> Value {
|
|
|
179
180
|
serde_json::Value::Array(new_appl)
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
fn process_field(value: &Value, new_appl: &mut Vec<serde_json::Value>, ext_prefix: &str, ext_suffix: Option<u32>) {
|
|
183
|
+
fn process_field(value: &Value, new_appl: &mut Vec<serde_json::Value>, ext_prefix: &str, ext: Option<&str>, ext_suffix: Option<u32>, force_type: Option<QuestionType>) {
|
|
183
184
|
let question = value.get("text").and_then(Value::as_str).unwrap_or("Unknown question");
|
|
184
185
|
let question_type = value.get("type").and_then(Value::as_str).unwrap_or("Unknown type");
|
|
185
|
-
let ext_id
|
|
186
|
+
let ext_id :String;
|
|
187
|
+
if let Some(ext) = ext {
|
|
188
|
+
ext_id = if let Some(suffix) = ext_suffix {
|
|
189
|
+
format!("lever__{}__{}__{}",ext_prefix, ext, suffix)
|
|
190
|
+
} else {
|
|
191
|
+
format!("lever__{}__{}",ext_prefix, ext)
|
|
192
|
+
};
|
|
193
|
+
} else {
|
|
194
|
+
ext_id = value.get("id").or_else(|| value.get("name"))
|
|
186
195
|
.and_then(Value::as_str)
|
|
187
196
|
.map(|s| {
|
|
188
197
|
if let Some(suffix) = ext_suffix {
|
|
@@ -192,14 +201,16 @@ fn process_field(value: &Value, new_appl: &mut Vec<serde_json::Value>, ext_prefi
|
|
|
192
201
|
}
|
|
193
202
|
})
|
|
194
203
|
.unwrap_or("Unknown question".to_string());
|
|
204
|
+
}
|
|
205
|
+
|
|
195
206
|
let required = value.get("required").and_then(Value::as_bool).unwrap_or(false);
|
|
196
207
|
let answer_options = value.get("options").and_then(Value::as_array).map(|array| {
|
|
197
208
|
array.iter().filter_map(|item| item.get("text").and_then(Value::as_str)).map(|s| s.to_string()).collect()
|
|
198
209
|
});
|
|
199
|
-
|
|
210
|
+
let question_type_to_use = force_type.unwrap_or_else(|| parse_lever_type(question_type).unwrap());
|
|
200
211
|
let app_option = ApplicationOption::new(
|
|
201
212
|
question.to_string(),
|
|
202
|
-
|
|
213
|
+
question_type_to_use,
|
|
203
214
|
Some(ext_id),
|
|
204
215
|
answer_options,
|
|
205
216
|
required,
|
|
@@ -208,6 +219,7 @@ fn process_field(value: &Value, new_appl: &mut Vec<serde_json::Value>, ext_prefi
|
|
|
208
219
|
new_appl.push(app_option.to_json());
|
|
209
220
|
}
|
|
210
221
|
|
|
222
|
+
|
|
211
223
|
fn process_eeo(map: &serde_json::Map<String, Value>, key: &str, new_appl: &mut Vec<serde_json::Value>) {
|
|
212
224
|
let question = map.get("text").and_then(Value::as_str).unwrap_or("Unknown question");
|
|
213
225
|
let question_type = map.get("type").and_then(Value::as_str).unwrap_or("Unknown type");
|
data/lib/mawsitsit/version.rb
CHANGED