Author Topic: [VAM2.6.2] Error in flights per day in current month stats  (Read 903 times)

Timothee

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
[VAM2.6.2] Error in flights per day in current month stats
« on: April 30, 2017, 11:34:40 AM »
Hey

For those who are using VAM for more than a year may have noticed that the statistics (global and pilot) for flights per day in current month do not show the correct values anymore.
The calculation ignores the current year and adds all flights per day, no matter what year they took part. Say I made 2 flights in 2016-04-30 and 4 flights in 2017-04-30 the statistic will show 6 flights for today.

To correct this I changed the following two SQL queries.

vam/stats.php (line 38)
Code: [Select]
$sql2 = "select IFNULL(sum(c),0) as co from v_flights_pilots where date_format(flightdate,'%m%Y')=date_format(now(),'%m%Y')  and date_format(flightdate,'%d')=$i";

vam/pilot_profile_stats_sql.php (line 274)
Code: [Select]
$sql2 = "select IFNULL(sum(c),0) as co from v_flights_pilots where pilot=$pilotid and date_format(flightdate,'%m%Y')=date_format(now(),'%m%Y') and date_format(flightdate,'%d')=$i";

Timothee

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: [VAM2.6.2] Error in flights per day in current month stats
« Reply #1 on: May 01, 2017, 11:29:15 AM »
And the same problem exists for the tables HOURS PER YEAR AND MONTH and FLIGHTS PER YEAR AND MONTH in the global statistics. Not sure if this has been reported somewhere already.
The following queries are missing the group by year.

vam/pilots_flights_per_months.php (line 19-21)
Code: [Select]
$sql = "select gva.gvauser_id, callsign, name, surname ,mes, ye,SUM(num) as num_per_month from v_flights_counter v inner join gvausers gva
on gva.gvauser_id = v.gvauser_id
group by gvauser_id, ye, mes order by ye asc,mes asc,num_per_month desc";

vam/pilots_hours_per_months.php (line 19-21)
Code: [Select]
$sql = "select gva.gvauser_id, callsign, name, surname ,mes, ye,SUM(dur) as time_per_month from v_hours_counter v inner join gvausers gva
on gva.gvauser_id = v.gvauser_id
group by gvauser_id, ye, mes order by ye asc,mes asc,time_per_month desc";

VAM

  • Administrator
  • Hero Member
  • *****
  • Posts: 1328
    • View Profile
    • virtual Airlines Manager
Re: [VAM2.6.2] Error in flights per day in current month stats
« Reply #2 on: May 20, 2017, 12:05:03 AM »
thansk fo the bugfix.
I want to provide a new hotfix soon, the problem is that in the last weeks my free time is 0, I thik soon will be back again with VAM to collect bugfix and provide more and more funtionality
VAM Creator and programmer.