Skip to content

Commit

Permalink
Merge pull request #426 from dylan8902/feature/christmas-jumpers
Browse files Browse the repository at this point in the history
Initial jumper code
  • Loading branch information
dylan8902 authored Dec 11, 2024
2 parents 99e818d + b55a55e commit 2d630ee
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
43 changes: 43 additions & 0 deletions app/models/christmas_jumper_donation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class ChristmasJumperDonation

PROJECT = "pub-tracker-live"
BASE_URL = "https://firestore.googleapis.com/v1/projects/#{PROJECT}/databases/(default)/documents"
DONATIONS_URL = "https://api.justgiving.com/904af047/v1/fundraising/pages/cjd240033091/donations"

def self.get_donations
begin
response = JSON.parse(RestClient.get(DONATIONS_URL, accept: "application/json").body)
return response["donations"]
rescue => e
logger.info "Get donations problem: " + e.message
return
end
end


def self.set_christmas_jumper_hat user_id
puts "Give hat to #{user_id}"
end


def self.update_pub_thursday_user justgiving_name
response = JSON.parse(RestClient.get("#{BASE_URL}/users?pageSize=100&mask.fieldPaths=displayName").body)
response["documents"].each do |user|
name = user["fields"]["displayName"]["stringValue"]
if name.strip.downcase.eql? justgiving_name.strip.downcase
user_id = user["name"].gsub("projects/#{PROJECT}/databases/(default)/documents/users/", "")
self.set_christmas_jumper_hat(user_id)
end
end
end


def self.update
self.get_donations().each do |donation|
justgiving_name = donation["donorDisplayName"]
self.update_pub_thursday_user(justgiving_name)
end
return
end

end
2 changes: 2 additions & 0 deletions bin/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ source ~/.bashrc
source ~/.bash_profile
cd /home/rails
git pull
rvm install 3.3.6
bundle install
rake db:migrate RAILS_ENV=production
export NODE_OPTIONS=--openssl-legacy-provider
yarn install
rake assets:precompile RAILS_ENV=production
bin/webpack
cp config/server/unicorn /etc/default/unicorn
chown -R rails /home/rails
chgrp -R www-data /home/rails
service unicorn restart
Binary file added public/images/jumper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2d630ee

Please sign in to comment.