{"action":"created","comment":{"url":"https://api.github.com/repos/mozfr/transvision/pulls/comments/35778231","id":35778231,"diff_hunk":"@@ -403,4 +403,35 @@ public static function resultsTable($search_results, $recherche, $locale1, $loca\n \n         return $table;\n     }\n+\n+    /**\n+     * Search entity names: search full entity IDs (including path and filename),\n+     * then search entity names (without the full path) if there are no results.\n+     *\n+     * @param array  $source_strings Array of source strings\n+     * @param string $regex          Regular expression to search entity names\n+     *\n+     * @return array List of matching entity names\n+     */\n+    public static function searchEntities($source_strings, $regex)\n+    {\n+        // Search through the full entity ID\n+        $entities = preg_grep($regex, array_keys($source_strings));\n+\n+        /* If there are no results, search also through the entity names.\n+         * This is needed for \"perfect match\" when only the entity name is\n+         * provided.\n+         */\n+        if (! $entities) {\n+            $entity_names = [];\n+            foreach ($source_strings as $entity => $translation) {\n+                $entity_name = explode(\":\", $entity)[1];","path":"app/classes/Transvision/ShowResults.php","position":38,"original_position":38,"commit_id":"ebc84f308cb09ecc7fe0fa13f193645bccb3d0c9","original_commit_id":"ebc84f308cb09ecc7fe0fa13f193645bccb3d0c9","user":{"login":"pascalchevrel","id":454375,"avatar_url":"https://avatars.githubusercontent.com/u/454375?v=3","gravatar_id":"","url":"https://api.github.com/users/pascalchevrel","html_url":"https://github.com/pascalchevrel","followers_url":"https://api.github.com/users/pascalchevrel/followers","following_url":"https://api.github.com/users/pascalchevrel/following{/other_user}","gists_url":"https://api.github.com/users/pascalchevrel/gists{/gist_id}","starred_url":"https://api.github.com/users/pascalchevrel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pascalchevrel/subscriptions","organizations_url":"https://api.github.com/users/pascalchevrel/orgs","repos_url":"https://api.github.com/users/pascalchevrel/repos","events_url":"https://api.github.com/users/pascalchevrel/events{/privacy}","received_events_url":"https://api.github.com/users/pascalchevrel/received_events","type":"User","site_admin":false},"body":"single quotes","created_at":"2015-07-29T16:13:16Z","updated_at":"2015-07-29T16:13:16Z","html_url":"https://github.com/mozfr/transvision/pull/499#discussion_r35778231","pull_request_url":"https://api.github.com/repos/mozfr/transvision/pulls/499","_links":{"self":{"href":"https://api.github.com/repos/mozfr/transvision/pulls/comments/35778231"},"html":{"href":"https://github.com/mozfr/transvision/pull/499#discussion_r35778231"},"pull_request":{"href":"https://api.github.com/repos/mozfr/transvision/pulls/499"}}},"pull_request":{"url":"https://api.github.com/repos/mozfr/transvision/pulls/499","id":39448325,"html_url":"https://github.com/mozfr/transvision/pull/499","diff_url":"https://github.com/mozfr/transvision/pull/499.diff","patch_url":"https://github.com/mozfr/transvision/pull/499.patch","issue_url":"https://api.github.com/repos/mozfr/transvision/issues/499","number":499,"state":"open","locked":false,"title":"Improve search for entities","user":{"login":"flodolo","id":3644868,"avatar_url":"https://avatars.githubusercontent.com/u/3644868?v=3","gravatar_id":"","url":"https://api.github.com/users/flodolo","html_url":"https://github.com/flodolo","followers_url":"https://api.github.com/users/flodolo/followers","following_url":"https://api.github.com/users/flodolo/following{/other_user}","gists_url":"https://api.github.com/users/flodolo/gists{/gist_id}","starred_url":"https://api.github.com/users/flodolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flodolo/subscriptions","organizations_url":"https://api.github.com/users/flodolo/orgs","repos_url":"https://api.github.com/users/flodolo/repos","events_url":"https://api.github.com/users/flodolo/events{/privacy}","received_events_url":"https://api.github.com/users/flodolo/received_events","type":"User","site_admin":false},"body":"* Search also in entity names if search on full entity fails (useful for \"perfect match\")\r\n* Don't display the table header if there are no results\r\n\r\nImpact in terms of performance is small, since we search through entity names only when the first search fails.\r\n\r\nFixes #497 ","created_at":"2015-07-08T07:23:09Z","updated_at":"2015-07-29T16:13:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fae58e9e6910c0d2d17fec77a05b0fcfaf61a39d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozfr/transvision/pulls/499/commits","review_comments_url":"https://api.github.com/repos/mozfr/transvision/pulls/499/comments","review_comment_url":"https://api.github.com/repos/mozfr/transvision/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozfr/transvision/issues/499/comments","statuses_url":"https://api.github.com/repos/mozfr/transvision/statuses/ebc84f308cb09ecc7fe0fa13f193645bccb3d0c9","head":{"label":"flodolo:entities","ref":"entities","sha":"ebc84f308cb09ecc7fe0fa13f193645bccb3d0c9","user":{"login":"flodolo","id":3644868,"avatar_url":"https://avatars.githubusercontent.com/u/3644868?v=3","gravatar_id":"","url":"https://api.github.com/users/flodolo","html_url":"https://github.com/flodolo","followers_url":"https://api.github.com/users/flodolo/followers","following_url":"https://api.github.com/users/flodolo/following{/other_user}","gists_url":"https://api.github.com/users/flodolo/gists{/gist_id}","starred_url":"https://api.github.com/users/flodolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flodolo/subscriptions","organizations_url":"https://api.github.com/users/flodolo/orgs","repos_url":"https://api.github.com/users/flodolo/repos","events_url":"https://api.github.com/users/flodolo/events{/privacy}","received_events_url":"https://api.github.com/users/flodolo/received_events","type":"User","site_admin":false},"repo":{"id":10496440,"name":"transvision","full_name":"flodolo/transvision","owner":{"login":"flodolo","id":3644868,"avatar_url":"https://avatars.githubusercontent.com/u/3644868?v=3","gravatar_id":"","url":"https://api.github.com/users/flodolo","html_url":"https://github.com/flodolo","followers_url":"https://api.github.com/users/flodolo/followers","following_url":"https://api.github.com/users/flodolo/following{/other_user}","gists_url":"https://api.github.com/users/flodolo/gists{/gist_id}","starred_url":"https://api.github.com/users/flodolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flodolo/subscriptions","organizations_url":"https://api.github.com/users/flodolo/orgs","repos_url":"https://api.github.com/users/flodolo/repos","events_url":"https://api.github.com/users/flodolo/events{/privacy}","received_events_url":"https://api.github.com/users/flodolo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/flodolo/transvision","description":"Transvision python and php source code","fork":true,"url":"https://api.github.com/repos/flodolo/transvision","forks_url":"https://api.github.com/repos/flodolo/transvision/forks","keys_url":"https://api.github.com/repos/flodolo/transvision/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flodolo/transvision/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flodolo/transvision/teams","hooks_url":"https://api.github.com/repos/flodolo/transvision/hooks","issue_events_url":"https://api.github.com/repos/flodolo/transvision/issues/events{/number}","events_url":"https://api.github.com/repos/flodolo/transvision/events","assignees_url":"https://api.github.com/repos/flodolo/transvision/assignees{/user}","branches_url":"https://api.github.com/repos/flodolo/transvision/branches{/branch}","tags_url":"https://api.github.com/repos/flodolo/transvision/tags","blobs_url":"https://api.github.com/repos/flodolo/transvision/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flodolo/transvision/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flodolo/transvision/git/refs{/sha}","trees_url":"https://api.github.com/repos/flodolo/transvision/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flodolo/transvision/statuses/{sha}","languages_url":"https://api.github.com/repos/flodolo/transvision/languages","stargazers_url":"https://api.github.com/repos/flodolo/transvision/stargazers","contributors_url":"https://api.github.com/repos/flodolo/transvision/contributors","subscribers_url":"https://api.github.com/repos/flodolo/transvision/subscribers","subscription_url":"https://api.github.com/repos/flodolo/transvision/subscription","commits_url":"https://api.github.com/repos/flodolo/transvision/commits{/sha}","git_commits_url":"https://api.github.com/repos/flodolo/transvision/git/commits{/sha}","comments_url":"https://api.github.com/repos/flodolo/transvision/comments{/number}","issue_comment_url":"https://api.github.com/repos/flodolo/transvision/issues/comments{/number}","contents_url":"https://api.github.com/repos/flodolo/transvision/contents/{+path}","compare_url":"https://api.github.com/repos/flodolo/transvision/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flodolo/transvision/merges","archive_url":"https://api.github.com/repos/flodolo/transvision/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flodolo/transvision/downloads","issues_url":"https://api.github.com/repos/flodolo/transvision/issues{/number}","pulls_url":"https://api.github.com/repos/flodolo/transvision/pulls{/number}","milestones_url":"https://api.github.com/repos/flodolo/transvision/milestones{/number}","notifications_url":"https://api.github.com/repos/flodolo/transvision/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flodolo/transvision/labels{/name}","releases_url":"https://api.github.com/repos/flodolo/transvision/releases{/id}","created_at":"2013-06-05T06:32:12Z","updated_at":"2015-05-05T11:36:42Z","pushed_at":"2015-07-29T13:36:59Z","git_url":"git://github.com/flodolo/transvision.git","ssh_url":"git@github.com:flodolo/transvision.git","clone_url":"https://github.com/flodolo/transvision.git","svn_url":"https://github.com/flodolo/transvision","homepage":null,"size":3229,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"mozfr:master","ref":"master","sha":"f3dabbbc440ef3e66aaf48c178126b933d05eae9","user":{"login":"mozfr","id":1695186,"avatar_url":"https://avatars.githubusercontent.com/u/1695186?v=3","gravatar_id":"","url":"https://api.github.com/users/mozfr","html_url":"https://github.com/mozfr","followers_url":"https://api.github.com/users/mozfr/followers","following_url":"https://api.github.com/users/mozfr/following{/other_user}","gists_url":"https://api.github.com/users/mozfr/gists{/gist_id}","starred_url":"https://api.github.com/users/mozfr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozfr/subscriptions","organizations_url":"https://api.github.com/users/mozfr/orgs","repos_url":"https://api.github.com/users/mozfr/repos","events_url":"https://api.github.com/users/mozfr/events{/privacy}","received_events_url":"https://api.github.com/users/mozfr/received_events","type":"Organization","site_admin":false},"repo":{"id":4100227,"name":"transvision","full_name":"mozfr/transvision","owner":{"login":"mozfr","id":1695186,"avatar_url":"https://avatars.githubusercontent.com/u/1695186?v=3","gravatar_id":"","url":"https://api.github.com/users/mozfr","html_url":"https://github.com/mozfr","followers_url":"https://api.github.com/users/mozfr/followers","following_url":"https://api.github.com/users/mozfr/following{/other_user}","gists_url":"https://api.github.com/users/mozfr/gists{/gist_id}","starred_url":"https://api.github.com/users/mozfr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozfr/subscriptions","organizations_url":"https://api.github.com/users/mozfr/orgs","repos_url":"https://api.github.com/users/mozfr/repos","events_url":"https://api.github.com/users/mozfr/events{/privacy}","received_events_url":"https://api.github.com/users/mozfr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozfr/transvision","description":"QA tool for Mozilla product localizers","fork":false,"url":"https://api.github.com/repos/mozfr/transvision","forks_url":"https://api.github.com/repos/mozfr/transvision/forks","keys_url":"https://api.github.com/repos/mozfr/transvision/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozfr/transvision/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozfr/transvision/teams","hooks_url":"https://api.github.com/repos/mozfr/transvision/hooks","issue_events_url":"https://api.github.com/repos/mozfr/transvision/issues/events{/number}","events_url":"https://api.github.com/repos/mozfr/transvision/events","assignees_url":"https://api.github.com/repos/mozfr/transvision/assignees{/user}","branches_url":"https://api.github.com/repos/mozfr/transvision/branches{/branch}","tags_url":"https://api.github.com/repos/mozfr/transvision/tags","blobs_url":"https://api.github.com/repos/mozfr/transvision/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozfr/transvision/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozfr/transvision/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozfr/transvision/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozfr/transvision/statuses/{sha}","languages_url":"https://api.github.com/repos/mozfr/transvision/languages","stargazers_url":"https://api.github.com/repos/mozfr/transvision/stargazers","contributors_url":"https://api.github.com/repos/mozfr/transvision/contributors","subscribers_url":"https://api.github.com/repos/mozfr/transvision/subscribers","subscription_url":"https://api.github.com/repos/mozfr/transvision/subscription","commits_url":"https://api.github.com/repos/mozfr/transvision/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozfr/transvision/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozfr/transvision/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozfr/transvision/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozfr/transvision/contents/{+path}","compare_url":"https://api.github.com/repos/mozfr/transvision/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozfr/transvision/merges","archive_url":"https://api.github.com/repos/mozfr/transvision/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozfr/transvision/downloads","issues_url":"https://api.github.com/repos/mozfr/transvision/issues{/number}","pulls_url":"https://api.github.com/repos/mozfr/transvision/pulls{/number}","milestones_url":"https://api.github.com/repos/mozfr/transvision/milestones{/number}","notifications_url":"https://api.github.com/repos/mozfr/transvision/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozfr/transvision/labels{/name}","releases_url":"https://api.github.com/repos/mozfr/transvision/releases{/id}","created_at":"2012-04-21T23:04:20Z","updated_at":"2015-05-05T11:23:08Z","pushed_at":"2015-07-08T07:23:09Z","git_url":"git://github.com/mozfr/transvision.git","ssh_url":"git@github.com:mozfr/transvision.git","clone_url":"https://github.com/mozfr/transvision.git","svn_url":"https://github.com/mozfr/transvision","homepage":"http://transvision.mozfr.org","size":4169,"stargazers_count":31,"watchers_count":31,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":22,"forks":40,"open_issues":22,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozfr/transvision/pulls/499"},"html":{"href":"https://github.com/mozfr/transvision/pull/499"},"issue":{"href":"https://api.github.com/repos/mozfr/transvision/issues/499"},"comments":{"href":"https://api.github.com/repos/mozfr/transvision/issues/499/comments"},"review_comments":{"href":"https://api.github.com/repos/mozfr/transvision/pulls/499/comments"},"review_comment":{"href":"https://api.github.com/repos/mozfr/transvision/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozfr/transvision/pulls/499/commits"},"statuses":{"href":"https://api.github.com/repos/mozfr/transvision/statuses/ebc84f308cb09ecc7fe0fa13f193645bccb3d0c9"}}}}