Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
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
RocketChat
Rocket.Chat
Commits
4c5669a9
Commit
4c5669a9
authored
9 years ago
by
Marcelo Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
Unsubscribe e-mails from CSV
parent
c28b36c2
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
private/node_scripts/unsubscribe_csv/package.json
+20
-0
20 additions, 0 deletions
private/node_scripts/unsubscribe_csv/package.json
private/node_scripts/unsubscribe_csv/unsubscribe.coffee
+33
-0
33 additions, 0 deletions
private/node_scripts/unsubscribe_csv/unsubscribe.coffee
with
53 additions
and
0 deletions
private/node_scripts/unsubscribe_csv/package.json
0 → 100644
+
20
−
0
View file @
4c5669a9
{
"name"
:
"unsubscribe_csv"
,
"version"
:
"0.0.1"
,
"private"
:
true
,
"scripts"
:
{
"start"
:
"coffee unsubscribe.coffee"
,
"test"
:
"mocha --compilers coffee:coffee-script --timeout 5s -R spec"
},
"dependencies"
:
{
"coffee-script"
:
"~1.6.3"
,
"commander"
:
"^2.9.0"
,
"ddp"
:
"^0.11.0"
,
"line-by-line"
:
"^0.1.3"
,
"line-reader"
:
"^0.2.4"
,
"moment"
:
"^2.10.2"
,
"mongodb"
:
"^2.1.0"
,
"underscore"
:
"^1.6.0"
,
"wait.for"
:
"^0.6.6"
}
}
This diff is collapsed.
Click to expand it.
private/node_scripts/unsubscribe_csv/unsubscribe.coffee
0 → 100644
+
33
−
0
View file @
4c5669a9
_
=
require
'underscore'
fs
=
require
(
'fs'
)
lineReader
=
require
(
'line-reader'
)
moment
=
require
(
'moment'
)
path
=
require
(
'path'
)
program
=
require
(
'commander'
)
wait
=
require
(
'wait.for'
)
MongoClient
=
require
(
'mongodb'
).
MongoClient
program
.
usage
'[options]'
.
option
'-v, --verbose'
,
'Verbose'
,
((
v
,
total
)
->
total
+
1
),
0
.
option
'-M, --mongo-db [mongo db]'
,
'Mongo DB'
,
'localhost:27017'
.
option
'-N, --db-name [db name]'
,
'DB Name'
,
'meteor'
.
on
'--help'
,
->
console
.
log
' Example:'
console
.
log
''
console
.
log
' $ coffee unsubscribe.coffee'
console
.
log
''
.
parse
process
.
argv
wait
.
launchFiber
->
db
=
wait
.
forMethod
MongoClient
,
'connect'
,
"mongodb://
#{
program
.
mongoDb
}
/
#{
program
.
dbName
}
"
,
{
replSet
:
{
socketOptions
:
{
connectTimeoutMS
:
300000
}
}
}
User
=
db
.
collection
'users'
lineReader
.
eachLine
'./unsubscribe.csv'
,
(
line
,
last
)
->
row
=
line
.
split
','
console
.
log
row
[
0
]
if
program
.
verbose
wait
.
launchFiber
->
updated
=
wait
.
forMethod
User
,
'update'
,
{
"emails.address"
:
row
[
0
]
},
{
$set
:
{
"mailer.unsubscribed"
:
true
}
}
if
last
process
.
exit
()
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