{"action":"created","comment":{"url":"https://api.github.com/repos/starteam/starcellbio_html/pulls/comments/30730360","id":30730360,"diff_hunk":"@@ -23,75 +23,73 @@ scb.components.MicroscopyModelFactory = function scb_components_MicroscopyModelF\n             var imgs = [];\n             var isFound = false;\n             var max;\n-            var index, slide_array, alreadySelected, number_of_comparisons;\n+            var index, alreadySelected, number_of_comparisons;\n+            var slide_array=[];\n             var parser = model.slide;\n \n-            if (parser.parser_simple){\n+            if (parser.parser_simple) {\n \n-\n-                    var micro_state = {\n-                        kind: function (str) {\n-                            return str == slide_type;\n-                        },\n-                        collection_id: function (str) {\n-                            return str == collection_id;\n-                        },\n-                        drug_id: function (str) {\n-                            return str == drug_id;\n-                        },\n-                        cell_line: function (str) {\n-                            return str == cell_line;\n-                        },\n-                        conditions: function (str) {\n-                            return str == conditions;\n+                var micro_state = {\n+                    kind: function (str) {\n+                        return str == slide_type;\n+                    },\n+                    collection_id: function (str) {\n+                        return str == collection_id;\n+                    },\n+                    drug_id: function (str) {\n+                        return str == drug_id;\n+                    },\n+                    cell_line: function (str) {\n+                        return str == cell_line;\n+                    },\n+                    conditions: function (str) {\n+                        return str == conditions;\n+                    }\n+                };\n+                _.each(parser.parser_simple, function (rule) {\n+                    var matches = true;\n+                    _.each(rule.match, function (property) {\n+                        if (micro_state[property]) {\n+                            matches &= micro_state[property](rule[property]);\n+                        } else {\n+                            console.info(\"UNDEFINED PROPERTY: \" + property);\n                         }\n-                    };\n-                    _.each(parser.parser_simple, function (rule) {\n-                            var matches = true;\n-                            _.each(rule.match, function (property) {\n-                                if (micro_state[property]) {\n-                            \t    matches &= micro_state[property](rule[property]);\n-                                }else {\n-                            \t    console.info(\"UNDEFINED PROPERTY: \" + property);\n+                    });\n+                    if (!isFound) {\n+                        if (matches) {\n+                            if (template.slide_parser) {\n+                                max = template.slide_parser[collection_id][slide_type][conditions].length;\n+                            } else {\n+                                max = rule.imgs_hash.length;\n+                            }\n+                            number_of_comparisons = 0;\n+                            do {\n+                                /*Math.random returns num in [0,1) so no need to worry about subtracting 1 from index*/\n+                                index = Math.floor(Math.random() * (max));\n+                                if (template.slide_parser) {\n+                                    slide_array = template.slide_parser[collection_id][slide_type][conditions][index];\n+                                } else {\n+                                    slide_array = [\n+                                        {hash: rule.imgs_hash[index]}\n+                                    ];\n                                 }\n-                            });\n-                            if(!isFound){\n-                                if(matches){\n-                                    if(collection_id == '%CELL_LINE%'){\n-                                        collection_id = cell_line;\n-                                    }\n-                                    if( scb.utils.isDefined(rule['use_collection_id'])){\n-                                        collection_id = rule['use_collection_id'];\n+\n+                                alreadySelected = false;\n+                                _.each(slide_array, function (x) {\n+                                    if (_.contains(hash_list, x.hash)) {\n+                                        alreadySelected = true;\n                                     }\n-                                    max = template.slide_parser[collection_id][slide_type][conditions].length;\n-                                    number_of_comparisons = 0;\n-                                    do{\n-                                        /*Math.random returns num in [0,1) so no need to worry about subtracting 1 from index*/\n-                                        index =  Math.floor(Math.random() * (max));\n-                                        slide_array = template.slide_parser[collection_id][slide_type][conditions][index];\n-                                        alreadySelected = false;\n-                                        _.each(slide_array, function(x){\n-                                            if(_.contains(hash_list, x.hash)) {\n-                                                alreadySelected = true;\n-                                            }\n-                                        });\n-                                        number_of_comparisons += 1;\n-                                    }while(alreadySelected && number_of_comparisons < max);\n-                                    imgs=slide_array;\n-                                    isFound = true;\n-                                }else{\n-                                    try {\n-                                        max = template.slide_parser['default']['Dye']['HnE'].length;\n-                                        index = Math.floor(Math.random() * (max));\n-                                        imgs = template.slide_parser['default']['Dye']['HnE'][index];\n-                                    } catch(e){}\n-\t\t\t\t\t\t\t\t}\n-\t\t\t\t\t\t\t}\n-\t\t\t\t\t});\n-\t\t\t\t\tstate.slides = imgs;\n-\t\t\t\t\tstate.slide_type = slide_type;\n-\t\t\t\t}\n-\t\t\telse if (parser.complex_parser){\n+                                });\n+                                number_of_comparisons += 1;\n+                            } while (alreadySelected && number_of_comparisons < max);\n+                            imgs = slide_array;\n+                            isFound = true;\n+                        }\n+                    }\n+                });\n+                state.slides = imgs;\n+                state.slide_type = slide_type;\n+            }else if (parser.complex_parser){","path":"html_app/components/MicroscopyModelFactory.js","position":133,"original_position":133,"commit_id":"2bae21b1223d8d7f2b7cbd0c6ffdb4fb3eae053b","original_commit_id":"2bae21b1223d8d7f2b7cbd0c6ffdb4fb3eae053b","user":{"login":"annagav","id":7574259,"avatar_url":"https://avatars.githubusercontent.com/u/7574259?v=3","gravatar_id":"","url":"https://api.github.com/users/annagav","html_url":"https://github.com/annagav","followers_url":"https://api.github.com/users/annagav/followers","following_url":"https://api.github.com/users/annagav/following{/other_user}","gists_url":"https://api.github.com/users/annagav/gists{/gist_id}","starred_url":"https://api.github.com/users/annagav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annagav/subscriptions","organizations_url":"https://api.github.com/users/annagav/orgs","repos_url":"https://api.github.com/users/annagav/repos","events_url":"https://api.github.com/users/annagav/events{/privacy}","received_events_url":"https://api.github.com/users/annagav/received_events","type":"User","site_admin":false},"body":"If you are talking about the code below, I plan on completely removing it soon.","created_at":"2015-05-20T18:00:26Z","updated_at":"2015-05-20T18:00:26Z","html_url":"https://github.com/starteam/starcellbio_html/pull/195#discussion_r30730360","pull_request_url":"https://api.github.com/repos/starteam/starcellbio_html/pulls/195","_links":{"self":{"href":"https://api.github.com/repos/starteam/starcellbio_html/pulls/comments/30730360"},"html":{"href":"https://github.com/starteam/starcellbio_html/pull/195#discussion_r30730360"},"pull_request":{"href":"https://api.github.com/repos/starteam/starcellbio_html/pulls/195"}}},"pull_request":{"url":"https://api.github.com/repos/starteam/starcellbio_html/pulls/195","id":35544347,"html_url":"https://github.com/starteam/starcellbio_html/pull/195","diff_url":"https://github.com/starteam/starcellbio_html/pull/195.diff","patch_url":"https://github.com/starteam/starcellbio_html/pull/195.patch","issue_url":"https://api.github.com/repos/starteam/starcellbio_html/issues/195","number":195,"state":"open","locked":false,"title":"microscopy: Removing slide_parser for Usability, NSF#3","user":{"login":"annagav","id":7574259,"avatar_url":"https://avatars.githubusercontent.com/u/7574259?v=3","gravatar_id":"","url":"https://api.github.com/users/annagav","html_url":"https://github.com/annagav","followers_url":"https://api.github.com/users/annagav/followers","following_url":"https://api.github.com/users/annagav/following{/other_user}","gists_url":"https://api.github.com/users/annagav/gists{/gist_id}","starred_url":"https://api.github.com/users/annagav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annagav/subscriptions","organizations_url":"https://api.github.com/users/annagav/orgs","repos_url":"https://api.github.com/users/annagav/repos","events_url":"https://api.github.com/users/annagav/events{/privacy}","received_events_url":"https://api.github.com/users/annagav/received_events","type":"User","site_admin":false},"body":"Changed microscopy model to contain the set of image hashes for each sample( or 'rule' that can identify a set of samples). Eliminated slide_parser.\r\n\r\nThe above changes were applied only to the following exercises: Microscopy Usability Test and NSF Exercise 3.","created_at":"2015-05-15T19:42:23Z","updated_at":"2015-05-20T18:00:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ae2d63a85e20fb76140a9a5d4899e8a3ff323039","assignee":{"login":"pdpinch","id":430126,"avatar_url":"https://avatars.githubusercontent.com/u/430126?v=3","gravatar_id":"","url":"https://api.github.com/users/pdpinch","html_url":"https://github.com/pdpinch","followers_url":"https://api.github.com/users/pdpinch/followers","following_url":"https://api.github.com/users/pdpinch/following{/other_user}","gists_url":"https://api.github.com/users/pdpinch/gists{/gist_id}","starred_url":"https://api.github.com/users/pdpinch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pdpinch/subscriptions","organizations_url":"https://api.github.com/users/pdpinch/orgs","repos_url":"https://api.github.com/users/pdpinch/repos","events_url":"https://api.github.com/users/pdpinch/events{/privacy}","received_events_url":"https://api.github.com/users/pdpinch/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/starteam/starcellbio_html/pulls/195/commits","review_comments_url":"https://api.github.com/repos/starteam/starcellbio_html/pulls/195/comments","review_comment_url":"https://api.github.com/repos/starteam/starcellbio_html/pulls/comments{/number}","comments_url":"https://api.github.com/repos/starteam/starcellbio_html/issues/195/comments","statuses_url":"https://api.github.com/repos/starteam/starcellbio_html/statuses/2bae21b1223d8d7f2b7cbd0c6ffdb4fb3eae053b","head":{"label":"annagav:feature/refactor_microscopy_parser","ref":"feature/refactor_microscopy_parser","sha":"2bae21b1223d8d7f2b7cbd0c6ffdb4fb3eae053b","user":{"login":"annagav","id":7574259,"avatar_url":"https://avatars.githubusercontent.com/u/7574259?v=3","gravatar_id":"","url":"https://api.github.com/users/annagav","html_url":"https://github.com/annagav","followers_url":"https://api.github.com/users/annagav/followers","following_url":"https://api.github.com/users/annagav/following{/other_user}","gists_url":"https://api.github.com/users/annagav/gists{/gist_id}","starred_url":"https://api.github.com/users/annagav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annagav/subscriptions","organizations_url":"https://api.github.com/users/annagav/orgs","repos_url":"https://api.github.com/users/annagav/repos","events_url":"https://api.github.com/users/annagav/events{/privacy}","received_events_url":"https://api.github.com/users/annagav/received_events","type":"User","site_admin":false},"repo":{"id":26652367,"name":"starcellbio_html","full_name":"annagav/starcellbio_html","owner":{"login":"annagav","id":7574259,"avatar_url":"https://avatars.githubusercontent.com/u/7574259?v=3","gravatar_id":"","url":"https://api.github.com/users/annagav","html_url":"https://github.com/annagav","followers_url":"https://api.github.com/users/annagav/followers","following_url":"https://api.github.com/users/annagav/following{/other_user}","gists_url":"https://api.github.com/users/annagav/gists{/gist_id}","starred_url":"https://api.github.com/users/annagav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annagav/subscriptions","organizations_url":"https://api.github.com/users/annagav/orgs","repos_url":"https://api.github.com/users/annagav/repos","events_url":"https://api.github.com/users/annagav/events{/privacy}","received_events_url":"https://api.github.com/users/annagav/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/annagav/starcellbio_html","description":"","fork":true,"url":"https://api.github.com/repos/annagav/starcellbio_html","forks_url":"https://api.github.com/repos/annagav/starcellbio_html/forks","keys_url":"https://api.github.com/repos/annagav/starcellbio_html/keys{/key_id}","collaborators_url":"https://api.github.com/repos/annagav/starcellbio_html/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/annagav/starcellbio_html/teams","hooks_url":"https://api.github.com/repos/annagav/starcellbio_html/hooks","issue_events_url":"https://api.github.com/repos/annagav/starcellbio_html/issues/events{/number}","events_url":"https://api.github.com/repos/annagav/starcellbio_html/events","assignees_url":"https://api.github.com/repos/annagav/starcellbio_html/assignees{/user}","branches_url":"https://api.github.com/repos/annagav/starcellbio_html/branches{/branch}","tags_url":"https://api.github.com/repos/annagav/starcellbio_html/tags","blobs_url":"https://api.github.com/repos/annagav/starcellbio_html/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/annagav/starcellbio_html/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/annagav/starcellbio_html/git/refs{/sha}","trees_url":"https://api.github.com/repos/annagav/starcellbio_html/git/trees{/sha}","statuses_url":"https://api.github.com/repos/annagav/starcellbio_html/statuses/{sha}","languages_url":"https://api.github.com/repos/annagav/starcellbio_html/languages","stargazers_url":"https://api.github.com/repos/annagav/starcellbio_html/stargazers","contributors_url":"https://api.github.com/repos/annagav/starcellbio_html/contributors","subscribers_url":"https://api.github.com/repos/annagav/starcellbio_html/subscribers","subscription_url":"https://api.github.com/repos/annagav/starcellbio_html/subscription","commits_url":"https://api.github.com/repos/annagav/starcellbio_html/commits{/sha}","git_commits_url":"https://api.github.com/repos/annagav/starcellbio_html/git/commits{/sha}","comments_url":"https://api.github.com/repos/annagav/starcellbio_html/comments{/number}","issue_comment_url":"https://api.github.com/repos/annagav/starcellbio_html/issues/comments{/number}","contents_url":"https://api.github.com/repos/annagav/starcellbio_html/contents/{+path}","compare_url":"https://api.github.com/repos/annagav/starcellbio_html/compare/{base}...{head}","merges_url":"https://api.github.com/repos/annagav/starcellbio_html/merges","archive_url":"https://api.github.com/repos/annagav/starcellbio_html/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/annagav/starcellbio_html/downloads","issues_url":"https://api.github.com/repos/annagav/starcellbio_html/issues{/number}","pulls_url":"https://api.github.com/repos/annagav/starcellbio_html/pulls{/number}","milestones_url":"https://api.github.com/repos/annagav/starcellbio_html/milestones{/number}","notifications_url":"https://api.github.com/repos/annagav/starcellbio_html/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/annagav/starcellbio_html/labels{/name}","releases_url":"https://api.github.com/repos/annagav/starcellbio_html/releases{/id}","created_at":"2014-11-14T18:45:00Z","updated_at":"2014-11-14T18:45:01Z","pushed_at":"2015-05-19T16:45:30Z","git_url":"git://github.com/annagav/starcellbio_html.git","ssh_url":"git@github.com:annagav/starcellbio_html.git","clone_url":"https://github.com/annagav/starcellbio_html.git","svn_url":"https://github.com/annagav/starcellbio_html","homepage":null,"size":316529,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"starteam:develop","ref":"develop","sha":"aefe180c5f1534b273301d11cd0cef44ec83e6e1","user":{"login":"starteam","id":2973496,"avatar_url":"https://avatars.githubusercontent.com/u/2973496?v=3","gravatar_id":"","url":"https://api.github.com/users/starteam","html_url":"https://github.com/starteam","followers_url":"https://api.github.com/users/starteam/followers","following_url":"https://api.github.com/users/starteam/following{/other_user}","gists_url":"https://api.github.com/users/starteam/gists{/gist_id}","starred_url":"https://api.github.com/users/starteam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starteam/subscriptions","organizations_url":"https://api.github.com/users/starteam/orgs","repos_url":"https://api.github.com/users/starteam/repos","events_url":"https://api.github.com/users/starteam/events{/privacy}","received_events_url":"https://api.github.com/users/starteam/received_events","type":"Organization","site_admin":false},"repo":{"id":7005293,"name":"starcellbio_html","full_name":"starteam/starcellbio_html","owner":{"login":"starteam","id":2973496,"avatar_url":"https://avatars.githubusercontent.com/u/2973496?v=3","gravatar_id":"","url":"https://api.github.com/users/starteam","html_url":"https://github.com/starteam","followers_url":"https://api.github.com/users/starteam/followers","following_url":"https://api.github.com/users/starteam/following{/other_user}","gists_url":"https://api.github.com/users/starteam/gists{/gist_id}","starred_url":"https://api.github.com/users/starteam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starteam/subscriptions","organizations_url":"https://api.github.com/users/starteam/orgs","repos_url":"https://api.github.com/users/starteam/repos","events_url":"https://api.github.com/users/starteam/events{/privacy}","received_events_url":"https://api.github.com/users/starteam/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/starteam/starcellbio_html","description":"","fork":false,"url":"https://api.github.com/repos/starteam/starcellbio_html","forks_url":"https://api.github.com/repos/starteam/starcellbio_html/forks","keys_url":"https://api.github.com/repos/starteam/starcellbio_html/keys{/key_id}","collaborators_url":"https://api.github.com/repos/starteam/starcellbio_html/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/starteam/starcellbio_html/teams","hooks_url":"https://api.github.com/repos/starteam/starcellbio_html/hooks","issue_events_url":"https://api.github.com/repos/starteam/starcellbio_html/issues/events{/number}","events_url":"https://api.github.com/repos/starteam/starcellbio_html/events","assignees_url":"https://api.github.com/repos/starteam/starcellbio_html/assignees{/user}","branches_url":"https://api.github.com/repos/starteam/starcellbio_html/branches{/branch}","tags_url":"https://api.github.com/repos/starteam/starcellbio_html/tags","blobs_url":"https://api.github.com/repos/starteam/starcellbio_html/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/starteam/starcellbio_html/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/starteam/starcellbio_html/git/refs{/sha}","trees_url":"https://api.github.com/repos/starteam/starcellbio_html/git/trees{/sha}","statuses_url":"https://api.github.com/repos/starteam/starcellbio_html/statuses/{sha}","languages_url":"https://api.github.com/repos/starteam/starcellbio_html/languages","stargazers_url":"https://api.github.com/repos/starteam/starcellbio_html/stargazers","contributors_url":"https://api.github.com/repos/starteam/starcellbio_html/contributors","subscribers_url":"https://api.github.com/repos/starteam/starcellbio_html/subscribers","subscription_url":"https://api.github.com/repos/starteam/starcellbio_html/subscription","commits_url":"https://api.github.com/repos/starteam/starcellbio_html/commits{/sha}","git_commits_url":"https://api.github.com/repos/starteam/starcellbio_html/git/commits{/sha}","comments_url":"https://api.github.com/repos/starteam/starcellbio_html/comments{/number}","issue_comment_url":"https://api.github.com/repos/starteam/starcellbio_html/issues/comments{/number}","contents_url":"https://api.github.com/repos/starteam/starcellbio_html/contents/{+path}","compare_url":"https://api.github.com/repos/starteam/starcellbio_html/compare/{base}...{head}","merges_url":"https://api.github.com/repos/starteam/starcellbio_html/merges","archive_url":"https://api.github.com/repos/starteam/starcellbio_html/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/starteam/starcellbio_html/downloads","issues_url":"https://api.github.com/repos/starteam/starcellbio_html/issues{/number}","pulls_url":"https://api.github.com/repos/starteam/starcellbio_html/pulls{/number}","milestones_url":"https://api.github.com/repos/starteam/starcellbio_html/milestones{/number}","notifications_url":"https://api.github.com/repos/starteam/starcellbio_html/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/starteam/starcellbio_html/labels{/name}","releases_url":"https://api.github.com/repos/starteam/starcellbio_html/releases{/id}","created_at":"2012-12-04T19:09:23Z","updated_at":"2015-05-07T16:10:07Z","pushed_at":"2015-05-19T18:52:11Z","git_url":"git://github.com/starteam/starcellbio_html.git","ssh_url":"git@github.com:starteam/starcellbio_html.git","clone_url":"https://github.com/starteam/starcellbio_html.git","svn_url":"https://github.com/starteam/starcellbio_html","homepage":null,"size":587936,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":84,"forks":6,"open_issues":84,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/starteam/starcellbio_html/pulls/195"},"html":{"href":"https://github.com/starteam/starcellbio_html/pull/195"},"issue":{"href":"https://api.github.com/repos/starteam/starcellbio_html/issues/195"},"comments":{"href":"https://api.github.com/repos/starteam/starcellbio_html/issues/195/comments"},"review_comments":{"href":"https://api.github.com/repos/starteam/starcellbio_html/pulls/195/comments"},"review_comment":{"href":"https://api.github.com/repos/starteam/starcellbio_html/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/starteam/starcellbio_html/pulls/195/commits"},"statuses":{"href":"https://api.github.com/repos/starteam/starcellbio_html/statuses/2bae21b1223d8d7f2b7cbd0c6ffdb4fb3eae053b"}}}}