summaryrefslogtreecommitdiff
path: root/lib/banzai/reference_parser
Commit message (Collapse)AuthorAgeFilesLines
* Enable more frozen string in lib/**/*.rbgfyoung2018-10-0613-0/+26
| | | | | | | | | | | | | Enables frozen for the following: * lib/*.rb * lib/banzai/**/*.rb * lib/bitbucket/**/*.rb * lib/constraints/**/*.rb * lib/container_registry/**/*.rb * lib/declarative_policy/**/*.rb Partially addresses #47424.
* Preload project features in reference parserJan Provaznik2018-09-301-1/+1
| | | | | | | | | | | Preloading of project_features mitigates N+1 queries when checking references in other projects. When loading projects for resources referenced in comments it makes sense to include also associated project_features because in the following step (`can_read_reference?(user, projects[node], node)`) project features is used for checking permissions for the given project.
* Use `Gitlab::SafeRequestStore` in more placesMichael Kozono2018-09-241-2/+2
| | | | | | Even if it doesn’t save lines of code, since people will tend to use code they’ve seen. And `SafeRequestStore` is safer since you don’t have to remember to check `RequestStore.active?`.
* Fix routes N+1 in Issues::ReferencedMergeRequestsService#executeSean McGivern2018-08-211-2/+3
| | | | | Sorting here needs the project routes to be loaded, including the namespace routes.
* Add frozen_string_literal to recently-added files from the communitySean McGivern2018-08-101-0/+2
|
* Use a hash to memoize readable_project_ids with user objects as keysReuben Pereira2018-07-311-6/+5
|
* Remove nodes_visible_to_user from ProjectParser and memoize readable_project_idsReuben Pereira2018-07-151-17/+10
|
* Use map instead of collect in the ProjectParser#projects_readable_by_user ↵Reuben Pereira2018-07-051-1/+1
| | | | function
* Use a custom ProjectParser#nodes_visible_to_user function so that the user ↵Reuben Pereira2018-07-051-2/+21
| | | | permissions for all project references can be checked together
* A working implementation of a project reference filter which links project ↵Reuben Pereira2018-06-301-0/+17
| | | | references to project profile.
* Eager load project routes for issue referencesYorick Peterse2018-05-281-1/+2
| | | | | This reduces the number of queries necessary when displaying the activity page of a group.
* Fix reference filters in group contextJan Provaznik2018-04-121-0/+2
| | | | | | | | | Since !18150 abstract reference filter supports also `group` as a resource parent (not only `project`). Some reference filters, which inherit from abstract filter, depend on parent being `project` when checking a reference. This patch adds explicit check of parent class to the given filters.
* Support Markdown rendering using multiple projectsrendering-markdown-multiple-projectsYorick Peterse2018-04-113-14/+44
| | | | | | | | | | | | | | | | | | | This refactors the Markdown pipeline so it supports the rendering of multiple documents that may belong to different projects. An example of where this happens is when displaying the event feed of a group. In this case we retrieve events for all projects in the group. Previously we would group events per project and render these chunks separately, but this would result in many SQL queries being executed. By extending the Markdown pipeline to support this out of the box we can drastically reduce the number of SQL queries. To achieve this we introduce a new object to the pipeline: Banzai::RenderContext. This object simply wraps two other objects: an optional Project instance, and an optional User instance. On its own this wouldn't be very helpful, but a RenderContext can also be used to associate HTML documents with specific Project instances. This work is done in Banzai::ObjectRenderer and allows us to reuse as many queries (and results) as possible.
* Port `read_cross_project` ability from EEBob Van Landuyt2018-02-222-4/+23
|
* Refactor banzai to support referencing from group contextce-backport-3615Jarka Kadlecova2017-12-064-31/+42
|
* Adds Rubocop rule for line break after guard clauseJacopo2017-11-161-0/+1
| | | | Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
* Eliminate N+1 queries referencing issuessh-project-feature-eager-loadStan Hu2017-09-181-1/+2
| | | | | | | | To load issue 1, we see that in #38033 that about 835 ms of the SQL queries were due to loading ProjectFeature. We should be able to cut this down by eagerly loading this information. Closes #38033
* Support both internal and external issue trackersJarka Kadlecova2017-07-241-3/+7
|
* Improve support for external issue referencesadam-external-issue-references-spikeAdam Niedzielski2017-06-301-3/+0
|
* Enable Style/DotPosition Rubocop :cop:Grzegorz Bizon2017-06-212-4/+4
|
* Don't return nil for missing objects from parser cachedm-fix-parser-cacheDouwe Maan2017-06-141-1/+1
|
* Merge branch '25934-project-snippet-vis' into 'security-9-2'DJ Mountney2017-06-089-10/+14
| | | | | | Fix visibility when referencing snippets See merge request !2101
* Fix /unsubscribe slash command creating extra todos33032-invalid-you-directly-addressed-yourself-todo-when-using-unsubscribeSean McGivern2017-05-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | The /unsubscribe slash command means that we check if the current user is subscribed to the issuable without having an explicit subscription. That means that we use the UserParser to find references to them in the notes. The UserParser (and all parsers inheriting from BaseParser) use RequestStore to cache ActiveRecord objects, so that we don't need to load the User object each time, if we're parsing references a bunch of times in the same request. However, it was always returning _all_ of the previously cached items, not just the ones matching the IDs passed. This would mean that we did two runs through with UserParser if you were mentioned in a comment, and then mentioned someone else in your comment while using /unsubscribe: 1. Because /unsubscribe was used, we see if you were mentioned in any comments. 2. Because you mentioned someone, we find them - but we would also get back your user, even if you didn't mention yourself. This would have the effect of creating a mention or directly addressed todo for yourself incorrectly. The fix is simple: only return values from the cache matching the IDs passed.
* Backport of multiple_assignees_feature [ci skip]Valery Sizov2017-05-041-1/+1
|
* Remove N+1 queries when checking nodes visible to userfix-n-plus-one-project-featuresSean McGivern2017-05-021-1/+2
| | | | | | | N in this case is low, as it's the number of distinct projects referenced from MRs, rather than the number of MRs referenced (issues use their own optimization). Still, on issues or MRs which are often referenced from MRs, it will save a few queries.
* Fix regression in rendering Markdown references that do not existsh-fix-base-parserStan Hu2017-04-151-1/+2
| | | | Closes #30972
* Reuse "merge_requests_for_nodes" in "MergeRequestParser"merge-request-parser-merge-requests-for-nodesAdam Niedzielski2017-04-101-11/+30
|
* Add indication for closed or merged issuables in GFMadam-finish-5993-closed-issuableAdam Buckland2017-04-074-19/+25
| | | | | | | | | | | | | | | Example: for issues that are closed, the links will now show '[closed]' following the issue number. This is done as post-process after the markdown has been loaded from the cache as the status of the issue may change between the cache being populated and the content being displayed. In order to avoid N+1 queries problem when rendering notes ObjectRenderer populates the cache of referenced issuables for all notes at once, before the post processing phase. As a part of this change, the Banzai BaseParser#grouped_objects_for_nodes method has been refactored to return a Hash utilising the node itself as the key, since this was a common pattern of usage for this method.
* Use Enumerable#index_by where possibledm-use-index-byDouwe Maan2017-03-161-3/+1
|
* use a magic default :global symbol instead of nilhttp://jneen.net/2017-03-091-1/+1
| | | | to make sure we mean the global permissions
* Create directly_addressed Todos when mentioned in beginning of a lineErshad Kunnakkadan2017-02-082-2/+11
|
* Merge branch 'issue_23548_dev' into 'master'Douwe Maan2016-11-099-14/+78
| | | | | | | | | | | | | | | | | | | | | disable markdown in comments when referencing disabled features fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/23548 This MR prevents the following references when tool is disabled: - issues - snippets - commits - when repo is disabled - commit range - when repo is disabled - milestones This MR does not prevent references to repository files, since they are just markdown links and don't leak information. See merge request !2011 Signed-off-by: Rémy Coutable <remy@rymai.me>
* Avoid database queries on Banzai::ReferenceParser::BaseParser for nodes ↵22681-avoid-empty-queries-on-reference-parsersPaco Guzman2016-09-281-1/+5
| | | | without references
* remove Ability.abilitieshttp://jneen.net/2016-08-301-1/+1
|
* Method for returning issues readable by a userability-batch-issue-checkingYorick Peterse2016-07-291-3/+4
| | | | | | | | | | | | | The method Ability.issues_readable_by_user takes a list of users and an optional user and returns an Array of issues readable by said user. This method in turn is used by Banzai::ReferenceParser::IssueParser#nodes_visible_to_user so this method no longer needs to get all the available abilities just to check if a user has the "read_issue" ability. To test this I benchmarked an issue with 222 comments on my development environment. Using these changes the time spent in nodes_visible_to_user was reduced from around 120 ms to around 40 ms.
* Re-use queries in reference parsersreuse-queries-in-reference-parsersYorick Peterse2016-07-082-4/+37
| | | | | This caches various queries to ensure that multiple reference extraction runs re-use any objects queried in previous runs.
* Eager load project relations in IssueParserYorick Peterse2016-06-151-1/+15
| | | | | | | | | | | | | By eager loading these associations we can greatly cut down the number of SQL queries executed when processing documents with lots of references, especially in cases where there are references belonging to the same project. Since these associations are so specific to the reference parsing process and the permissions checking process that follows it I opted to include them directly in IssueParser instead of using something like a scope. Once we have a need for it we can move this code to a scope or method.
* Split Markdown rendering & reference gatheringYorick Peterse2016-05-2610-0/+477
This splits the Markdown rendering and reference extraction phases into two distinct code bases. The reference extraction phase no longer relies on the html-pipeline Gem (and any related code) and allows for extracting of references from multiple HTML nodes in a single pass. This means that if you want to extract user references from 200 comments you no longer need to run 200 times N number of queries, instead only a handful of queries may be needed.