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):
|
def get(self, request, *args, **kwargs):
|
||||||
queryset = self.get_queryset()
|
queryset = self.get_queryset()
|
||||||
serializer = BhavCopyEquitySerializer(queryset, many=True)
|
serializer = BhavCopyEquitySerializer(queryset, many=True)
|
||||||
print("without redis")
|
|
||||||
return Response(serializer.data)
|
return Response(serializer.data)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -29,7 +28,5 @@ class BhavCopyEquityDefaultRedisView(generics.RetrieveAPIView):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
queryset = self.get_queryset()
|
queryset = self.get_queryset()
|
||||||
serializer = BhavCopyEquitySerializer(queryset, many=True)
|
serializer = BhavCopyEquitySerializer(queryset, many=True)
|
||||||
print("without redis")
|
|
||||||
return Response(serializer.data)
|
return Response(serializer.data)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,14 @@
|
||||||
</v-icon>
|
</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-spacer></v-spacer>
|
<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
|
<v-text-field
|
||||||
ref="searchField"
|
ref="searchField"
|
||||||
v-model="sc_name"
|
v-model="sc_name"
|
||||||
|
|
@ -30,6 +38,7 @@
|
||||||
:items-per-page="10"
|
:items-per-page="10"
|
||||||
:footer-props="{
|
:footer-props="{
|
||||||
showFirstLastPage: true,
|
showFirstLastPage: true,
|
||||||
|
itemsPerPageOptions: [10, 20, 30, 40, 50, -1],
|
||||||
firstIcon: 'mdi-arrow-collapse-left',
|
firstIcon: 'mdi-arrow-collapse-left',
|
||||||
lastIcon: 'mdi-arrow-collapse-right',
|
lastIcon: 'mdi-arrow-collapse-right',
|
||||||
prevIcon: 'mdi-minus',
|
prevIcon: 'mdi-minus',
|
||||||
|
|
@ -56,7 +65,6 @@
|
||||||
rows.push([this.headersData.map(header => element[header.value])])
|
rows.push([this.headersData.map(header => element[header.value])])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// console.log(rows)
|
|
||||||
let csvContent = "data:text/csv;charset=utf-8,"
|
let csvContent = "data:text/csv;charset=utf-8,"
|
||||||
+ rows.map(e => e.join(",")).join("\n");
|
+ rows.map(e => e.join(",")).join("\n");
|
||||||
var encodedUri = encodeURI(csvContent);
|
var encodedUri = encodeURI(csvContent);
|
||||||
|
|
@ -66,6 +74,17 @@
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
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: {
|
computed: {
|
||||||
headers() {
|
headers() {
|
||||||
|
|
@ -76,7 +95,11 @@
|
||||||
return {
|
return {
|
||||||
sc_name: '',
|
sc_name: '',
|
||||||
apiData: [],
|
apiData: [],
|
||||||
apiEndpointSelected: 'bhavcopyequity',
|
apiEndpointSelected: { endpoint: 'bhavcopyequity', text: "Plain Endpoint" },
|
||||||
|
apiEndpoints: [
|
||||||
|
{ endpoint: 'bhavcopyequity', text: "Plain Endpoint" },
|
||||||
|
{ endpoint: 'bhavcopyequitydefaultredis', text: "Default Redis Cache" }
|
||||||
|
],
|
||||||
headersData: [
|
headersData: [
|
||||||
{text: 'Stock Code', value: 'sc_code'},
|
{text: 'Stock Code', value: 'sc_code'},
|
||||||
{
|
{
|
||||||
|
|
@ -102,14 +125,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
getAPI.get(`/${this.apiEndpointSelected}/`,)
|
this.populateApiData()
|
||||||
.then(response => {
|
|
||||||
console.log('BhavCopyEquity API has recieved data')
|
|
||||||
this.apiData = response.data
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log(err)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue