feat: add ci cd files dont edit those files
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
const User = require('../models/User')
|
||||
const News = require('../models/News')
|
||||
const Category = require('../models/Category')
|
||||
const fs = require('fs')
|
||||
|
||||
const minute = 1000 * 60
|
||||
const hour = minute * 60
|
||||
const day = hour * 24
|
||||
|
||||
module.exports = async () => {
|
||||
// check users for activation
|
||||
// setInterval(() => {
|
||||
// User.find({confirmed: false})
|
||||
// .then(users => {
|
||||
// if (users.length) {
|
||||
// ///////////////////////
|
||||
// users.forEach((item, index) => {
|
||||
// // item time and timeout
|
||||
// const itemTime = Date.parse(item.created_at)
|
||||
// const timeout = itemTime + day
|
||||
// ////////////////////////////
|
||||
// if (Date.now() >= timeout) {
|
||||
// item.remove()
|
||||
// }
|
||||
// if (index === users.length - 1) {
|
||||
// // console.log('Unconfirmed users deleted.')
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// .catch(err => {
|
||||
// console.log(err)
|
||||
// })
|
||||
// }, hour)
|
||||
|
||||
|
||||
// console.log('migration started ...')
|
||||
// try {
|
||||
// const rawFile = await fs.readFileSync(`./server/ostan_wp_posts.json`)
|
||||
// const parsedData = await JSON.parse(rawFile)
|
||||
//
|
||||
// // console.log(parsedData[0])
|
||||
//
|
||||
// const posts = []
|
||||
//
|
||||
// // dynamic
|
||||
// const rootParent = '60e95a43111ba696ea3d5171' // فرمانداری ها
|
||||
// const category = '60e95c7d111ba696ea3d5301' // فرماندای شهرستان خنداب
|
||||
//
|
||||
// // static
|
||||
// const creator = '60eaaf8db36930ef88d3d377'
|
||||
//
|
||||
// const newArray = []
|
||||
//
|
||||
// for await (const item of parsedData) {
|
||||
//
|
||||
// // console.log(item.post_type)
|
||||
// if (item.post_type === 'post' && posts.includes(item.ID) && item.post_status === 'publish') {
|
||||
// await newArray.push(item)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// console.log('-- posts length: ', newArray.length)
|
||||
//
|
||||
// let index = 0
|
||||
// for await (const item of newArray) {
|
||||
// const newPost = new News({
|
||||
// title: item.post_title,
|
||||
// shortTitlePanel: item.post_title,
|
||||
// shortTitleFront: item.post_title,
|
||||
// summaryTitle: item.post_title,
|
||||
// leadTitle: '',
|
||||
// shortSummaryTitle: item.post_title,
|
||||
// customDate: item.post_date,
|
||||
// /// ****************************************
|
||||
// catId: category,
|
||||
// /// ****************************************
|
||||
// allCat: [],
|
||||
// newsFileId: null,
|
||||
// /// ****************************************
|
||||
// rootParent: rootParent,
|
||||
// /// ****************************************
|
||||
// priority: false,
|
||||
// allowComment: false,
|
||||
// showInHome: false,
|
||||
// slider: false,
|
||||
// publish: true,
|
||||
// pageContent: item.post_content,
|
||||
// cover: null,
|
||||
// thumbCover: null,
|
||||
// userViews: 200,
|
||||
// special: false,
|
||||
// notifications: false,
|
||||
// _creator: creator,
|
||||
// _updatedBy: creator,
|
||||
// siteMap: true,
|
||||
// keywords: [],
|
||||
// metaTagDesc: item.post_title,
|
||||
// newsStatus: true,
|
||||
// modelType: 'ostandari',
|
||||
// attachments: [],
|
||||
// imported: true
|
||||
// })
|
||||
// await newPost.save()
|
||||
// if (index === newArray.length - 1) console.log('---- data entry finished')
|
||||
// index++
|
||||
// }
|
||||
//
|
||||
//
|
||||
// } catch (e) {
|
||||
// console.log('this is catch error --- ', e)
|
||||
// }
|
||||
|
||||
|
||||
// update all news
|
||||
|
||||
// try {
|
||||
// const news = await News.find()
|
||||
// const regex = new RegExp('/', 'g')
|
||||
// let index = 0
|
||||
// for await (const item of news) {
|
||||
// console.log(index)
|
||||
// item.title = item.title.replace(regex, ',')
|
||||
// await item.save()
|
||||
// if (index === news.length - 1) console.log('update finished')
|
||||
// index++
|
||||
//
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.log('-- this is catch error:', e)
|
||||
// }
|
||||
|
||||
|
||||
// update all categories
|
||||
|
||||
// try {
|
||||
// const categories = await Category.find()
|
||||
// // const regex = new RegExp('/', 'g')
|
||||
// let index = 0
|
||||
// for await (const item of categories) {
|
||||
// console.log(index)
|
||||
// // item.title = item.title.replace(regex, ',')
|
||||
// await item.save()
|
||||
// if (index === categories.length - 1) console.log('update finished')
|
||||
// index++
|
||||
//
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.log('-- this is catch error:', e)
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user