Skip to content

Commit 6ca743d

Browse files
committed
Updated API endpoint.
1 parent 0b54b3b commit 6ca743d

2 files changed

Lines changed: 57 additions & 52 deletions

File tree

data/solr-config.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"APILink": "https://fcdo2.iati.cloud/",
2+
"APILink": "https://fcdo.iati.cloud/",
33
"DefaultFieldsToReturn": "id, iati_identifier, reporting_org_ref, reporting_org_narrative, title_narrative_first, title_narrative, description_narrative, activity_date_iso_date, activity_date_start_actual, activity_date_end_planned, activity_status_code, humanitarian, tag_code, tag, child_aggregation_*, activity_plus_child_aggregation*, activity_aggregation_*, default_currency, activity_date_start_common_f, activity_date_end_common_f, activity_date_start_common, activity_date_end_common",
44
"DefaultFieldsToSearch":
55
[
@@ -38,71 +38,71 @@
3838
{
3939
"title": "Activity Status",
4040
"field": "activity_status_code",
41-
"url": "api/v2/activity/?facet=on&facet.field=activity_status_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
41+
"url": "search/activity/?facet=on&facet.field=activity_status_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
4242
"mappingFile": "data/mappingSolrFilters/activity_status.json",
4343
"defaultValue": "2",
4444
"isFieldTypeString": "0"
4545
},
4646
{
4747
"title": "Government Department(s)",
4848
"field": "reporting_org_ref",
49-
"url": "api/v2/activity/?facet=on&facet.field=reporting_org_ref&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
49+
"url": "search/activity/?facet=on&facet.field=reporting_org_ref&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
5050
"mappingFile": "data/custom-codes/ogds.json",
5151
"defaultValue": "",
5252
"isFieldTypeString": "1"
5353
},
5454
{
5555
"title": "Tags",
5656
"field": "tag_code",
57-
"url": "api/v2/activity/?facet=on&facet.field=tag_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
57+
"url": "search/activity/?facet=on&facet.field=tag_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
5858
"mappingFile": "data/custom-codes/policy-priorities.json",
5959
"defaultValue": "",
6060
"isFieldTypeString": "1"
6161
},
6262
{
6363
"title": "Sectors",
6464
"field": "sector_code",
65-
"url": "api/v2/activity/?facet=on&facet.field=sector_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
65+
"url": "search/activity/?facet=on&facet.field=sector_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
6666
"mappingFile": "sectorHierarchies.json",
6767
"defaultValue": "",
6868
"isFieldTypeString": "0"
6969
},
7070
{
7171
"title": "Participating Orgs",
7272
"field": "participating_org_ref",
73-
"url": "api/v2/activity/?facet=on&facet.field=participating_org_ref&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND participating_org_role:4 AND ",
73+
"url": "search/activity/?facet=on&facet.field=participating_org_ref&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND participating_org_role:4 AND ",
7474
"mappingFile": "iati_publishers_list.json",
7575
"defaultValue": "",
7676
"isFieldTypeString": "1"
7777
},
7878
{
7979
"title": "Activity Dates",
8080
"field": "activity_date_iso_date",
81-
"url": "api/v2/activity/?facet=on&facet.field=activity_date_iso_date&facet.limit=-1&facet.mincount=1&q=participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
81+
"url": "search/activity/?facet=on&facet.field=activity_date_iso_date&facet.limit=-1&facet.mincount=1&q=participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
8282
"mappingFile": "",
8383
"defaultValue": "",
8484
"isFieldTypeString": "1"
8585
},
8686
{
8787
"title": "Benefiting Countries",
8888
"field": "recipient_country_code",
89-
"url": "api/v2/activity/?facet=on&facet.field=recipient_country_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
89+
"url": "search/activity/?facet=on&facet.field=recipient_country_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
9090
"mappingFile": "data/country-codes/country_codes.json",
9191
"defaultValue": "",
9292
"isFieldTypeString": "1"
9393
},
9494
{
9595
"title": "Benefiting Regions",
9696
"field": "recipient_region_code",
97-
"url": "api/v2/activity/?facet=on&facet.field=recipient_region_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
97+
"url": "search/activity/?facet=on&facet.field=recipient_region_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
9898
"mappingFile": "data/regionCodes.json",
9999
"defaultValue": "",
100100
"isFieldTypeString": "1"
101101
},
102102
{
103103
"title": "Document Categories",
104104
"field": "document_link_category_code",
105-
"url": "api/v2/activity/?facet=on&facet.field=document_link_category_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
105+
"url": "search/activity/?facet=on&facet.field=document_link_category_code&facet.limit=-1&facet.mincount=1&q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
106106
"mappingFile": "data/custom-codes/DocumentCategory.json",
107107
"defaultValue": "",
108108
"isFieldTypeString": "1"
@@ -113,71 +113,71 @@
113113
{
114114
"title": "Activity Status",
115115
"field": "activity_status_code",
116-
"url": "api/v2/activity/?facet=on&facet.field=activity_status_code&facet.limit=-1&facet.mincount=1&q.op=AND&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*) ",
116+
"url": "search/activity/?facet=on&facet.field=activity_status_code&facet.limit=-1&facet.mincount=1&q.op=AND&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*) ",
117117
"mappingFile": "data/mappingSolrFilters/activity_status.json",
118118
"defaultValue": "2",
119119
"isFieldTypeString": "0"
120120
},
121121
{
122122
"title": "Government Department(s)",
123123
"field": "reporting_org_ref",
124-
"url": "api/v2/activity/?facet=on&facet.field=reporting_org_ref&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*) ",
124+
"url": "search/activity/?facet=on&facet.field=reporting_org_ref&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*) ",
125125
"mappingFile": "data/custom-codes/ogds.json",
126126
"defaultValue": "",
127127
"isFieldTypeString": "1"
128128
},
129129
{
130130
"title": "Tags",
131131
"field": "tag_code",
132-
"url": "api/v2/activity/?facet=on&facet.field=tag_code&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*) ",
132+
"url": "search/activity/?facet=on&facet.field=tag_code&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*) ",
133133
"mappingFile": "data/custom-codes/policy-priorities.json",
134134
"defaultValue": "",
135135
"isFieldTypeString": "1"
136136
},
137137
{
138138
"title": "Sectors",
139139
"field": "sector_code",
140-
"url": "api/v2/activity/?facet=on&facet.field=sector_code&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*) ",
140+
"url": "search/activity/?facet=on&facet.field=sector_code&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*) ",
141141
"mappingFile": "sectorHierarchies.json",
142142
"defaultValue": "",
143143
"isFieldTypeString": "0"
144144
},
145145
{
146146
"title": "Participating Orgs",
147147
"field": "participating_org_ref",
148-
"url": "api/v2/activity/?facet=on&facet.field=participating_org_ref&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*)&fq=participating_org_role:4 ",
148+
"url": "search/activity/?facet=on&facet.field=participating_org_ref&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*)&fq=participating_org_role:4 ",
149149
"mappingFile": "iati_publishers_list.json",
150150
"defaultValue": "",
151151
"isFieldTypeString": "1"
152152
},
153153
{
154154
"title": "Activity Dates",
155155
"field": "activity_date_iso_date",
156-
"url": "api/v2/activity/?facet=on&facet.field=activity_date_iso_date&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*)",
156+
"url": "search/activity/?facet=on&facet.field=activity_date_iso_date&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*)",
157157
"mappingFile": "",
158158
"defaultValue": "",
159159
"isFieldTypeString": "1"
160160
},
161161
{
162162
"title": "Benefiting Countries",
163163
"field": "recipient_country_code",
164-
"url": "api/v2/activity/?facet=on&facet.field=recipient_country_code&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*)",
164+
"url": "search/activity/?facet=on&facet.field=recipient_country_code&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*)",
165165
"mappingFile": "data/country-codes/country_codes.json",
166166
"defaultValue": "",
167167
"isFieldTypeString": "1"
168168
},
169169
{
170170
"title": "Benefiting Regions",
171171
"field": "recipient_region_code",
172-
"url": "api/v2/activity/?facet=on&facet.field=recipient_region_code&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*)",
172+
"url": "search/activity/?facet=on&facet.field=recipient_region_code&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*)",
173173
"mappingFile": "data/regionCodes.json",
174174
"defaultValue": "",
175175
"isFieldTypeString": "1"
176176
},
177177
{
178178
"title": "Document Categories",
179179
"field": "document_link_category_code",
180-
"url": "api/v2/activity/?facet=on&facet.field=document_link_category_code&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*)",
180+
"url": "search/activity/?facet=on&facet.field=document_link_category_code&facet.limit=-1&facet.mincount=1&fq=hierarchy:1&fq=participating_org_ref:(GB-GOV-* OR GB-COH-*)",
181181
"mappingFile": "data/custom-codes/DocumentCategory.json",
182182
"defaultValue": "",
183183
"isFieldTypeString": "1"
@@ -187,28 +187,28 @@
187187
{
188188
"F":
189189
{
190-
"url": "/api/v2/activity/?q.op=AND&sort=if(termfreq(reporting_org_ref,'GB-GOV-1'),1,if(termfreq(reporting_org_ref,'GB-GOV-2'),2,99)) asc, score desc&hl=on&hl.requireFieldMatch=true&hl.fl=title_narrative,title_narrative_first,description_narrative,iati_identifier,transaction_description_narrative,reporting_org_ref,recipient_country_name,document_link_title_narrative_text,transaction,reporting_org_narrative,participating_org_narrative&fq=hierarchy:1&fq=participating_org_ref:GB-GOV-*",
190+
"url": "/search/activity/?q.op=AND&sort=if(termfreq(reporting_org_ref,'GB-GOV-1'),1,if(termfreq(reporting_org_ref,'GB-GOV-2'),2,99)) asc, score desc&hl=on&hl.requireFieldMatch=true&hl.fl=title_narrative,title_narrative_first,description_narrative,iati_identifier,transaction_description_narrative,reporting_org_ref,recipient_country_name,document_link_title_narrative_text,transaction,reporting_org_narrative,participating_org_narrative&fq=hierarchy:1&fq=participating_org_ref:GB-GOV-*",
191191
"fieldDependency": "",
192192
"comments": "This search category is related to the free text search of DevTracker"
193193
},
194194
"C":
195195
{
196-
"url": "/api/v2/activity/?q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
196+
"url": "/search/activity/?q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
197197
"fieldDependency": "recipient_country_code"
198198
},
199199
"R":
200200
{
201-
"url": "/api/v2/activity/?q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
201+
"url": "/search/activity/?q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
202202
"fieldDependency": "recipient_region_code"
203203
},
204204
"O":
205205
{
206-
"url": "/api/v2/activity/?q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
206+
"url": "/search/activity/?q=hierarchy:1 AND participating_org_ref:(GB-GOV-* OR GB-COH-*) AND ",
207207
"fieldDependency": "reporting_org_ref"
208208
},
209209
"S":
210210
{
211-
"url": "/api/v2/activity/?q=hierarchy:1 AND participating_org_ref:GB-GOV-* AND ",
211+
"url": "/search/activity/?q=hierarchy:1 AND participating_org_ref:GB-GOV-* AND ",
212212
"fieldDependency": "sector_code"
213213
}
214214
},

devtracker.rb

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@
6161
# Developer Machine: set global settings
6262
#set :oipa_api_url, 'https://fcdo-direct-indexing.iati.cloud/search/'#'https://fcdo.iati.cloud/search/'#'https://fcdo-direct-indexing.iati.cloud/search/'#'https://devtracker.fcdo.gov.uk/api/'
6363
# set :oipa_api_url, 'https://devtracker-entry.oipa.nl/api/'
64-
set :oipa_api_url, 'https://fcdo2.iati.cloud/api/v2/'
64+
# set :oipa_api_url, 'https://fcdo.iati.cloud/search/'
6565
# set :oipa_api_url, 'https://fcdo-direct-indexing.iati.cloud/search/'
6666
# set :bind, '0.0.0.0' # Allows for vagrant pass-through whilst debugging
6767

6868
# Server Machine: set global settings to use varnish cache
69-
#set :oipa_api_url, 'http://127.0.0.1:6081/search/'
69+
set :oipa_api_url, 'http://127.0.0.1:6081/search/'
7070
set :prod_api_url, 'https://fcdo.iati.cloud'
7171
set :dev_api_url, 'https://fcdo-staging.iati.cloud'
7272

@@ -87,8 +87,8 @@
8787
set :google_recaptcha_publicKey, ENV["GOOGLE_PUBLIC_KEY"]
8888
set :google_recaptcha_privateKey, ENV["GOOGLE_PRIVATE_KEY"]
8989

90-
set :raise_errors, false
91-
set :show_exceptions, false
90+
set :raise_errors, true
91+
set :show_exceptions, true
9292
set :log_api_calls, false
9393

9494
set :devtracker_page_title, ''
@@ -102,12 +102,14 @@
102102
top5countries = ''
103103
Benchmark.bm(7) do |x|
104104
x.report("Loading Time: ") {
105-
if (!canLoadFromCache('top5Countries'))
106-
storeCacheData(get_top_5_countriesv2(), 'top5Countries')
107-
top5countries = getCacheData('top5Countries')
108-
else
109-
top5countries = getCacheData('top5Countries')
110-
end
105+
# if (!canLoadFromCache('top5Countries'))
106+
# storeCacheData(get_top_5_countriesv2(), 'top5Countries')
107+
# top5countries = getCacheData('top5Countries')
108+
# else
109+
# top5countries = getCacheData('top5Countries')
110+
# end
111+
#storeCacheData(get_top_5_countriesv2(), 'top5Countries')
112+
top5countries = get_top_5_countriesv2() #getCacheData('top5Countries')
111113
#oipa v3.1
112114
}
113115
end
@@ -118,25 +120,28 @@
118120
# Example of setting up a cookie from server end
119121
# response.set_cookie('my_cookie', 'value_of_cookie')
120122
what_we_do = ''
121-
if (!canLoadFromCache('what_we_do'))
122-
## logic
123-
## get budget data, then check if they fall within date range
124-
## do a summation of the budget amount within date range
125-
## pick dac5 sector code and then get the underlying high level sector code
126-
## if the sector is present, add the new budget info to this sector
127-
## Else create a new ref to the high level sector code and add
128-
## budget value starting from 0
129-
## pick budget percentage for each dac5 sector code2
130-
## calculate the budget amount against that perentage and add it to
131-
## the high level related sector code
132-
newApiCall = settings.oipa_api_url + "activity?q=participating_org_ref:GB-GOV-* AND reporting_org_ref:(#{settings.goverment_department_ids.gsub(","," OR ")}) AND budget_period_start_iso_date:[#{settings.current_first_day_of_financial_year}T00:00:00Z TO *] AND budget_period_end_iso_date:[* TO #{settings.current_last_day_of_financial_year}T00:00:00Z]&fl=iati_identifier,budget_value,recipient_country_code,recipient_region_code,budget_period_start_iso_date,budget_period_end_iso_date,sector_code,sector_percentage,&rows=50000"
123+
newApiCall = settings.oipa_api_url + "activity?q=participating_org_ref:GB-GOV-* AND reporting_org_ref:(#{settings.goverment_department_ids.gsub(","," OR ")}) AND budget_period_start_iso_date:[#{settings.current_first_day_of_financial_year}T00:00:00Z TO *] AND budget_period_end_iso_date:[* TO #{settings.current_last_day_of_financial_year}T00:00:00Z]&fl=iati_identifier,budget_value,recipient_country_code,recipient_region_code,budget_period_start_iso_date,budget_period_end_iso_date,sector_code,sector_percentage,&rows=50000"
124+
pulledData = RestClient.get newApiCall
125+
what_we_do = high_level_sector_listv2(pulledData, 'top_five_sectors')
126+
# if (!canLoadFromCache('what_we_do'))
127+
# ## logic
128+
# ## get budget data, then check if they fall within date range
129+
# ## do a summation of the budget amount within date range
130+
# ## pick dac5 sector code and then get the underlying high level sector code
131+
# ## if the sector is present, add the new budget info to this sector
132+
# ## Else create a new ref to the high level sector code and add
133+
# ## budget value starting from 0
134+
# ## pick budget percentage for each dac5 sector code2
135+
# ## calculate the budget amount against that perentage and add it to
136+
# ## the high level related sector code
137+
# newApiCall = settings.oipa_api_url + "activity?q=participating_org_ref:GB-GOV-* AND reporting_org_ref:(#{settings.goverment_department_ids.gsub(","," OR ")}) AND budget_period_start_iso_date:[#{settings.current_first_day_of_financial_year}T00:00:00Z TO *] AND budget_period_end_iso_date:[* TO #{settings.current_last_day_of_financial_year}T00:00:00Z]&fl=iati_identifier,budget_value,recipient_country_code,recipient_region_code,budget_period_start_iso_date,budget_period_end_iso_date,sector_code,sector_percentage,&rows=50000"
133138

134-
pulledData = RestClient.get newApiCall
135-
storeCacheData(high_level_sector_listv2(pulledData, 'top_five_sectors'), 'what_we_do')
136-
what_we_do = getCacheData('what_we_do')
137-
else
138-
what_we_do = getCacheData('what_we_do')
139-
end
139+
# pulledData = RestClient.get newApiCall
140+
# storeCacheData(high_level_sector_listv2(pulledData, 'top_five_sectors'), 'what_we_do')
141+
# what_we_do = getCacheData('what_we_do')
142+
# else
143+
# what_we_do = getCacheData('what_we_do')
144+
# end
140145

141146
whatWeDoTotal = what_we_do.first['budget']
142147
top5countries = top5countries.select{|i| i.has_key?('budget')}

0 commit comments

Comments
 (0)