Skip to content

Commit

Permalink
Количество пропущеных звонков за 30 рабочих дней
Browse files Browse the repository at this point in the history
  • Loading branch information
evskorobogatij committed Oct 5, 2020
1 parent 03a9c37 commit 167e2d5
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
2 changes: 2 additions & 0 deletions assets/js/components/App/Appw.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import CallsList from '../../pages/CallsList/CallsList'
import './Appw.scss'
import CallsInputGraph from "../../pages/CallsGraph/CallsInputGraph";
import CallsAnsweredGraph from "../../pages/CallsGraph/CallsAnsweredGraph";
import CallsAbandonGraph from "../../pages/CallsGraph/CallsAbandonGraph";

function App() {

Expand Down Expand Up @@ -42,6 +43,7 @@ function App() {
<Route path={"/answered_calls_log"} >
<CallsAnsweredGraph/>
</Route>
<Route path={"/abandon_calls_log"} component={CallsAbandonGraph}/>
<Redirect from={"/"} to={"/dashboard"} />
</RouteSwitch>
</div>
Expand Down
67 changes: 67 additions & 0 deletions assets/js/pages/CallsGraph/CallsAbandonGraph.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, {useEffect, useMemo, useState} from "react";
import moment from "moment";
import {Link} from "react-router-dom";
import {Button} from "primereact/button";
import {Chart} from "primereact/components/chart/Chart";

import "./CallsGraph.scss"

function CallsAbandonGraph() {

const [graphData,setGraphData] = useState({
data : [],
labels: []
})

React.useEffect(()=>{
// let s_date = moment(props.date).format("YYYY-MM-DD");
fetch(`/api/abandon_calls_log`).then(response => response.json()).then(
result => {
let descr = []
let values= []
result.reverse().map((item)=>{
descr.push(moment(item.dt).lang('ru').format("DD MMM"))
values.push(item.cn)
})
setGraphData({
data: values,
labels: descr
})
}
)
},[])

useEffect(()=>{
console.log(graphData)
},[graphData])

const basicData = useMemo(()=>(
{
labels: graphData.labels,
datasets: [
{
label: 'Пропущеные звонки',
backgroundColor: '#f9c851',
data: graphData.data
}
]
}
),[graphData])

return (
<>
<div className={"CallGraph-title"}>
<Link to={"dasboard"} >
<Button icon="pi pi-chevron-left" className={"p-button-outlined"} label={"Назад"} />
</Link>
<h1>Количество пропущеных звонков по дням</h1>
</div>

<Chart type={"bar"} data={basicData} height={120}/>

</>
)
}

export default CallsAbandonGraph;

4 changes: 3 additions & 1 deletion assets/js/pages/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export default function Dashboard(props) {
</Link>
</div>
<div className="p-col-12 p-sm-6 p-md-6 p-lg-3">
<TelCard title={"Пропущено"} detail={"Пропущеные звонки"} call_type={'notanswered'} count={callsStatus.abandon}/>
<Link to={"abandon_calls_log"} style={{ textDecoration: 'none' }} >
<TelCard title={"Пропущено"} detail={"Пропущеные звонки"} call_type={'notanswered'} count={callsStatus.abandon}/>
</Link>
</div>
<div className="p-col-12 p-sm-6 p-md-6 p-lg-3">
<TelCard title={"Отклонено"} detail={"Оператор отклонил звонок"} call_type={'abandon'} count={callsStatus.rejected_calls}/>
Expand Down
10 changes: 10 additions & 0 deletions src/Controller/ApiCoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,14 @@ public function answered_calls_log(CallsRepository $callsRepository):JsonRespons
$data = $callsRepository->answered_calls_log();
return $this->json($data);
}

/**
* @Route("/abandon_calls_log")
* @param CallsRepository $callsRepository
* @return JsonResponse
*/
public function abandon_calls_log(CallsRepository $callsRepository):JsonResponse{
$data = $callsRepository->abandon_calls_log();
return $this->json($data);
}
}
9 changes: 9 additions & 0 deletions src/Repository/CallsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,13 @@ function answered_calls_log(){
return $data;
}

function abandon_calls_log(){
$str="select date_format(time,'%Y-%m-%d') as dt, count(1) cn from queue_log
where event='ABANDON'
group by dt
order by dt desc
limit 30";
$data = $this->conn->fetchAll($str);
return $data;
}
}

0 comments on commit 167e2d5

Please sign in to comment.