1
0
Fork 0

chore(backend): Disable mongo export script for now

This commit is contained in:
joostdecock 2023-05-19 11:29:51 +02:00
parent 2951f50ac8
commit 2c16f634a9

View file

@ -1,3 +1,4 @@
/*
import path from 'path'
import fs from 'fs'
import { PrismaClient } from '@prisma/client'
@ -7,15 +8,15 @@ import { verifyConfig } from '../src/config.mjs'
const config = verifyConfig()
/*
* Note: This is not intended to work for you
*
* This script imports a raw database dump of the current (v2)
* FreeSewing backend and writes it to JSON.
*
* This is not the kind of thing you should try to run yourself
* because for one thing you do not have a raw database dump
*/
//
// Note: This is not intended to work for you
//
// This script imports a raw database dump of the current (v2)
// FreeSewing backend and writes it to JSON.
//
// This is not the kind of thing you should try to run yourself
// because for one thing you do not have a raw database dump
//
// Dumped data folder
const dir = '/home/joost/'
@ -26,10 +27,10 @@ const file = 'freesewing-dump.json'
data = filterData(JSON.parse(fs.readFileSync(path.resolve(dir, file), { encoding: 'utf-8' })))
console.log(JSON.stringify(data, null, 2))
/*
* Only migrate user data if the user was active in the last 12 months
* Unless they are patrons. Keep patrons regardless coz patrons rock.
*/
//
// Only migrate user data if the user was active in the last 12 months
// Unless they are patrons. Keep patrons regardless coz patrons rock.
//
function filterData(data) {
let i = 0
const filtered = {
@ -65,18 +66,18 @@ function filterData(data) {
return filtered
}
/*
* Migrates role field
*/
//
// Migrates role field
//
function getRole(entry) {
if (entry.handle === 'joost') return 'admin'
if (entry.patron > 0) return 'patron'
return 'user'
}
/*
* Migrates consent field
*/
//
// Migrates consent field
//
function getConsent(entry) {
let consent = 0
if (entry.consent.profile) consent++
@ -85,9 +86,9 @@ function getConsent(entry) {
return consent
}
/*
* Migrates user entry
*/
//
// Migrates user entry
//
function migrateUser(entry) {
const now = Date.now()
const lastLogin = new Date(entry.time?.login || 0)
@ -120,9 +121,9 @@ function migrateUser(entry) {
}
}
/*
* Migrates person entry
*/
//
// Migrates person entry
//
function migratePerson(entry) {
return {
user: entry.user,
@ -137,9 +138,9 @@ function migratePerson(entry) {
}
}
/*
* Migrates pattern entry
*/
//
// Migrates pattern entry
//
function migratePattern(entry) {
return {
handle: entry.handle,
@ -152,12 +153,14 @@ function migratePattern(entry) {
}
}
/*
* Migrates subscriber entry
*/
//
// Migrates subscriber entry
//
function migrateSubscriber(entry) {
return {
createdAt: entry.created,
email: entry.email,
}
}
*/