@@ -11,20 +11,35 @@ const createTransaction = async (signature, ip_address, wallet_address, github_u
1111 return result . rows [ 0 ] ;
1212} ;
1313
14- const getLastTransaction = async ( { wallet_address, github_username, ip_address } ) => {
15- const query = `
16- SELECT * FROM faucet.transactions
17- WHERE
18- (wallet_address = $1) OR
19- (github_username = $2) OR
20- (ip_address = $3)
21- ORDER BY timestamp DESC
22- LIMIT 1;
23- ` ;
14+ const getLastTransaction = async ( { wallet_address, github_id, ip_address, queryLimit } ) => {
15+ let query ;
16+ let values ;
17+
18+ if ( github_id ) {
19+ query = `
20+ SELECT * FROM faucet.transactions
21+ WHERE
22+ (wallet_address = $1) OR
23+ (ip_address = $2) OR
24+ (github_username = $3)
25+ ORDER BY timestamp DESC
26+ LIMIT $4;
27+ ` ;
28+ values = [ wallet_address , ip_address , github_id , queryLimit ] ;
29+ } else {
30+ query = `
31+ SELECT * FROM faucet.transactions
32+ WHERE
33+ (wallet_address = $1) OR
34+ (ip_address = $2)
35+ ORDER BY timestamp DESC
36+ LIMIT $3;
37+ ` ;
38+ values = [ wallet_address , ip_address , queryLimit ] ;
39+ }
2440
25- const values = [ wallet_address || null , github_username || null , ip_address || null ] ;
2641 const result = await db . query ( query , values ) ;
27- return result . rows [ 0 ] ; // Returns the most recent transaction found
42+ return result . rows ;
2843} ;
2944
3045// Not currently needed, but may be used for implementing TTL
0 commit comments