-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport-pending.js
71 lines (61 loc) · 2.02 KB
/
import-pending.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import fs from 'fs'
import { TherapistPending } from './src/therapists/models.js'
const data = JSON.parse(fs.readFileSync("../holistia-scrapper/holistia.json"))
async function createTherapists() {
data.forEach(async d => {
const nameparts = d.name.split(" ")
const socials = d.socials.map(s => {
if(s.includes('instagram')) return { name: 'instagram', url: s }
if(s.includes('facebook')) return { name: 'facebook', url: s }
if(s.includes('youtube')) return { name: 'youtube', url: s }
if(s.includes('linkedin')) return { name: 'linkedin', url: s }
if(s.includes('skype')) return { name: 'skype', url: s }
if(s.includes('twitter')) return { name: 'twitter', url: s }
})
if(d.website) socials.push({ name: 'website', url: d.website })
const office = {
location: {
coordinates: d.latlng && d.latlng.map(s => Number(s)),
}
}
const timetable = d.timetable
let slug = ''
try {
slug = d.url.match('/therapeut/(.*)/')[1]
} catch {
return
}
const t = await TherapistPending.create({
slug,
name: d.name,
email: d.email,
phone: d.phone,
isCertified: true,
description: Buffer.from(d.description.join('\n'), 'utf8'),
languages: [d.language],
// photoUrl: `assets/uploads/therapists/holistia/${slug}.jpg`,
socials,
agreements: d['asca-rme'] ? ['ASCA', 'RME'] : [],
// paymentTypes: [String],
offices: [office],
address: d.address,
therapies: d.therapies.filter(d => d),
source: 'holistia',
language: d.language,
// timetable,
// symptoms: [{ type: mongoose.ObjectId, ref: Symptom }],
// "last-update": "29/09/2017",
// "therapies": ["Reiki"],
// "symptoms": [],
// "education": "",
// "baseline": "SwissReiki",
// "logo": "../../wp-content/uploads/2017/06/Coeur-SR.png"
})
console.log(t.slug)
})
}
async function init() {
await TherapistPending.deleteMany({})
await createTherapists()
}
init()