Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This refactors the TodoService class according to our code reuse
guidelines. The resulting code is a wee bit more verbose, but it allows
us to decouple the column names from the input, resulting in fewer
changes being necessary when we change the schema.
One particular noteworthy line in TodoService is the following:
todos_ids = todos.update_state(state)
Technically this is a violation of the guidelines, because
`update_state` is a class method, which services are not supposed to use
(safe for a few allowed ones). I decided to keep this, since there is no
alternative. `update_state` doesn't produce a relation so it doesn't
belong in a Finder, and we can't move it to another Service either. As
such I opted to just use the method directly.
Cases like this may happen more frequently, at which point we should
update our documentation with some sort of recommendation. For now, I
want to refrain from doing so until we have a few more examples.
|
|
This refactors the TodosFinder finder according to the new code reuse
rules, as enforced by the CodeReuse cops. I also changed some of the
methods to use regular if statements, instead of assignments and/or
early returns. This results in a more natural flow when reading the
code, and it makes it harder to accidentally return the wrong result.
|
|
This commit adds the module `FromUnion`, which provides the class method
`from_union`. This simplifies the process of selecting data from the
result of a UNION, and reduces the likelihood of making mistakes. As a
result, instead of this:
union = Gitlab::SQL::Union.new([foo, bar])
Foo.from("(#{union.to_sql}) #{Foo.table_name}")
We can now write this instead:
Foo.from_union([foo, bar])
This commit also includes some changes to make this new setup work
properly. For example, a bug in Rails 4
(https://github.com/rails/rails/issues/24193) would break the use of
`from("sub-query-here").includes(:relation)` in certain cases. There was
also a CI query which appeared to repeat a lot of conditions from an
outer query on an inner query, which isn't necessary.
Finally, we include a RuboCop cop to ensure developers use this new
module, instead of using Gitlab::SQL::Union directly.
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/51307
|
|
Enable frozen string in app/graphql + app/finders
See merge request gitlab-org/gitlab-ce!21681
|
|
Partially addresses #47424.
|
|
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
|
|
|
|
|
|
This reverts commit 8717c7dad9b5a8fa21ec9a652c54718a6b4c2175.
|
|
This reverts commit 4d9a3f42f1fd3be21555e19872b7121cca65015e, reversing
changes made to ecf9c145f6e4d170cd059df88743393d9e63c489.
|
|
|
|
* Group filtering now includes also issues/MRs from
subgroups/subprojects
* fixed due_date
* Also DRYed todo controller specs
|
|
|
|
|
|
This was causing todo priority sorting to fail.
|
|
Using ProjectsFinder in TodosFinder to limit todos to the right projects
leads to overly complicated and slow database queries. This commit
removes the use of ProjectsFinder in favour of using
Project.public_or_visible_to_current_user directly.
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/43767
|
|
|
|
|
|
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
|
|
|
|
|
|
Signed-off-by: Rémy Coutable <remy@rymai.me>
|
|
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.
|
|
This reverts merge request !10076
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
# Conflicts:
# app/services/issues/create_service.rb
|
|
|
|
Closes #20828
|
|
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>
|
|
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
|
|
|
|
|
|
|
|
|
|
Added a button into the sidebar for issues & merge requests to allow users to manually create todo items
Closes #15045
|