filter tags usage by date

This commit is contained in:
Ishaan Jaff 2024-05-13 17:15:39 -07:00
parent 51961387a2
commit 5dfa0ed196

View file

@ -153,6 +153,19 @@ const UsagePage: React.FC<UsagePageProps> = ({
console.log("End user data updated successfully", newTopUserData); console.log("End user data updated successfully", newTopUserData);
setTopUsers(newTopUserData); setTopUsers(newTopUserData);
}
const updateTagSpendData = async (startTime: Date | undefined, endTime: Date | undefined) => {
if (!startTime || !endTime || !accessToken) {
return;
}
let top_tags = await tagsSpendLogsCall(accessToken, startTime.toISOString(), endTime.toISOString());
setTopTagsData(top_tags.top_10_tags);
console.log("Tag spend data updated successfully");
} }
function formatDate(date: Date) { function formatDate(date: Date) {
@ -218,7 +231,7 @@ const UsagePage: React.FC<UsagePageProps> = ({
setTotalSpendPerTeam(total_spend_per_team); setTotalSpendPerTeam(total_spend_per_team);
//get top tags //get top tags
const top_tags = await tagsSpendLogsCall(accessToken); const top_tags = await tagsSpendLogsCall(accessToken, dateValue.from?.toISOString(), dateValue.to?.toISOString());
setTopTagsData(top_tags.top_10_tags); setTopTagsData(top_tags.top_10_tags);
// get spend per end-user // get spend per end-user
@ -459,6 +472,15 @@ const UsagePage: React.FC<UsagePageProps> = ({
<TabPanel> <TabPanel>
<Grid numItems={2} className="gap-2 h-[75vh] w-full mb-4"> <Grid numItems={2} className="gap-2 h-[75vh] w-full mb-4">
<Col numColSpan={2}> <Col numColSpan={2}>
<DateRangePicker
className="mb-4"
enableSelect={true}
value={dateValue}
onValueChange={(value) => {
setDateValue(value);
updateTagSpendData(value.from, value.to); // Call updateModelMetrics with the new date range
}}
/>
<Card> <Card>
<Title>Spend Per Tag - Last 30 Days</Title> <Title>Spend Per Tag - Last 30 Days</Title>