Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
340
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
27
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
621c36c4
Commit
621c36c4
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Update migration script
parent
ae580462
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/migration/nighthike/7.js
+34
-10
34 additions, 10 deletions
tools/migration/nighthike/7.js
tools/migration/nighthike/8.js
+40
-0
40 additions, 0 deletions
tools/migration/nighthike/8.js
with
74 additions
and
10 deletions
tools/migration/nighthike/7.js
+
34
−
10
View file @
621c36c4
// for Node.js interpret
ation
// for Node.js interpret
const
Message
=
require
(
'
../../../built/models/
messaging-message
'
).
default
;
const
Post
=
require
(
'
../../../built/models/post
'
).
default
;
const
{
default
:
Post
}
=
require
(
'
../../../built/
api/
models/
post
'
)
;
const
{
default
:
zip
}
=
require
(
'
@prezzemolo/zip
'
)
const
html
=
require
(
'
../../../built/common/text/html
'
).
default
;
const
parse
=
require
(
'
../../../built/common/text/parse
'
).
default
;
Promise
.
all
([
Message
,
Post
].
map
(
async
model
=>
{
const
documents
=
await
model
.
find
();
return
Promise
.
all
(
documents
.
map
(({
_id
,
text
})
=>
model
.
update
(
_id
,
{
const
migrate
=
async
(
post
)
=>
{
const
result
=
await
Post
.
update
(
post
.
_id
,
{
$set
:
{
textHtml
:
html
(
parse
(
text
))
textHtml
:
post
.
text
?
html
(
parse
(
post
.
text
))
:
null
}
})));
})).
catch
(
console
.
error
).
then
(
process
.
exit
);
});
return
result
.
ok
===
1
;
}
async
function
main
()
{
const
count
=
await
Post
.
count
({});
const
dop
=
Number
.
parseInt
(
process
.
argv
[
2
])
||
5
const
idop
=
((
count
-
(
count
%
dop
))
/
dop
)
+
1
return
zip
(
1
,
async
(
time
)
=>
{
console
.
log
(
`
${
time
}
/
${
idop
}
`
)
const
doc
=
await
Post
.
find
({},
{
limit
:
dop
,
skip
:
time
*
dop
})
return
Promise
.
all
(
doc
.
map
(
migrate
))
},
idop
).
then
(
a
=>
{
const
rv
=
[]
a
.
forEach
(
e
=>
rv
.
push
(...
e
))
return
rv
})
}
main
().
then
(
console
.
dir
).
catch
(
console
.
error
)
This diff is collapsed.
Click to expand it.
tools/migration/nighthike/8.js
0 → 100644
+
40
−
0
View file @
621c36c4
// for Node.js interpret
const
{
default
:
Message
}
=
require
(
'
../../../built/api/models/message
'
);
const
{
default
:
zip
}
=
require
(
'
@prezzemolo/zip
'
)
const
html
=
require
(
'
../../../built/common/text/html
'
).
default
;
const
parse
=
require
(
'
../../../built/common/text/parse
'
).
default
;
const
migrate
=
async
(
message
)
=>
{
const
result
=
await
Message
.
update
(
message
.
_id
,
{
$set
:
{
textHtml
:
message
.
text
?
html
(
parse
(
message
.
text
))
:
null
}
});
return
result
.
ok
===
1
;
}
async
function
main
()
{
const
count
=
await
Message
.
count
({});
const
dop
=
Number
.
parseInt
(
process
.
argv
[
2
])
||
5
const
idop
=
((
count
-
(
count
%
dop
))
/
dop
)
+
1
return
zip
(
1
,
async
(
time
)
=>
{
console
.
log
(
`
${
time
}
/
${
idop
}
`
)
const
doc
=
await
Message
.
find
({},
{
limit
:
dop
,
skip
:
time
*
dop
})
return
Promise
.
all
(
doc
.
map
(
migrate
))
},
idop
).
then
(
a
=>
{
const
rv
=
[]
a
.
forEach
(
e
=>
rv
.
push
(...
e
))
return
rv
})
}
main
().
then
(
console
.
dir
).
catch
(
console
.
error
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment