Commit Graph

197 Commits

Author SHA1 Message Date
Senén Rodero Rodríguez
be886ba77a Add rake task to remove duplicated local census records
Also supress migration messages during spec execution to keep test log as clean
as possible.
2019-11-08 14:46:45 +01:00
Javi Martín
9b511edd5b Write task to migrate budget admins and valuators
If we didn't run this task, investments for existing budgets wouldn't
show their administrator/valuators as an option when we're editing them,
leading to data loss.
2019-11-01 17:12:42 +01:00
Javi Martín
b8fbd6347b Use acts_as_taggable for investment valuation tags
We were manually doing the same thing, generating inconsistent results,
since the method `valuation_tag_list` was using the `valuation` context,
when actually the expected behavior would be to use the `valuation_tag`
context.
2019-11-01 17:12:31 +01:00
Javi Martín
eafb4018bf Apply Style/CollectionMethods rubocop rule
We were already using `map` and `reduce` almost everywhere.
2019-10-26 13:03:49 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Javi Martín
7ca55c44e0 Apply Rails/SaveBang rubocop rule
Having exceptions is better than having silent bugs.

There are a few methods I've kept the same way they were.

The `RelatedContentScore#score_with_opposite` method is a bit peculiar:
it creates scores for both itself and the opposite related content,
which means the opposite related content will try to create the same
scores as well.

We've already got a test to check `Budget::Ballot#add_investment` when
creating a line fails ("Edge case voting a non-elegible investment").

Finally, the method `User#send_oauth_confirmation_instructions` doesn't
update the record when the email address isn't already present, leading
to the test "Try to register with the email of an already existing user,
when an unconfirmed email was provided by oauth" fo fail if we raise an
exception for an invalid user. That's because updating a user's email
doesn't update the database automatically, but instead a confirmation
email is sent.

There are also a few false positives for classes which don't have bang
methods (like the GraphQL classes) or destroying attachments.

For these reasons, I'm adding the rule with a "Refactor" severity,
meaning it's a rule we can break if necessary.
2019-10-23 14:39:31 +02:00
Javi Martín
0a2efb1d80 Use application logger in set_original_heading_id
The pull request adding the original heading was done before we started
using `ApplicationLogger` in rake tasks.
2019-10-08 20:39:26 +02:00
Javi Martín
4fad6f16f6 Make set_original_heading_id task idempotent
This way there'll be no side effects if accidentally executed on data
already having the `original_heading_id`.
2019-10-08 20:30:02 +02:00
Javi Martín
acbad38749 Update execute_release_tasks task
It now contains tasks we've added after version 1.0.0
2019-10-08 20:20:41 +02:00
Javi Martín
7bb39c8e4e Execute add_new_settings on every release
Although it's already executed when deploying with capistrano, heroku
installations don't use capistrano for deployment, so we're also
executing it when upgrading.

This isn't a one-time task, so it makes sense to have it executed on
every release.
2019-10-08 20:19:48 +02:00
Javi Martín
8fb44961e9 Remove tasks to rename/remove deprecated settings
I was thinking of leaving these tasks empty, so in the future we could
use them again if we rename or remove more settings. But since we
haven't renamed nor removed any settings for more than seven months, and
we've only used these tasks once, I'm simply removing the tasks. It's
easy to add them back if we ever need them.
2019-10-08 20:19:48 +02:00
Javi Martín
122b066573 Remove already executed tasks
These tasks were executed when upgading to version 0.19, 1.0.0-beta or
1.0.0.
2019-10-08 20:19:48 +02:00
Javi Martín
2aabf79fb4 Rename methods to add auto links to HTML
The name `safe_html_with_links` was confusing and could make you think
it takes care of making the HTML safe. So I've renamed it in a way that
makes it a bit more intuitive that it expects its input to be already
sanitized.

I've changed `text_with_links` as well so now the two method names
complement each other.
2019-10-08 18:46:20 +02:00
voodoorai2000
71e6c5713a Add rake task to set the original_heading_id value
By default we want this attribute to be the current heading id for existing investments. If there have been reclassifications, this field should be updated accordingly.
2019-09-12 16:49:01 +02:00
Javier Martín
8670cafa2e Merge pull request #3611 from PierreMesure/adding-missing-subtasks-to-upgrade-task
Adding missing subtasks to upgrade task and adding info log
2019-09-11 21:26:45 +02:00
Javi Martín
a21240b230 Use Date.current and Time.current
Using Date.today and Time.now might lead to inconsistencies if the time
zone the application uses is not the same as the system time zone.
2019-08-28 20:32:40 +02:00
Javi Martín
d981e23cd7 Remove custom dashboard task
It was made for Madrid's repository, but was accidentally added to
CONSUL as well.
2019-08-07 20:37:02 +02:00
taitus
064235d29f Add rake task to create remote census setting 2019-07-29 13:10:09 +02:00
taitus
95f848f021 Fix specs after rebase with translations branch
- Fix spec spec/features/management/proposals_spec.rb:24 adding single quotes.
- Remove spec related with 'proposal improvement info link' as master branch.
- Fix proposal rake task (now proposals have translations). We put the 'validate: false' to keep the existing html tags in the  proposal's description. Without the sanitizable module deleting them.
2019-06-27 09:19:37 +02:00
Pierre Mesure
2705416842 Adding missing subtasks to upgrade task and adding info log 2019-06-11 22:35:57 +02:00
Javi Martín
1d0b05832c Add info messages for release 1.0.0 tasks
So users know what's going on when they upgrade CONSUL.
2019-06-05 20:23:56 +02:00
Javi Martín
3ab2085e05 Move calculate_ballot_lines task to the right file
We already have a file with the proper budgets namespace.
2019-06-05 20:23:56 +02:00
Javi Martín
c78211af49 Add task to upgrade to version 1.0.0
It includes every task needed for the upgrade.
2019-06-05 20:23:54 +02:00
Javi Martín
e339ed94d1 Add new settings every time we deploy
This way we don't need to add and execute rake tasks every time we add a
new setting.
2019-05-31 19:33:31 +02:00
voodoorai2000
d0b8fef6b3 Delete spending proposals 2019-05-31 18:22:59 +02:00
Javi Martín
dd851cb6cc Add task to regenerate ballot_lines_count cache
We've added this column recently to `budget_ballots`, and we use it to
calculate stats.
2019-05-29 20:39:19 +02:00
Javi Martín
9ae0cbb254 Add task to migrate enabled poll results and stats 2019-05-22 12:48:11 +02:00
Javier Martín
82e3c41aa9 Merge pull request #3512 from consul/backport-stats
Change stats layout
2019-05-21 17:18:47 +02:00
Javi Martín
13dd77dd1b Add tasks to generate and expire stats cache
We're generating stats every 2 hours because it's less than the time it
will take to generate stats for every process. Once stats are generated,
this task should take less than a second.

The regenerate task has been added so we can manually execute it.
2019-05-21 13:50:19 +02:00
Javier Martín
cbfa2c1df8 Merge pull request #3504 from consul/backport-poll_slugs
Add slug to polls
2019-05-21 13:42:47 +02:00
Javi Martín
3d84920c47 Add task to generate poll slugs 2019-05-17 08:15:41 +02:00
decabeza
f40787561d Remove all references to question and external_url fields 2019-04-30 16:42:07 +02:00
decabeza
e88c66c92c Dont use faker gem on simulate successful proposal rake 2019-04-29 15:45:35 +02:00
decabeza
ad41f23a98 Improve rake to add published_at to proposals 2019-04-29 15:44:47 +02:00
voodoorai2000
992f1d23a1 Change syntax to delay dashboard emails
After updating to Rails5 It seems the after_action[1] in the dashboard's mailer is not beind called.

Using this syntax the emails are still being delayed and the after_action being called correctly.

[1] https://github.com/AyuntamientoMadrid/consul/pull/1945/files#diff-fdf5590f3241c439fcc9d2225c3cf4d8R3
2019-04-29 15:44:45 +02:00
decabeza
2cff3767c1 Remove open in new tab option for links 2019-04-24 13:58:13 +02:00
decabeza
cb22e6cbfb Merge branch 'master' into proposal-dashboard 2019-04-23 17:12:47 +02:00
voodoorai2000
e47a8be2a2 Add more log messages 2019-04-17 16:51:13 +02:00
voodoorai2000
aa04757e16 Add rake task to check for spending proposals 2019-04-17 16:50:32 +02:00
decabeza
91be3cf775 Fix more hound warnings 2019-03-27 15:22:14 +01:00
decabeza
b79061064b Remove all texts of decide madrid 2019-03-26 18:22:02 +01:00
decabeza
eda6ea7f12 Merge branch 'master' into dashboard 2019-03-26 16:45:48 +01:00
Javi Martín
9d6bd7e788 Remove obsolete rake tasks
These tasks dealt with data migrations or stats generations which were
done only once, so we don't need them anymore.

New CONSUL installations don't need these tasks, and existing CONSUL
installations will execute them when upgrading one release at a time.
2019-03-22 13:07:09 +01:00
decabeza
ab8f04a71e Add updated_at to proposals rake 2019-03-21 14:15:07 +01:00
decabeza
832f0c40a8 Add rake to move external_url to description
This rake move this field for Proposals and Legislation proposals.
2019-03-21 14:14:50 +01:00
taitus
8b1c458fdf Allow detect new actions since a custom date
- Rename method "detect_new_actions" to "detect_new_actions_since". Add new param date.
2019-03-21 12:29:31 +01:00
taitus
b115c3af49 Rake task for create basic templates with actions and resources by default. 2019-03-21 12:29:30 +01:00
taitus
5177adb32a New rake task for proposals to send new action email
Execute rake task every day to detect new actions available for not archived proposals. If there are new actions available for today, send email to proposal's author with information text, new actions available and link to proposal dashboard url.
2019-03-21 12:29:28 +01:00
Julian Herrero
e04fd74cf1 Add rake task to rename existing setting keys 2019-03-19 19:45:34 +01:00
Julian Herrero
002e16ce30 Use double quotes in lib/ 2019-03-15 10:29:07 +01:00