Skip to content

Commit

Permalink
Track who called in a correct answer
Browse files Browse the repository at this point in the history
Sets solved_by to whoever called in the answer and confirmed_by to whoever confirmed it.
  • Loading branch information
Torgen committed Jan 16, 2020
1 parent 42d9122 commit f429ebe
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 11 deletions.
17 changes: 16 additions & 1 deletion lib/methods/correctCallIn.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}
feedsInto: []
callin = model.CallIns.insert
Expand Down Expand Up @@ -71,7 +72,8 @@ describe 'correctCallIn', ->
touched: 7
touched_by: 'cjb'
solved: 7
solved_by: 'cjb'
solved_by: 'torgen'
confirmed_by: 'cjb'
tags: answer:
name: 'Answer'
value: 'precipitate'
Expand Down Expand Up @@ -119,6 +121,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}
incorrectAnswers: []
feedsInto: []
Expand All @@ -144,6 +147,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}
feedsInto: []
callin = model.CallIns.insert
Expand Down Expand Up @@ -175,6 +179,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}

it 'removes callin', ->
Expand Down Expand Up @@ -214,6 +219,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}

it 'removes callin', ->
Expand Down Expand Up @@ -254,6 +260,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}
incorrectAnswers: []
feedsInto: []
Expand All @@ -274,6 +281,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}
feedsInto: []
callin = model.CallIns.insert
Expand Down Expand Up @@ -305,6 +313,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}

it 'removes callin', ->
Expand Down Expand Up @@ -344,6 +353,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}

it 'removes callin', ->
Expand Down Expand Up @@ -384,6 +394,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}
incorrectAnswers: []
feedsInto: []
Expand All @@ -404,6 +415,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}
feedsInto: []
callin = model.CallIns.insert
Expand Down Expand Up @@ -435,6 +447,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}

it 'removes callin', ->
Expand Down Expand Up @@ -475,6 +488,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}

it 'removes callin', ->
Expand Down Expand Up @@ -516,6 +530,7 @@ describe 'correctCallIn', ->
touched_by: 'cscott'
solved: null
solved_by: null
confirmed_by: null
tags: {}
incorrectAnswers: []
feedsInto: []
Expand Down
9 changes: 7 additions & 2 deletions lib/methods/deleteAnswer.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe 'deleteAnswer', ->
touched_by: 'cjb'
solved: null
solved_by: null
confirmed_by: null
tags: status: {name: 'Status', value: 'stuck', touched: 2, touched_by: 'torgen'}
oplogs = model.Messages.find(room_name: 'oplog/0').fetch()
chai.assert.equal oplogs.length, 1
Expand All @@ -88,7 +89,8 @@ describe 'deleteAnswer', ->
touched: 2
touched_by: 'torgen'
solved: 2
solved_by: 'torgen'
solved_by: 'cjb'
confirmed_by: 'torgen'
tags:
answer: {name: 'Answer', value: 'foo', touched: 2, touched_by: 'torgen'}
temperature: {name: 'Temperature', value: '12', touched: 2, touched_by: 'torgen'}
Expand All @@ -104,6 +106,7 @@ describe 'deleteAnswer', ->
touched_by: 'cjb'
solved: null
solved_by: null
confirmed_by: null
tags: temperature: {name: 'Temperature', value: '12', touched: 2, touched_by: 'torgen'}
oplogs = model.Messages.find(room_name: 'oplog/0').fetch()
chai.assert.equal oplogs.length, 1
Expand All @@ -130,7 +133,8 @@ describe 'deleteAnswer', ->
touched: 2
touched_by: 'torgen'
solved: 2
solved_by: 'torgen'
solved_by: 'cjb'
confirmed_by: 'torgen'
tags:
answer: {name: 'Answer', value: 'foo', touched: 2, touched_by: 'torgen'}
backsolve: {name: 'Backsolve', value: 'yes', touched: 2, touched_by: 'torgen'}
Expand All @@ -147,6 +151,7 @@ describe 'deleteAnswer', ->
touched_by: 'cjb'
solved: null
solved_by: null
confirmed_by: null
tags: {}
oplogs = model.Messages.find(room_name: 'oplog/0').fetch()
chai.assert.equal oplogs.length, 1
Expand Down
24 changes: 20 additions & 4 deletions lib/methods/setAnswer.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe 'setAnswer', ->
touched_by: 'torgen'
solved: null
solved_by: null
confirmed_by: null
tags: technology: {name: 'Technology', value: 'Pottery', touched: 2, touched_by: 'torgen'}
it 'fails without login', ->
chai.assert.throws ->
Expand Down Expand Up @@ -66,6 +67,7 @@ describe 'setAnswer', ->
touched_by: 'cjb'
solved: 7
solved_by: 'cjb'
confirmed_by: 'cjb'
tags:
answer: {name: 'Answer', value: 'bar', touched: 7, touched_by: 'cjb'}
technology: {name: 'Technology', value: 'Pottery', touched: 2, touched_by: 'torgen'}
Expand Down Expand Up @@ -94,7 +96,8 @@ describe 'setAnswer', ->
touched: 2
touched_by: 'torgen'
solved: 2
solved_by: 'torgen'
solved_by: 'cscott'
confirmed_by: 'torgen'
tags:
answer: {name: 'Answer', value: 'qux', touched: 2, touched_by: 'torgen'}
technology:{name: 'Technology', value: 'Pottery', touched: 2, touched_by: 'torgen'}
Expand All @@ -116,6 +119,7 @@ describe 'setAnswer', ->
touched_by: 'cjb'
solved: 7
solved_by: 'cjb'
confirmed_by: 'cjb'
tags:
answer: {name: 'Answer', value: 'bar', touched: 7, touched_by: 'cjb'}
technology: {name: 'Technology', value: 'Pottery', touched: 2, touched_by: 'torgen'}
Expand Down Expand Up @@ -145,7 +149,8 @@ describe 'setAnswer', ->
touched: 2
touched_by: 'torgen'
solved: 2
solved_by: 'torgen'
solved_by: 'cscott'
confirmed_by: 'torgen'
tags:
answer: {name: 'Answer', value: 'bar', touched: 2, touched_by: 'torgen'}
technology: {name: 'Technology', value: 'Pottery', touched: 2, touched_by: 'torgen'}
Expand All @@ -166,7 +171,8 @@ describe 'setAnswer', ->
touched: 2
touched_by: 'torgen'
solved: 2
solved_by: 'torgen'
solved_by: 'cscott'
confirmed_by: 'torgen'
tags:
answer: {name: 'Answer', value: 'bar', touched: 2, touched_by: 'torgen'}
technology: {name: 'Technology', value: 'Pottery', touched: 2, touched_by: 'torgen'}
Expand All @@ -184,6 +190,7 @@ describe 'setAnswer', ->
touched_by: 'torgen'
solved: null
solved_by: null
confirmed_by: null
tags: status: {name: 'Status', value: 'stuck', touched: 2, touched_by: 'torgen'}
chai.assert.isTrue callAs 'setAnswer', 'cjb',
target: id
Expand All @@ -210,11 +217,13 @@ describe 'setAnswer', ->
touched_by: 'torgen'
solved: null
solved_by: null
confirmed_by: null
tags: {}
cid1 = model.CallIns.insert
target: id
name: 'Foo'
answer: 'bar'
callin_type: 'answer'
created: 5
created_by: 'codexbot'
submitted_to_hq: true
Expand All @@ -224,6 +233,7 @@ describe 'setAnswer', ->
target: id
name: 'Foo'
answer: 'qux'
callin_type: 'answer'
created: 5
created_by: 'codexbot'
submitted_to_hq: false
Expand All @@ -239,5 +249,11 @@ describe 'setAnswer', ->
it 'doesn\'t oplog for callins', ->
chai.assert.lengthOf model.Messages.find({room_name: 'oplog/0', type: 'callins'}).fetch(), 0

it "oplogs for puzzle", ->
it 'oplogs for puzzle', ->
chai.assert.lengthOf model.Messages.find({room_name: 'oplog/0', type: 'puzzles', id: id}).fetch(), 2

it 'sets solved_by correctly', ->
chai.assert.deepInclude model.Puzzles.findOne(id),
solved: 7
solved_by: 'codexbot'
confirmed_by: 'cjb'
5 changes: 5 additions & 0 deletions lib/model.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1201,8 +1201,12 @@ doc_id_to_link = (id) ->
updateDoc = $set:
solved: now
solved_by: @userId
confirmed_by: @userId
touched: now
touched_by: @userId
c = CallIns.findOne(target: id, callin_type: callin_types.ANSWER, answer: args.answer)
if c?
updateDoc.$set.solved_by = c.created_by
setTagInternal updateDoc,
name: 'Answer'
value: args.answer
Expand Down Expand Up @@ -1276,6 +1280,7 @@ doc_id_to_link = (id) ->
updateDoc = $set:
solved: null
solved_by: null
confirmed_by: null
touched: now
touched_by: @userId
deleteTagInternal updateDoc, 'answer'
Expand Down
12 changes: 8 additions & 4 deletions server/hubot-scripts/codex.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ describe 'codex hubot script', ->
touched: 7
touched_by: 'torgen'
solved: 7
confirmed_by: 'torgen'
tags: answer:
name: 'Answer'
value: 'linear abeja'
Expand All @@ -88,7 +89,8 @@ describe 'codex hubot script', ->
touched: 3
touched_by: 'cjb'
solved: 3
solved_by: 'cjb'
solved_by: 'cscott'
confirmed_by: 'cjb'
tags:
answer:
name: 'Answer'
Expand All @@ -100,7 +102,7 @@ describe 'codex hubot script', ->
room_name: 'puzzles/12345abcde'
timestamp: Date.now()
body: 'bot the answer to latino alphabet is linear abeja'
waitForDocument model.Puzzles, {_id: '12345abcde', solved_by: 'torgen'},
waitForDocument model.Puzzles, {_id: '12345abcde', solved_by: 'torgen', confirmed_by: 'torgen'},
touched: 7
touched_by: 'torgen'
solved: 7
Expand All @@ -117,7 +119,8 @@ describe 'codex hubot script', ->
canon: 'latino_alphabet'
feedsInto: []
solved: 3
solved_by: 'cjb'
solved_by: 'cscott'
confirmed_by: 'cjb'
touched: 3
touched_by: 'cjb'
tags:
Expand All @@ -139,7 +142,8 @@ describe 'codex hubot script', ->
touched: 3
touched_by: 'cjb'
solved: 3
solved_by: 'cjb'
solved_by: 'cscott'
confirmed_by: 'cjb'
tags: answer:
name: 'Answer'
value: 'linear abeja'
Expand Down

0 comments on commit f429ebe

Please sign in to comment.