feat: add option to hit different endpoints
Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
This commit is contained in:
parent
41c3ba1d6b
commit
d2f5de31ce
2 changed files with 26 additions and 13 deletions
|
|
@ -18,7 +18,6 @@ class BhavCopyEquityView(generics.RetrieveAPIView):
|
|||
def get(self, request, *args, **kwargs):
|
||||
queryset = self.get_queryset()
|
||||
serializer = BhavCopyEquitySerializer(queryset, many=True)
|
||||
print("without redis")
|
||||
return Response(serializer.data)
|
||||
|
||||
|
||||
|
|
@ -29,7 +28,5 @@ class BhavCopyEquityDefaultRedisView(generics.RetrieveAPIView):
|
|||
def get(self, request, *args, **kwargs):
|
||||
queryset = self.get_queryset()
|
||||
serializer = BhavCopyEquitySerializer(queryset, many=True)
|
||||
print("without redis")
|
||||
return Response(serializer.data)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,14 @@
|
|||
</v-icon>
|
||||
</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
<v-select
|
||||
v-model="apiEndpointSelected.endpoint"
|
||||
:items="apiEndpoints"
|
||||
label="API Endpoint"
|
||||
v-on:change="populateApiData"
|
||||
item-value="endpoint"
|
||||
></v-select>
|
||||
<v-spacer></v-spacer>
|
||||
<v-text-field
|
||||
ref="searchField"
|
||||
v-model="sc_name"
|
||||
|
|
@ -30,6 +38,7 @@
|
|||
:items-per-page="10"
|
||||
:footer-props="{
|
||||
showFirstLastPage: true,
|
||||
itemsPerPageOptions: [10, 20, 30, 40, 50, -1],
|
||||
firstIcon: 'mdi-arrow-collapse-left',
|
||||
lastIcon: 'mdi-arrow-collapse-right',
|
||||
prevIcon: 'mdi-minus',
|
||||
|
|
@ -56,7 +65,6 @@
|
|||
rows.push([this.headersData.map(header => element[header.value])])
|
||||
}
|
||||
})
|
||||
// console.log(rows)
|
||||
let csvContent = "data:text/csv;charset=utf-8,"
|
||||
+ rows.map(e => e.join(",")).join("\n");
|
||||
var encodedUri = encodeURI(csvContent);
|
||||
|
|
@ -66,6 +74,17 @@
|
|||
document.body.appendChild(link);
|
||||
link.click();
|
||||
},
|
||||
populateApiData() {
|
||||
console.log(`Fetching data from ${this.apiEndpointSelected.endpoint} API`)
|
||||
getAPI.get(`/${this.apiEndpointSelected.endpoint}/`,)
|
||||
.then(response => {
|
||||
console.log('BhavCopyEquity API has recieved data')
|
||||
this.apiData = response.data
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
headers() {
|
||||
|
|
@ -76,7 +95,11 @@
|
|||
return {
|
||||
sc_name: '',
|
||||
apiData: [],
|
||||
apiEndpointSelected: 'bhavcopyequity',
|
||||
apiEndpointSelected: { endpoint: 'bhavcopyequity', text: "Plain Endpoint" },
|
||||
apiEndpoints: [
|
||||
{ endpoint: 'bhavcopyequity', text: "Plain Endpoint" },
|
||||
{ endpoint: 'bhavcopyequitydefaultredis', text: "Default Redis Cache" }
|
||||
],
|
||||
headersData: [
|
||||
{text: 'Stock Code', value: 'sc_code'},
|
||||
{
|
||||
|
|
@ -102,14 +125,7 @@
|
|||
}
|
||||
},
|
||||
created() {
|
||||
getAPI.get(`/${this.apiEndpointSelected}/`,)
|
||||
.then(response => {
|
||||
console.log('BhavCopyEquity API has recieved data')
|
||||
this.apiData = response.data
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
this.populateApiData()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue