Skip to content

Commit

Permalink
Merge pull request #881 from alphagov/fix-archived-petitions-csv
Browse files Browse the repository at this point in the history
Fix CSV downloads of archived petitions in the moderation portal
  • Loading branch information
pixeltrix authored Nov 2, 2023
2 parents d3d61f5 + 901feec commit 4b84b47
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 24 deletions.
4 changes: 3 additions & 1 deletion app/models/archived/signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ def search(query, options = {})
scope = scope.for_postcode(query)
elsif sector_search?(query)
scope = scope.for_sector(query)
else
elsif query.present?
scope = scope.for_name(query)
else
scope = scope.none
end

scope.paginate(page: page, per_page: 50)
Expand Down
4 changes: 3 additions & 1 deletion app/models/signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,10 @@ def search(query, options = {})
scope = scope.for_postcode(query)
elsif sector_search?(query)
scope = scope.for_sector(query)
else
elsif query.present?
scope = scope.for_name(query)
else
scope = scope.none
end

scope.paginate(page: page, per_page: 50)
Expand Down
8 changes: 6 additions & 2 deletions app/presenters/petition_csv_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ def notes
petition.note.details if petition.note
end

def statistics
petition.respond_to?(:statistics) && petition.statistics
end

def subscriber_count
if petition.statistics.refreshed?
if statistics && statistics.refreshed?
csv_escape petition.statistics.subscriber_count
end
end

def subscription_rate
if petition.statistics.refreshed?
if statistics && statistics.refreshed?
csv_escape petition.statistics.subscription_rate
end
end
Expand Down
37 changes: 18 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ version: "3.7"
x-application: &application
image: e-petitions/ruby
build: docker/ruby
environment:
- DATABASE_URL=postgres://postgres:ZW4IvOPrXcbp2hyp@postgres:5432
- MEMCACHE_SERVERS=memcached:11211
- SMTP_HOST=mailcatcher
- SMTP_PORT=1025
- SPROCKETS_CACHE=/cache
- PIDFILE=/tmp/pids/server.pid
volumes:
- .:/app
- bundle:/bundle
Expand All @@ -22,6 +15,14 @@ x-application: &application
- mailcatcher
- memcached

x-environment: &environment
DATABASE_URL: "postgres://postgres:ZW4IvOPrXcbp2hyp@postgres:5432"
MEMCACHE_SERVERS: "memcached:11211"
SMTP_HOST: "mailcatcher"
SMTP_PORT: "1025"
SPROCKETS_CACHE: "/cache"
PIDFILE: "/tmp/pids/server.pid"

services:
postgres:
image: postgres:12
Expand Down Expand Up @@ -50,6 +51,8 @@ services:

web:
<<: *application
environment:
<<: *environment
command: [
"rails", "server",
"-b", "0.0.0.0",
Expand All @@ -62,21 +65,17 @@ services:

worker:
<<: *application
command: [
"bin/delayed_job", "start",
"-p", "worker",
"--min-priority", "10",
"--daemon_options", "-t"
]
environment:
<<: *environment
MIN_PRIORITY: "10"
command: [ "rake", "jobs:work" ]

counter:
<<: *application
command: [
"bin/delayed_job", "start",
"-p", "counter",
"--max-priority", "5",
"--daemon_options", "-t"
]
environment:
<<: *environment
MAX_PRIORITY: "5"
command: [ "rake", "jobs:work" ]

volumes:
bundle:
Expand Down
2 changes: 1 addition & 1 deletion docker/ruby/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ else
yarn install
bundle check || bundle install

bundle exec "$@"
exec bundle exec "$@"
fi

0 comments on commit 4b84b47

Please sign in to comment.