250 Commits
Author SHA1 Message Date
Douwe Maan 2f30d00432 Add DiffNote model 2016-07-06 18:50:59 -04:00
Douwe Maan a27462a5c6 Extract parts of LegacyDiffNote into DiffOnNote concern and move part of responsibility to other classes 2016-07-06 18:50:59 -04:00
Douwe Maan 3286dd7a1d Don't garbage collect commits that have related DB records like comments 2016-07-04 00:11:33 -04:00
James Lopez f29c30475e use has_many relationship with events 2016-07-01 15:34:10 +02:00
James Lopez 3d2a736679 fixing events for import/export 2016-06-29 10:35:26 +02:00
Yorick Peterse d470f3d195 Support for rendering/redacting multiple documents
This commit changes the way certain documents are rendered (currently
only Notes) and how documents are redacted. Previously both rendering
and redacting would run on a per document basis. The result of this was
that for every document we'd have to run countless queries just to
figure out if we could display a set of links or not.

This commit changes things around so that redacting Markdown documents
is no longer tied into the html-pipeline Gem. This in turn allows it to
redact multiple documents in a single pass, thus reducing the number of
queries needed.

In turn rendering issue/merge request notes has been adjusted to take
advantage of this new setup. Instead of rendering Markdown somewhere
deep down in a view the Markdown is rendered and redacted in the
controller (taking the current user and all that into account). This has
been done in such a way that the "markdown()" helper method can still be
used on its own.

This particular commit also paves the way for caching rendered HTML on
object level. Right now there's an accessor method Note#note_html which
is used for setting/getting the rendered HTML. Once we cache HTML on row
level we can simply change this field to be a column and call a "save"
whenever needed and we're pretty much done.
2016-06-24 11:46:39 +02:00
Paco Guzman 66ec925557 Preload notes/discussions associations (award_emoji: :user) 2016-06-23 21:04:37 +02:00
Z.J. van de WegandPaco Guzman e7a27946ea Eager load award emoji on notes
This commit eager loads the award emoji on both the issues and the MRs.
When loading an issue with 108 comments this reduces the query count by
327 queries. On a merge request with the same amount of comments this
saves 148 queries. The large difference is not clear to me at this
point and the total query count is still huge with 387 and 1034
respectively. The biggest problem however, remains the calculation of
participants.
2016-06-23 20:59:34 +02:00
James Lopez 2a747d386d fixed merge conflicts 2016-06-16 14:07:49 +02:00
Z.J. van de Weg 31944179aa Award Emoji can't be awarded on system notes backend 2016-06-15 15:06:34 +02:00
Douglas Barbosa Alexandre 1491767583 Use Issue.visible_to_user in Notes.search to avoid query duplication 2016-06-13 19:32:00 -03:00
Douglas Barbosa Alexandre b56c456750 Project members with guest role can't access confidential issues 2016-06-13 19:32:00 -03:00
James Lopez b07dc938b9 fixed specs and refactored a few things due to recent model changes and merge conflicts 2016-06-13 13:34:36 +02:00
ZJ van de Weg 2f9c2149a3 Backend awardables on comments 2016-06-06 11:03:39 +02:00
Z.J. van de Weg 9d491712cf Merge branch 'master' into awardables 2016-06-03 15:20:11 +02:00
Douwe Maan 2d084dd848 Merge branch 'separate-banzai-references' into 'master'
Separate reference gathering from rendering

This is a required step to allow batch processing when gathering references. This in turn would allow grabbing (for example) all mentioned users of an issue/merge request using a single query.

cc @rspeicher @DouweM 

See merge request !3969
2016-06-01 15:51:59 +00:00
Yorick Peterse 580d250166 Refactor Participable
There are several changes to this module:

1. The use of an explicit stack in Participable#participants
2. Proc behaviour has been changed
3. Batch permissions checking

== Explicit Stack

Participable#participants no longer uses recursion to process "self" and
all child objects, instead it uses an Array and processes objects in
breadth-first order. This allows us to for example create a single
Gitlab::ReferenceExtractor instance and pass this to any Procs. Re-using
a ReferenceExtractor removes the need for running potentially many SQL
queries every time a Proc is called on a new object.

== Proc Behaviour Changed

Previously a Proc in Participable was expected to return an Array of
User instances. This has been changed and instead it's now expected that
a Proc modifies the Gitlab::ReferenceExtractor passed to it. The return
value of the Proc is ignored.

== Permissions Checking

The method Participable#participants uses
Ability.users_that_can_read_project to check if the returned users have
access to the project of "self" _without_ running multiple SQL queries
for every user.
2016-06-01 16:22:35 +02:00
Z.J. van de Weg 91a7b9333b Incorportate feedback 2016-06-01 12:10:08 +02:00
Robert Speicher 613bcdc626 Merge branch 'data_leak' into 'master'
Confidential notes data leak

Fixes part of https://gitlab.com/gitlab-org/gitlab-ee/issues/575

See merge request !1967
2016-05-31 19:35:13 +00:00
Valery Sizov 9154586ce5 Confidential notes data leak 2016-05-31 21:32:53 +03:00
ZJ van de Weg cbd7801b3d Merge branch 'master' into awardables 2016-05-30 18:54:08 +02:00
Grzegorz BizonandRobert Speicher 99ef3a84b5 Validate presence of noteable_type in note model 2016-05-29 15:03:00 -04:00
Grzegorz BizonandRobert Speicher 21d0cddd45 Do not override foreign attributes in note factory 2016-05-29 15:03:00 -04:00
Grzegorz BizonandRobert Speicher 57b551a19f Remove redundant with_options from note validators 2016-05-29 15:03:00 -04:00
Grzegorz BizonandRobert Speicher 87c44b0e91 Improve note validation for project mismatch 2016-05-29 15:03:00 -04:00
Grzegorz BizonandRobert Speicher c31a296c94 Make note invalid if noteable project is different
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/15577
2016-05-29 15:03:00 -04:00
ZJ van de Weg 4d6c51e228 Fix backend merge mistakes
[ci skip]
2016-05-19 15:00:50 -05:00
Fatih Acet bb883387f9 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into awardables
# Conflicts:
#	app/controllers/projects/merge_requests_controller.rb
#	app/models/note.rb
#	db/schema.rb
#	spec/models/note_spec.rb
2016-05-18 13:05:53 -05:00
Robert Speicher 6286b28bbc Add an Event's target's title to its reference link
Given an activity feed entry like:

> Douwe Maan commented on [issue #123] at [gitlab-org/gitlab-ce]

...the `issue #123` link will now have a `title` attribute.
2016-05-16 14:52:02 -05:00
Douwe Maan 7848d54f5b Clean up LegacyDiffNote somewhat 2016-05-13 17:31:58 -05:00
Douwe Maan 99d3e21f19 Extract LegacyDiffNote out of Note 2016-05-13 17:31:43 -05:00
Zeger-Jan van de Weg 7a4e7ad04e Fix tests and wrong choices during merge 2016-05-12 09:23:21 +02:00
Zeger-Jan van de Weg 4558b5b9fe Incorporate feedback 2016-05-11 22:43:58 +02:00
Zeger-Jan van de Weg 7e6dcf9cd0 Merge branch 'master' into awardables 2016-05-11 08:47:04 +02:00
Jeroen van Baarsen f1479b56b7 Remove the annotate gem and delete old annotations
In 8278b763d9 the default behaviour of annotation
has changes, which was causing a lot of noise in diffs. We decided in #17382
that it is better to get rid of the whole annotate gem, and instead let people
look at schema.rb for the columns in a table.

Fixes: #17382
2016-05-09 18:00:28 +02:00
Zeger-Jan van de Weg 3bdc57f0a7 Create table for award emoji 2016-05-06 10:47:11 +02:00
Zeger-Jan van de Weg 47da013cf8 Annotate the models 2016-05-06 08:27:46 +02:00
Rémy Coutable 1fbea7cec9 Remove useless require 'file_size_validator' causing warnings
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-04-19 11:40:16 +02:00
Rémy Coutable 091b8a6ede Rename Note#for_project_snippet? to #for_snippet?
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-03-31 09:20:27 +02:00
Robert Speicher b782e7c973 Merge branch 'rs-note-active-spec' into 'master'
Add unit specs for `Note#active?`

See merge request !3133
2016-03-14 12:53:15 -04:00
Robert Speicher a63eba9a2b Add unit specs for Note#active? 2016-03-11 18:16:34 -05:00
Robert Speicher 01f6db4f64 Disallow blank (non-null) values for a Note's line_code attribute
It's unclear how these blank values got added, but GitLab.com had a few:

```
irb(main):002:0> Note.where("line_code IS NOT NULL AND line_code = ''").count
=> 439
```

We've added a migration to convert any existing records to use a NULL
value when blank, and updated Note to set blank values to nil before
validation.
2016-03-11 17:46:50 -05:00
Yorick PeterseandRobert Speicher d7d5937531 Removed arel_table receiver from search methods
We can just use "arel_table" in these cases instead of
"SomeClass.arel_table".
2016-03-11 15:25:23 -05:00
Yorick PeterseandRobert Speicher 508b6b46fe Use ILIKE/LIKE for searching notes 2016-03-11 15:25:21 -05:00
Douwe Maan be1ae2d660 Merge branch 'rs-note-delegates-mentionable'
# Conflicts:
#	app/models/note.rb
2016-03-07 09:38:16 +01:00
Douwe Maan de872f2668 Merge branch 'rs-note-reuse-for-methods' into 'master'
Make better use of the `Note#for_*?` methods

We've got all these polymorphic type-checking methods, might as well use
'em everywhere it makes sense.

See merge request !3106
2016-03-07 08:32:49 +00:00
Robert Speicher 84dab62c18 Delegate a Note's Mentionable methods to its noteable object 2016-03-05 20:45:05 -05:00
Robert Speicher dcbf7d13c4 Make better use of the Note#for_*? methods
We've got all these polymorphic type-checking methods, might as well use
'em everywhere it makes sense.
2016-03-05 20:19:01 -05:00
Robert Speicher 1b27c3c5f8 Remove Note#system? "override"
This method was duplicating default Rails behavior.
2016-03-05 17:32:37 -05:00
Robert Speicher eb3ca32813 Remove Note#noteable_type_name
This method was added in Dec 2012, its single use was removed two days
later, and it's been there ever since.
2016-03-05 17:32:08 -05:00