Skip to content

Commit a46c21e

Browse files
committed
Optimise the trello:load_people task
Only update the DB if the card has changed
1 parent 070b9a8 commit a46c21e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ trello:
4545
token: [YOUR API TOKEN]
4646
```
4747
48+
You also need to set the environment variable `TRELLO_BOARD_ID` (e.g. `Yae2dtTq`).
49+
4850
### Configure Google Sign In
4951

5052
You need to configure the app with Google creds.

lib/tasks/trello.rake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
namespace :trello do
2-
WHOS_WHO = "Xau2Ttaq"
3-
42
desc "Looks for Trello cards that have been archived (closed) and discards the person in the database"
53
task clean: :environment do
64
Rails.logger = Logger.new(STDOUT)
@@ -22,7 +20,10 @@ namespace :trello do
2220
Rails.logger = Logger.new(STDOUT)
2321
Rails.logger.info "Loading cards from Trello"
2422

25-
lists = Trello::Board.find(WHOS_WHO).lists
23+
board = ENV['TRELLO_BOARD_ID']
24+
raise "Missing environment variable TRELLO_BOARD_ID" if board.nil?
25+
26+
lists = Trello::Board.find(board).lists
2627
lists.each do |list|
2728
Rails.logger.info "Checking #{list.name}"
2829

@@ -33,6 +34,11 @@ namespace :trello do
3334

3435
Rails.logger.info "checking #{card.name}"
3536

37+
if person.updated_at > card.last_activity_date
38+
Rails.logger.info "No activity. Skipping"
39+
next
40+
end
41+
3642
name, title = card.name.split /[\[(]/
3743
person.name = name.strip if name
3844
person.title = title.gsub(/[\)\]]/, "").strip if title

0 commit comments

Comments
 (0)