mirror of https://github.com/BOINC/boinc.git
- client: Avoid showing too-old stats in GUI.
Trim old credit statistics on each GUI RPC as well as each scheduler reply.
This commit is contained in:
parent
35390ef974
commit
68331492ac
|
@ -614,10 +614,9 @@ static void handle_acct_mgr_info(GUI_RPC_CONN& grc) {
|
|||
|
||||
static void handle_get_statistics(GUI_RPC_CONN& grc) {
|
||||
grc.mfout.printf("<statistics>\n");
|
||||
for (std::vector<PROJECT*>::iterator i=gstate.projects.begin();
|
||||
i!=gstate.projects.end();++i
|
||||
) {
|
||||
(*i)->write_statistics(grc.mfout,true);
|
||||
for (unsigned int i=0; i<gstate.projects.size(); i++) {
|
||||
PROJECT* p = gstate.projects[i];
|
||||
p->write_statistics(grc.mfout);
|
||||
}
|
||||
grc.mfout.printf("</statistics>\n");
|
||||
}
|
||||
|
|
|
@ -551,9 +551,10 @@ void PROJECT::copy_state_fields(PROJECT& p) {
|
|||
use_symlinks = p.use_symlinks;
|
||||
}
|
||||
|
||||
// Write project statistic to project statistics file
|
||||
// Write project statistic to GUI RPC reply
|
||||
//
|
||||
int PROJECT::write_statistics(MIOFILE& out, bool /*gui_rpc*/) {
|
||||
int PROJECT::write_statistics(MIOFILE& out) {
|
||||
trim_statistics();
|
||||
out.printf(
|
||||
"<project_statistics>\n"
|
||||
" <master_url>%s</master_url>\n",
|
||||
|
@ -831,3 +832,26 @@ bool PROJECT::waiting_until_min_rpc_time() {
|
|||
return (min_rpc_time > gstate.now);
|
||||
}
|
||||
|
||||
void PROJECT::trim_statistics() {
|
||||
double cutoff = dday() - config.save_stats_days*86400;
|
||||
// delete old stats; fill in the gaps if some days missing
|
||||
//
|
||||
while (!statistics.empty()) {
|
||||
DAILY_STATS& ds = statistics[0];
|
||||
if (ds.day >= cutoff) {
|
||||
break;
|
||||
}
|
||||
if (statistics.size() > 1) {
|
||||
DAILY_STATS& ds2 = statistics[1];
|
||||
if (ds2.day <= cutoff) {
|
||||
statistics.erase(statistics.begin());
|
||||
} else {
|
||||
ds.day = cutoff;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ds.day = cutoff;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,8 +305,9 @@ struct PROJECT : PROJ_AM {
|
|||
std::vector<DAILY_STATS> statistics;
|
||||
int parse_statistics(MIOFILE&);
|
||||
int parse_statistics(FILE*);
|
||||
int write_statistics(MIOFILE&, bool gui_rpc=false);
|
||||
int write_statistics(MIOFILE&);
|
||||
int write_statistics_file();
|
||||
void trim_statistics();
|
||||
|
||||
void suspend();
|
||||
void resume();
|
||||
|
|
|
@ -608,28 +608,7 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
|
|||
// add new record if vector is empty or we have a new day
|
||||
//
|
||||
if (project->statistics.empty() || project->statistics.back().day!=dday()) {
|
||||
double cutoff = dday() - config.save_stats_days*86400;
|
||||
// delete old stats; fill in the gaps if some days missing
|
||||
//
|
||||
while (!project->statistics.empty()) {
|
||||
DAILY_STATS& ds = project->statistics[0];
|
||||
if (ds.day >= cutoff) {
|
||||
break;
|
||||
}
|
||||
if (project->statistics.size() > 1) {
|
||||
DAILY_STATS& ds2 = project->statistics[1];
|
||||
if (ds2.day <= cutoff) {
|
||||
project->statistics.erase(project->statistics.begin());
|
||||
} else {
|
||||
ds.day = cutoff;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ds.day = cutoff;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
project->trim_statistics();
|
||||
DAILY_STATS nds;
|
||||
project->statistics.push_back(nds);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue