@@ -21,21 +21,27 @@ def feature!
21
21
url = URI . parse ( "#{ ENV [ 'PRIVATE_URL' ] } /api/v1/protips/feature.json" ) . to_s
22
22
protip_json = MultiJson . load ( protip_hash . to_json )
23
23
24
- RestClient . post ( url , protip_json , accept : :json , content_type : 'application/json' )
24
+ Rails . cache . fetch ( [ 'hawt_feature' , url , protip_hash [ :public_id ] ] , expires : 1 . hour ) do
25
+ RestClient . post ( url , protip_json , accept : :json , content_type : 'application/json' )
26
+ end
25
27
end
26
28
27
29
def unfeature!
28
30
url = URI . parse ( "#{ ENV [ 'PRIVATE_URL' ] } /api/v1/protips/unfeature.json" ) . to_s
29
31
protip_json = MultiJson . load ( protip_hash . to_json )
30
32
31
- RestClient . post ( url , protip_json , accept : :json , content_type : 'application/json' )
33
+ Rails . cache . fetch ( [ 'hawt_unfeature' , url , protip_hash [ :public_id ] ] , expires : 1 . hour ) do
34
+ RestClient . post ( url , protip_json , accept : :json , content_type : 'application/json' )
35
+ end
32
36
end
33
37
34
38
def hawt?
35
39
url = URI . parse ( "#{ ENV [ 'PRIVATE_URL' ] } /api/v1/protips/hawt.json" ) . to_s
36
40
protip_json = MultiJson . load ( protip_hash . to_json )
37
41
38
- JSON . parse ( RestClient . post ( url , protip_json , accept : :json , content_type : 'application/json' ) . to_s ) [ 'hawt?' ]
42
+ Rails . cache . fetch ( [ 'hawt_hawt' , url , protip_hash [ :public_id ] ] , expires : 1 . hour ) do
43
+ JSON . parse ( RestClient . post ( url , protip_json , accept : :json , content_type : 'application/json' ) . to_s ) [ 'hawt?' ]
44
+ end
39
45
end
40
46
end
41
47
0 commit comments