Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting topic crashes Node #13

Open
mariusursache opened this issue May 18, 2015 · 9 comments
Open

Sorting topic crashes Node #13

mariusursache opened this issue May 18, 2015 · 9 comments

Comments

@mariusursache
Copy link

Tried sorting the 'random' topic with three triggers (*, hello*, are you *?), and got this error:

/Users/Me/projects/superscript-editor/node_modules/superscript/lib/topics/sort.js:19
    var match  = trig.input.match(/\{weight=(\d+)\}/i);
                     ^
TypeError: Cannot read property 'input' of null
    at Object.exports.sortTriggerSet (/Users/Me/projects/superscript-editor/node_modules/superscript/lib/topics/sort.js:19:22)
    at /Users/Me/projects/superscript-editor/node_modules/superscript/lib/topics/topic.js:70:26
    at /Users/Me/projects/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:240:13
    at done (/Users/Me/projects/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:128:19)
    at /Users/Me/projects/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:25:16
    at /Users/Me/projects/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:237:17
    at Promise.<anonymous> (/Users/Me/projects/superscript-editor/node_modules/superscript/lib/topics/topic.js:65:9)
    at Promise.<anonymous> (/Users/Me/projects/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
    at Promise.emit (events.js:95:17)
    at Promise.emit (/Users/Me/projects/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
    at Promise.fulfill (/Users/Me/projects/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
    at /Users/Me/projects/superscript-editor/node_modules/mongoose/lib/query.js:1406:13
    at model.Document.init (/Users/Me/projects/superscript-editor/node_modules/mongoose/lib/document.js:254:11)
    at completeOne (/Users/Me/projects/superscript-editor/node_modules/mongoose/lib/query.js:1404:10)
    at Object.cb (/Users/Me/projects/superscript-editor/node_modules/mongoose/lib/query.js:1158:11)
@mariusursache
Copy link
Author

As per #14, there are two suggestions for enhancement:

  • Auto-ordering which places the greediest trigger last
  • Allow manual ordering by drag& drop

@silentrob
Copy link
Owner

Drag and Drop topic gambits was pushed last night.

@mariusursache
Copy link
Author

Amazing. Can't wait to test it, this was a huge blocker for our project. Thanks a lot! 😀

@silentrob
Copy link
Owner

Oh great. Had I known you were blocked i would have made it a much higher priority. Sorry about that.

On May 31, 2015, at 11:19 AM, Marius Ursache [email protected] wrote:

Amazing. Can't wait to test it, this was a huge blocker for our project. Thanks a lot! 😀


Reply to this email directly or view it on GitHub.

@mariusursache
Copy link
Author

I tested the latest version are there are two issues:

  1. Topic sorting still crashes Node
  2. Manual sorting (drag & drop) only works in the interface. Updating the topic or refreshing the page sets the gambits in a predefined order which does not respect greediness (+ * is greedier than ? *).

Here's the console output for crash:

/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/lib/topics/sort.js:19
    var match  = trig.input.match(/\{weight=(\d+)\}/i);
                     ^
TypeError: Cannot read property 'input' of null
    at Object.exports.sortTriggerSet (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/lib/topics/sort.js:19:22)
    at /Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/lib/topics/topic.js:70:26
    at /Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:240:13
    at done (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:128:19)
    at /Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:25:16
    at /Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:237:17
    at Promise.<anonymous> (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/lib/topics/topic.js:65:9)
    at Promise.<anonymous> (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
    at Promise.emit (events.js:107:17)
    at Promise.emit (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
    at Promise.fulfill (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
    at /Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/lib/query.js:1406:13
    at model.Document.init (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/lib/document.js:254:11)
    at completeOne (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/lib/query.js:1404:10)
    at Immediate.cb (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/lib/query.js:1158:11)
    at Immediate._onImmediate (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/node_modules/mquery/lib/utils.js:137:16)```

Unfortunately, this does not allow us to create complex gambits/topics at this stage.

@silentrob
Copy link
Owner

Can you help me reproduce this.
First, let me explain how it should work now.

When you create gambits the newst ones always appear at the bottom (within a topic)
When you click Sort Topic We apply a algorithm to layer the most greedy gambits on the bottom bases on how many words and what types of wildcards.

If you apply a {weight=XX} it will create new group and order each gambit using the same algorithm but put them into a bucket.

If you use the drag and drop it will update them in real-time but note that his overide sort algorithm and force the order, and this is lost when you hit Sort Topic again.

If the order is not preserved it is most likely because the server crashed and was unable to update, which is indeed a bug.

@mariusursache
Copy link
Author

I reinstalled the superscript-editor node module, cleared the DB and it seems that the ordering / server crash happen in a specific case, reproducing it below:

  1. Create 3 gambits in random topic.
  2. Sorting (manually, automatically) works.
  3. Delete one of the gambits
  4. Gambit count still shows 3 gambits in topic table (but only two gambits in the topic page).

image
5. Sorting manually does not work (updating and refreshing the table keeps previous order)
6. Sorting automatically crashes node (see previous console log).

@silentrob
Copy link
Owner

Thanks for the steps. I will see if I can get to the bottom of it.

@mariusursache
Copy link
Author

This is a bit of a blocker in working with the editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants