Migrate visits view #135

Merged
jsegarra merged 2 commits from wbuezas/hedera-web-mindshore:feature/visits-view into beta 2025-04-02 21:42:14 +00:00
1 changed files with 11 additions and 18 deletions

View File

@ -10,7 +10,7 @@ import { useAppStore } from 'stores/app';
import { storeToRefs } from 'pinia';
const { t } = useI18n();
const jApi = inject('jApi');
const api = inject('api');
const route = useRoute();
const router = useRouter();
const appStore = useAppStore();
@ -24,28 +24,21 @@ const visitsData = ref(null);
const getVisits = async () => {
try {
loading.value = true;
const [visitsResponse] = await jApi.query(
`SELECT browser,
MIN(CAST(version AS DECIMAL(4,1))) minVersion,
MAX(CAST(version AS DECIMAL(4,1))) maxVersion,
MAX(c.stamp) lastVisit,
COUNT(DISTINCT c.id) visits,
SUM(a.firstAccessFk = c.id AND v.firstAgentFk = a.id) newVisits
FROM visitUser e
JOIN visitAccess c ON c.id = e.accessFk
JOIN visitAgent a ON a.id = c.agentFk
JOIN visit v ON v.id = a.visitFk
WHERE c.stamp BETWEEN TIMESTAMP(#from,'00:00:00') AND TIMESTAMP(#to,'23:59:59')
GROUP BY browser ORDER BY visits DESC`,
{
const { data } = await api.get('visitUsers/getVisits', {
params: {
from: date(from.value),
to: date(to.value)
}
);
visitsData.value = visitsResponse;
loading.value = false;
});
if (!data || !data.length) return;
visitsData.value = data[0];
} catch (error) {
console.error('Error getting visits:', error);
} finally {
loading.value = false;
}
};