Commit Graph

51 Commits

Author SHA1 Message Date
Valery Sizov 5004579b15 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into mia_backort[ci skip] 2017-05-05 16:59:31 +03:00
Douglas Barbosa Alexandre 91b5aaf770 Update last_repository_updated_at when a push event is created 2017-05-04 15:36:04 -03:00
Valery Sizov 387c4b2c21 Backport of multiple_assignees_feature [ci skip] 2017-05-04 17:11:53 +03:00
Robert Speicher e48a1755f4 Add traits for the different Event types to the Event factory 2017-02-01 16:02:03 -05:00
Robert Speicher fcb37542e7 Use `:empty_project` where possible in model specs 2017-01-26 17:44:59 -05:00
Yorick Peterse 0ba03d7eb1
Removed data-user-is view code
With events no longer being cached this is no longer needed.
2016-11-25 13:45:34 +01:00
Rémy Coutable d47fca53db
Allow commit note to be visible if repo is visible
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-16 15:35:15 +01:00
Robert Speicher b0088b527e
Merge branch '23403-fix-events-for-private-project-features' into 'security'
Respect project visibility settings in the contributions calendar

This MR fixes a number of bugs relating to access controls and date selection of events for the contributions calendar

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/23403

See merge request !2019

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-09 12:27:41 +01:00
Callum Dryden 9124310f28
Differentiate the expire from leave event
At the moment we cannot see weather a user left a project due to their
membership expiring of if they themselves opted to leave the project.
This adds a new event type that allows us to make this differentiation.
Note that is not really feasable to go back and reliably fix up the
previous events. As a result the events for previous expire removals
will remain the same however events of this nature going forward will be
correctly represented.
2016-10-20 00:26:45 +00:00
Semyon Pupkov 48015deda1 Union examples in event spec fo speed up 2016-10-13 12:11:18 +05:00
Valery Sizov b4004488f7 Make guests unable to view MRs 2016-10-11 16:51:26 +03:00
Yorick Peterse c9bcfc631a
Remove lease from Event#reset_project_activity
Per GitLab.com's performance metrics this method could take up to 5
seconds of wall time to complete, while only taking 1-2 milliseconds of
CPU time. Removing the Redis lease in favour of conditional updates
allows us to work around this.

A slight drawback is that this allows for multiple threads/processes to
try and update the same row. However, only a single thread/process will
ever win since the UPDATE query uses a WHERE condition to only update
rows that were not updated in the last hour.

Fixes gitlab-org/gitlab-ce#22473
2016-10-04 19:41:37 +02:00
Yorick Peterse 028c086f90
Restrict last_activity_at updates to one per hour
The lock in turn is only obtained when actually needed, reducing some
load on Redis.

Fixes gitlab-org/gitlab-ce#22213
2016-09-19 16:48:58 +02:00
Douwe Maan 70a64f6a57 Update test with new factory name 2016-07-07 15:57:38 -04:00
Rémy Coutable 19e15ae244
Use a more future-proof check for Note/LegacyDiffNote
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-07-06 10:08:42 +02:00
Rémy Coutable 4834e2e609
Fix diff comments not showing up in activity feed
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-07-04 16:29:28 +02:00
Douglas Barbosa Alexandre b56c456750 Project members with guest role can't access confidential issues 2016-06-13 19:32:00 -03: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
Rémy Coutable 533cd8c2ee
Throttle the update of `project.last_activity_at` to 1 minute
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-04-25 17:25:46 +02:00
Douglas Barbosa Alexandre 39a51f9e1c Rename `Event#proper?` to `Event#visible_to_user?` 2016-03-24 14:24:22 -03:00
Douglas Barbosa Alexandre 239560331a Comments on confidential issues doesn't show in activity feed to non-members 2016-03-24 14:22:01 -03:00
Douglas Barbosa Alexandre 9222459ea3 Restrict access to confidential issues on activity feed 2016-03-17 20:56:00 -03:00
Yorick Peterse de7c9c7ab1 Use Atom update times of the first event
By simply loading the first event from the already sorted set we save
ourselves extra (slow) queries just to get the latest update timestamp.
This removes the need for Event.latest_update_time and significantly
reduces the time needed to build an Atom feed.

Fixes gitlab-org/gitlab-ce#12415
2016-01-27 10:33:33 +01:00
Douwe Maan 1e8d703a85 Tag model specs 2015-12-09 10:50:51 +01:00
Yorick Peterse 01620dd7e7 Added Event.limit_recent
This will be used to move some querying logic from the users controller
to the Event model (where it belongs).
2015-11-18 13:05:45 +01:00
Yorick Peterse 054f2f98ed Faster way of obtaining latest event update time
Instead of using MAX(events.updated_at) we can simply sort the events in
descending order by the "id" column and grab the first row. In other
words, instead of this:

    SELECT max(events.updated_at) AS max_id
    FROM events
    LEFT OUTER JOIN projects   ON projects.id   = events.project_id
    LEFT OUTER JOIN namespaces ON namespaces.id = projects.namespace_id
    WHERE events.author_id IS NOT NULL
    AND events.project_id IN (13083);

we can use this:

    SELECT events.updated_at AS max_id
    FROM events
    LEFT OUTER JOIN projects   ON projects.id   = events.project_id
    LEFT OUTER JOIN namespaces ON namespaces.id = projects.namespace_id
    WHERE events.author_id IS NOT NULL
    AND events.project_id IN (13083)
    ORDER BY events.id DESC
    LIMIT 1;

This has the benefit that on PostgreSQL a backwards index scan can be
used, which due to the "LIMIT 1" will at most process only a single row.
This in turn greatly speeds up the process of grabbing the latest update
time. This can be confirmed by looking at the query plans. The first
query produces the following plan:

    Aggregate  (cost=43779.84..43779.85 rows=1 width=12) (actual time=2142.462..2142.462 rows=1 loops=1)
      ->  Index Scan using index_events_on_project_id on events  (cost=0.43..43704.69 rows=30060 width=12) (actual time=0.033..2138.086 rows=32769 loops=1)
            Index Cond: (project_id = 13083)
            Filter: (author_id IS NOT NULL)
    Planning time: 1.248 ms
    Execution time: 2142.548 ms

The second query in turn produces the following plan:

    Limit  (cost=0.43..41.65 rows=1 width=16) (actual time=1.394..1.394 rows=1 loops=1)
      ->  Index Scan Backward using events_pkey on events  (cost=0.43..1238907.96 rows=30060 width=16) (actual time=1.394..1.394 rows=1 loops=1)
            Filter: ((author_id IS NOT NULL) AND (project_id = 13083))
            Rows Removed by Filter: 2104
    Planning time: 0.166 ms
    Execution time: 1.408 ms

According to the above plans the 2nd query is around 1500 times faster.
However, re-running the first query produces timings of around 80 ms,
making the 2nd query "only" around 55 times faster.
2015-11-18 13:02:43 +01:00
Jeroen van Baarsen 0c4a70a306 Updated rspec to rspec 3.x syntax
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-02-12 19:17:35 +01:00
Valeriy Sizov 5715df2067 Merge pull request #8233 from cirosantilli/rm-new-branch-dead
Remove dead Event#new_branch? method
2014-11-05 16:25:35 +02:00
Ciro Santilli c3be1517ae Factor '0' * 40 blank ref constants 2014-11-03 20:37:08 +01:00
Ciro Santilli c49cb40f65 Remove dead Event#new_branch? method 2014-11-03 20:17:02 +01:00
Dmitriy Zaporozhets 73f91da8b1 Fix project deletion and tests 2014-06-17 23:49:17 +03:00
Dmitriy Zaporozhets 36f861f1b1
Re-annotate models
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-04-09 15:05:03 +03:00
skv d89527839e fix most of warnings 2013-12-15 00:05:10 +04:00
Dmitriy Zaporozhets e3f1164248 stub notification in event model 2013-03-26 19:27:39 +02:00
Andrew8xx8 839957cf56 Constants in Events looks good now 2013-02-13 15:48:16 +04:00
Dmitriy Zaporozhets 0ff468160e Fixed event.allowed? with event.proper? 2012-12-14 21:54:49 +02:00
Dmitriy Zaporozhets 95c23b2f97 Annotated. schema updated 2012-11-19 21:24:05 +03:00
Vincent Bonmalais 80fb38de7a Remove backward compatibility of factories. 2012-11-13 22:27:45 +11:00
Dmitriy Zaporozhets 41e53eb980 Annotated 2012-10-09 11:14:17 +03:00
randx a82977c648 A bit of test refactoring 2012-09-15 01:00:59 +03:00
Alex Denisov 1f240b09ed User left project event added 2012-09-10 00:27:47 +03:00
Alex Denisov a86bd87afc User joined project event added 2012-09-09 23:18:28 +03:00
Robert Speicher 97423a0bed Add more coverage for model validations and associations 2012-08-29 11:36:02 -04:00
Robert Speicher 9e7d77cece Remove annotations from specs 2012-08-29 10:44:34 -04:00
Robert Speicher 2c95074a5f Remove model specs that are covered by factories_spec 2012-08-29 10:44:34 -04:00
Robert Speicher 7754189187 Fully embrace Ruby 1.9 hash syntax
Didn't bother with files in db/, config/, or features/
2012-08-10 18:25:15 -04:00
randx 6abc649590 Reannotated 2012-06-26 21:23:09 +03:00
Dmitriy Zaporozhets f1799a239f fixed project spec 2012-04-02 08:50:37 +03:00
Dmitriy Zaporozhets 8ee0993fdf Event & Wiki models specs 2012-03-28 22:53:45 +03:00
Dmitriy Zaporozhets dcdb2fdfdb Observe issue, merge request, note creation - create event 2012-02-28 16:01:14 +02:00