Commit Graph

30 Commits

Author SHA1 Message Date
Tiago Botelho cfd475a45e Removes default scope from sortable 2017-09-07 13:01:59 +01:00
Toon Claes a488fc0add Add workaround for UPDATE with subquery when using MySQL
When trying to run an UPDATE, this query is ran:

```sql
UPDATE `todos`
INNER JOIN `projects` ON `projects`.`id` = `todos`.`project_id`
SET `todos`.`state` = 'done'
WHERE `todos`.`user_id` = 4
  AND (`todos`.`state` IN ('pending'))
  AND (EXISTS
         (SELECT 1
          FROM `project_authorizations`
          WHERE `project_authorizations`.`user_id` = 4
            AND (project_authorizations.project_id = projects.id))
       OR projects.visibility_level IN (10,
                                        20))
  AND `projects`.`id` IN
    (SELECT `todos`.`project_id`
     FROM `todos`
     WHERE `todos`.`user_id` = 4
       AND (`todos`.`state` IN ('pending')))
  AND (`todos`.`state` != 'done')
```

But MySQL does not like the subquery used to filter on
`projects.id IN (SELECT ...`

Because the subquery queries from the same table:

> Error: You can’t specify target table ‘todos’ for update in FROM clause

So as workaround, wrap it in another subquery, where the original
subquery is aliased using the `AS` statement.

Mostly inspired by https://stackoverflow.com/a/43610081/89376
2017-08-03 16:31:05 +02:00
Tiago Botelho 1fbb7f9777 Removes redundant pending delete checks 2017-06-28 17:51:05 +01:00
Tiago Botelho 34f57b462b Fix current feature related specs 2017-06-28 11:32:34 +01:00
Rémy Coutable 4cfa5ce4a9
Enable the Style/PreferredHashMethods cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-02 19:11:26 +02:00
Jacopo b996a82ff4 ProjectsFinder should handle more options
Extended ProjectFinder in order to handle the following options:
 - current_user - which user use
 - project_ids_relation: int[] - project ids to use
 - params:
   -  trending: boolean
   -  non_public: boolean
   -  starred: boolean
   -  sort: string
   -  visibility_level: int
   -  tags: string[]
   -  personal: boolean
   -  search: string
   -  non_archived: boolean

GroupProjectsFinder now inherits from ProjectsFinder.
Changed the code in order to use the new available options.
2017-04-06 07:11:37 +02:00
Sean McGivern 1974691bfe Revert "Merge branch '29534-todos-performance' into 'master'"
This reverts merge request !10076
2017-03-21 15:25:00 +00:00
Jarka Kadlecova bf41a2e752 Todos performance: Include associations in Finder 2017-03-20 12:45:43 +01:00
Douwe Maan 7d4b52b27d Enable Style/WordArray 2017-02-23 09:32:41 -06:00
Douwe Maan b7d8df503c Enable Style/MutableConstant 2017-02-23 09:31:56 -06:00
http://jneen.net/ 5853c96b49 remove Ability.abilities 2016-08-30 11:35:06 -07:00
Douwe Maan c620c40575 Merge branch 'issue_18135' into 'master'
Todos sorting dropdown

Implements #18135 

![todos_sorting](/uploads/bff76827c421628134dfb8b864e47c74/todos_sorting.png)  


- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5691
2016-08-19 23:06:30 +00:00
Felipe Artur 37bf35f0bc Todos sorting dropdown 2016-08-19 16:14:20 -03:00
Douwe Maan e07c27fee4 Merge branch 'master' into 4273-slash-commands
# Conflicts:
#	app/services/issues/create_service.rb
2016-08-16 17:49:53 -05:00
Ahmad Sherif 76db0dc115 Pass project IDs relation to ProjectsFinder instead of using a block 2016-08-15 12:49:31 +02:00
Ahmad Sherif d13c36f72d Speed up todos queries by limiting the projects set we join with
Closes #20828
2016-08-15 12:49:31 +02:00
Rémy Coutable 0eea8c8857 Support slash commands in noteable description and notes
Some important things to note:

- commands are removed from noteable.description / note.note
- commands are translated to params so that they are treated as normal
  params in noteable Creation services
- the logic is not in the models but in the Creation services, which is
  the right place for advanced logic that has nothing to do with what
  models should be responsible of!
- UI/JS needs to be updated to handle notes which consist of commands
  only
- the `/merge` command is not handled yet

Other improvements:

- Don't process commands in commit notes and display a flash is note is only commands
- Add autocomplete for slash commands
- Add description and params to slash command DSL methods
- Ensure replying by email with a commands-only note works
- Use :subscription_event instead of calling noteable.subscribe
- Support :todo_event in IssuableBaseService

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-08-13 00:05:57 +02:00
Robert Speicher 33b4fc315e Merge branch 'approval-required-todo' into 'master'
Add approval required todos

Ports the 'approval required' todo type from EE - https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/547

See merge request !5217
2016-07-12 19:50:33 +00:00
Sean McGivern d957d5f1aa Add approval required todos 2016-07-12 19:01:09 +01:00
Paco Guzman 244134f9c3 Cache todos pending/done dashboard query counts 2016-07-12 18:57:52 +02:00
Robert Schilling 3942621329 Expose target, filter by state as string 2016-07-01 14:52:04 +02:00
Douglas Barbosa Alexandre 2878c99005 Ensure Todos counters doesn't count Todos for projects pending delete 2016-06-17 16:17:43 -03:00
Phil Hughes f67b06ada0 Manually create todo for issuable
Added a button into the sidebar for issues & merge requests to allow users to manually create todo items

Closes #15045
2016-06-14 08:36:07 +01:00
DJ Mountney f0ca487cd5 Reorder the todos because the use of the project finder attempts to order them differently 2016-06-02 14:17:46 -07:00
DJ Mountney b173ea2bd4 Use the project finder in the todos finder to limit todos to just ones within projects you have access to. 2016-06-02 12:20:27 -07:00
DJ Mountney 4280575fc0 Move filtering todos by projects not pending deletion into a scope on the todo model 2016-06-02 11:24:18 -07:00
DJ Mountney 4ecc10fade Reduce the filters on the todos joins project query by being explicit about the join 2016-06-02 11:24:18 -07:00
DJ Mountney c3e923c496 Ensure we don't show TODOS for projects pending delete
By joining the Todos on the project table.
2016-06-02 11:24:18 -07:00
Sean McGivern 6b834f2cbc Create a todo on failing MR build
When a build fails for a commit, create a todo for the author of the
merge request that commit is the HEAD of. If the commit isn't the HEAD
commit of any MR, don't do anything. If there already is a todo for that
user and MR, don't do anything.

Current limitations:
- This isn't configurable by project.
- The author of a merge request might not be the person who pushed the
  breaking commit.
2016-05-17 10:17:45 +01:00
Douglas Barbosa Alexandre 3d52e139b1 Rename Tasks to Todos 2016-02-20 12:39:27 -02:00