Skip to content

Commit 68b9e44

Browse files
committed
Added estimated completion date and deadline difference columns
1 parent ff09b53 commit 68b9e44

File tree

2 files changed

+48
-45
lines changed

2 files changed

+48
-45
lines changed

clientgui/ViewWork.cpp

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ CWork::CWork() {
8585
m_fCPUTime = -1.0;
8686
m_fProgress = -1.0;
8787
m_fTimeToCompletion = -1.0;
88-
m_tReportDeadline = (time_t)0;
89-
m_tEstimatedCompletion = (time_t)0;
88+
m_fDeadlineDiff = -1.0;
89+
m_tReportDeadline = (time_t)-1;
90+
m_tEstimatedCompletion = (time_t)-1;
9091
}
9192

9293

@@ -100,6 +101,8 @@ CWork::~CWork() {
100101
m_strProgress.Clear();
101102
m_strTimeToCompletion.Clear();
102103
m_strReportDeadline.Clear();
104+
m_strEstimatedCompletion.Clear();
105+
m_strDeadlineDiff.Clear();
103106
}
104107

105108

@@ -194,9 +197,9 @@ static bool CompareViewWorkItems(int iRowIndex1, int iRowIndex2) {
194197
}
195198
break;
196199
case COLUMN_DEADLINEDIFF:
197-
if (work1->m_tDeadlineDiff < work2->m_tDeadlineDiff) {
200+
if (work1->m_fDeadlineDiff < work2->m_fDeadlineDiff) {
198201
result = -1;
199-
} else if (work1->m_tDeadlineDiff > work2->m_tDeadlineDiff) {
202+
} else if (work1->m_fDeadlineDiff > work2->m_fDeadlineDiff) {
200203
result = 1;
201204
}
202205
break;
@@ -1108,18 +1111,11 @@ bool CViewWork::SynchronizeCacheItem(wxInt32 iRowIndex, wxInt32 iColumnIndex) {
11081111
}
11091112
break;
11101113
case COLUMN_ESTIMATEDCOMPLETION:
1111-
// TODO: NEED TO ADD A WAY TO DISPLAY '---' if the date is the original date.
1112-
// Also todo: Let's change all time_t pointers from 'time' to something else, like 'pt'.
1113-
// Function to pass 0 (to read '---' is: strBuffer = FormatTime(0)
1114-
// TODO: Figure out logic to be most efficient for this case.
1115-
// - what happens if time returned in 0 (because task is not active)
1116-
// - what happens if no change in time
1117-
// -what happens if there is a change in time.
11181114
GetDocEstCompletionDate(m_iSortedIndexes[iRowIndex], tDocumentTime);
11191115
if (tDocumentTime != work->m_tEstimatedCompletion) {
11201116
work->m_tEstimatedCompletion = tDocumentTime;
11211117
if (work->m_tEstimatedCompletion == 0) {
1122-
work->m_strEstimatedCompletion << 0;
1118+
work->m_strEstimatedCompletion = _("---");
11231119
}
11241120
else {
11251121
FormatDateTime(tDocumentTime, work->m_strEstimatedCompletion);
@@ -1128,11 +1124,23 @@ bool CViewWork::SynchronizeCacheItem(wxInt32 iRowIndex, wxInt32 iColumnIndex) {
11281124
}
11291125
break;
11301126
case COLUMN_DEADLINEDIFF:
1131-
//something!!!!!!!!!!!!!!!!!!!!!!!!!!!
1132-
// - find estimated completion date
1133-
// - get deadline (should not change...right?
1134-
// make the delta between those.
1135-
// If not equal, store
1127+
GetDocEstDeadlineDiff(m_iSortedIndexes[iRowIndex], x);
1128+
if (x != work->m_fDeadlineDiff) {
1129+
work->m_fDeadlineDiff = x;
1130+
if (x < 0) {
1131+
// A negative difference means the task will not meet the
1132+
// deadline. Because FormatTime does not recognize negative
1133+
// numbers, the adjustment will be made here.
1134+
//
1135+
x *= -1;
1136+
work->m_strDeadlineDiff = _("-");
1137+
work->m_strDeadlineDiff += FormatTime(x);
1138+
}
1139+
else {
1140+
work->m_strDeadlineDiff = FormatTime(x);
1141+
}
1142+
return true;
1143+
}
11361144
break;
11371145
case COLUMN_STATUS:
11381146
int i = m_iSortedIndexes[iRowIndex];
@@ -1285,49 +1293,43 @@ void CViewWork::GetDocTimeToCompletion(wxInt32 item, double& fBuffer) const {
12851293
}
12861294

12871295

1288-
void CViewWork::GetDocReportDeadline(wxInt32 item, time_t& time) const {
1296+
void CViewWork::GetDocReportDeadline(wxInt32 item, time_t& tBuffer) const {
12891297
RESULT* result = wxGetApp().GetDocument()->result(item);
12901298

12911299
if (result) {
1292-
time = (time_t)result->report_deadline;
1300+
tBuffer = (time_t)result->report_deadline;
12931301
} else {
1294-
time = (time_t)0;
1302+
tBuffer = (time_t)0;
12951303
}
12961304
}
12971305

1306+
12981307
// Calculates the estimated date and time a task will be completed.
12991308
// This is only calculated for active tasks. If a task is not active,
13001309
// time pt will remain at zero. The intent is for the command calling this
13011310
// function to use that value to display '---', not the epoch time.
13021311
//
1303-
void CViewWork::GetDocEstCompletionDate(wxInt32 item, time_t& pt) const {
1312+
void CViewWork::GetDocEstCompletionDate(wxInt32 item, time_t& tBuffer) const {
13041313
RESULT* result = wxGetApp().GetDocument()->result(item);
1305-
pt = 0;
1314+
tBuffer = 0;
13061315
if (result->active_task_state == 1) {
13071316
time_t ttime = time(0);
1308-
pt = ttime;
1309-
pt += (time_t)result->estimated_cpu_time_remaining;
1317+
tBuffer = ttime;
1318+
tBuffer += (time_t)result->estimated_cpu_time_remaining;
13101319
}
1320+
}
1321+
13111322

1312-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1313-
// Figure out what "strBuffer" needs to be down below.
1314-
// double check what passing variables need to be.
1315-
// Add function to header
1316-
/* RESULT* result = wxGetApp().GetDocument()->result(m_iSortedIndexes[item]);
1317-
if ((work->m_fCPUTime > 0) && (result->active_task_state == 1)) {
1318-
wxDateTime now = wxDateTime::Now();
1319-
wxTimeSpan time_to_completion = convert_to_timespan(work->m_fTimeToCompletion);
1320-
wxDateTime estimated_completion = now.Add(time_to_completion);
1321-
FormatDateTime(estimated_completion.GetTicks(), strBuffer);
1322-
// Only display the Estimated Completion time if the task has
1323-
// been started and is currently running.
1323+
void CViewWork::GetDocEstDeadlineDiff(wxInt32 item, double& fBuffer) const {
1324+
RESULT* result = wxGetApp().GetDocument()->result(item);
1325+
fBuffer = 0;
1326+
if (result->active_task_state == 1) {
1327+
time_t tdeadline, testcompletion;
1328+
GetDocEstCompletionDate(item, testcompletion);
1329+
GetDocReportDeadline(item, tdeadline);
1330+
fBuffer = (double)(tdeadline - testcompletion);
13241331
}
1325-
else {
1326-
strBuffer = FormatTime(0);
1327-
// If the task has not started (CPUTime <= 0) or is not currently
1328-
// running, pass 0 to FormatTime to display "---" as the Estimated
1329-
// Completion time
1330-
}*/
1332+
13311333
}
13321334

13331335

clientgui/ViewWork.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class CWork : public wxObject
3838
double m_fCPUTime;
3939
double m_fProgress;
4040
double m_fTimeToCompletion;
41+
double m_fDeadlineDiff;
4142
time_t m_tReportDeadline;
4243
time_t m_tEstimatedCompletion;
43-
time_t m_tDeadlineDiff;
4444
wxString m_strStatus;
4545
wxString m_strProjectURL; // Used internally, not displayed
4646
wxString m_strCPUTime;
@@ -110,8 +110,9 @@ class CViewWork : public CBOINCBaseView
110110
void GetDocProgress(wxInt32 item, double& fBuffer) const;
111111
wxInt32 FormatProgress( double fBuffer, wxString& strBuffer ) const;
112112
void GetDocTimeToCompletion(wxInt32 item, double& fBuffer) const;
113-
void GetDocReportDeadline(wxInt32 item, time_t& time) const;
114-
void GetDocEstCompletionDate(wxInt32 item, time_t& time) const;
113+
void GetDocReportDeadline(wxInt32 item, time_t& tBuffer) const;
114+
void GetDocEstCompletionDate(wxInt32 item, time_t& tBuffer) const;
115+
void GetDocEstDeadlineDiff(wxInt32 item, double& fBuffer) const;
115116
wxInt32 FormatDateTime( time_t datetime, wxString& strBuffer ) const;
116117
wxInt32 FormatStatus( wxInt32 item, wxString& strBuffer ) const;
117118
void GetDocProjectURL(wxInt32 item, wxString& strBuffer) const;

0 commit comments

Comments
 (0)