SVN Commit by dpage: r4218 - in trunk/pgadmin3/src/agent: . include

From: svn(at)pgadmin(dot)org
To: pgadmin-hackers(at)postgresql(dot)org
Subject: SVN Commit by dpage: r4218 - in trunk/pgadmin3/src/agent: . include
Date: 2005-05-19 10:30:28
Message-ID: 200505191030.j4JAUSCH012115@developer.pgadmin.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Author: dpage
Date: 2005-05-19 11:30:28 +0100 (Thu, 19 May 2005)
New Revision: 4218

Modified:
trunk/pgadmin3/src/agent/include/pgaJob.h
trunk/pgadmin3/src/agent/include/pgaStep.h
trunk/pgadmin3/src/agent/pgaJob.cpp
trunk/pgadmin3/src/agent/pgaStep.cpp
Log:
Display job & step stats

Modified: trunk/pgadmin3/src/agent/include/pgaJob.h
===================================================================
--- trunk/pgadmin3/src/agent/include/pgaJob.h 2005-05-19 10:06:30 UTC (rev 4217)
+++ trunk/pgadmin3/src/agent/include/pgaJob.h 2005-05-19 10:30:28 UTC (rev 4218)
@@ -30,6 +30,7 @@

int GetIcon() { return enabled ? PGAICON_JOB : PGAICON_JOBDISABLED; }
void ShowTreeDetail(wxTreeCtrl *browser, frmMain *form=0, ctlListView *properties=0, ctlSQLBox *sqlPane=0);
+ void ShowStatistics(frmMain *form, ctlListView *statistics);
static pgObject *ReadObjects(pgCollection *collection, wxTreeCtrl *browser, const wxString &restriction=wxEmptyString);
pgObject *Refresh(wxTreeCtrl *browser, const wxTreeItemId item);
bool DropObject(wxFrame *frame, wxTreeCtrl *browser, bool cascaded);

Modified: trunk/pgadmin3/src/agent/include/pgaStep.h
===================================================================
--- trunk/pgadmin3/src/agent/include/pgaStep.h 2005-05-19 10:06:30 UTC (rev 4217)
+++ trunk/pgadmin3/src/agent/include/pgaStep.h 2005-05-19 10:30:28 UTC (rev 4218)
@@ -33,6 +33,7 @@

int GetIcon() { return PGAICON_STEP; }
void ShowTreeDetail(wxTreeCtrl *browser, frmMain *form=0, ctlListView *properties=0, ctlSQLBox *sqlPane=0);
+ void ShowStatistics(frmMain *form, ctlListView *statistics);
static pgObject *ReadObjects(pgCollection *collection, wxTreeCtrl *browser, const wxString &restriction=wxEmptyString);
pgObject *Refresh(wxTreeCtrl *browser, const wxTreeItemId item);
bool DropObject(wxFrame *frame, wxTreeCtrl *browser, bool cascaded);

Modified: trunk/pgadmin3/src/agent/pgaJob.cpp
===================================================================
--- trunk/pgadmin3/src/agent/pgaJob.cpp 2005-05-19 10:06:30 UTC (rev 4217)
+++ trunk/pgadmin3/src/agent/pgaJob.cpp 2005-05-19 10:30:28 UTC (rev 4218)
@@ -160,9 +160,67 @@
return job;
}

+void pgaJob::ShowStatistics(frmMain *form, ctlListView *statistics)
+{
+ wxString sql =
+ wxT("SELECT jlgid")
+ wxT(", jlgstatus")
+ wxT(", jlgstart")
+ wxT(", jlgduration")
+ wxT(", (jlgstart + jlgduration) AS endtime")
+ wxT(" FROM pgagent.pga_joblog\n")
+ wxT(" WHERE jlgjobid = ") + NumToStr(GetRecId()) +
+ wxT(" ORDER BY jlgstart DESC");

+ if (statistics)
+ {
+ wxLogInfo(wxT("Displaying statistics for job %s"), GetFullIdentifier());
+
+ // Add the statistics view columns
+ statistics->ClearAll();
+ statistics->AddColumn(_("Run"), 70);
+ statistics->AddColumn(_("Status"), 90);
+ statistics->AddColumn(_("Start time"), 125);
+ statistics->AddColumn(_("End time"), 125);
+ statistics->AddColumn(_("Duration"), 110);
+
+ pgSet *stats = database->ExecuteSet(sql);
+ wxString status;
+ wxDateTime startTime;
+ wxDateTime endTime;
+
+ if (stats)
+ {
+ while (!stats->Eof())
+ {
+ if (stats->GetVal(1) == wxT("r"))
+ status = _("Running");
+ else if (stats->GetVal(1) == wxT("s"))
+ status = _("Successful");
+ else if (stats->GetVal(1) == wxT("f"))
+ status = _("Failed");
+ else if (stats->GetVal(1) == wxT("i"))
+ status = _("No steps");
+ else
+ status = _("Unknown");
+
+ startTime.ParseDateTime(stats->GetVal(2));
+ endTime.ParseDateTime(stats->GetVal(4));
+
+ long pos=statistics->AppendItem(stats->GetVal(0), status, startTime.Format());
+ statistics->SetItem(pos, 3, endTime.Format());
+ statistics->SetItem(pos, 4, stats->GetVal(3));
+
+ stats->MoveNext();
+ }
+ delete stats;
+ }
+ }
+}
+
pgaJobObject::pgaJobObject(pgaJob *_job, int newType, const wxString& newName)
: pgDatabaseObject(newType, newName)
{
job=_job;
}
+

Modified: trunk/pgadmin3/src/agent/pgaStep.cpp
===================================================================
--- trunk/pgadmin3/src/agent/pgaStep.cpp 2005-05-19 10:06:30 UTC (rev 4217)
+++ trunk/pgadmin3/src/agent/pgaStep.cpp 2005-05-19 10:30:28 UTC (rev 4218)
@@ -142,3 +142,65 @@
}
return step;
}
+
+
+void pgaStep::ShowStatistics(frmMain *form, ctlListView *statistics)
+{
+ wxString sql =
+ wxT("SELECT jsljlgid")
+ wxT(", jslstatus")
+ wxT(", jslresult")
+ wxT(", jslstart")
+ wxT(", jslduration")
+ wxT(", (jslstart + jslduration) AS endtime")
+ wxT(" FROM pgagent.pga_jobsteplog\n")
+ wxT(" WHERE jsljstid = ") + NumToStr(GetRecId()) +
+ wxT(" ORDER BY jslstart DESC");
+
+ if (statistics)
+ {
+ wxLogInfo(wxT("Displaying statistics for job %s"), GetFullIdentifier());
+
+ // Add the statistics view columns
+ statistics->ClearAll();
+ statistics->AddColumn(_("Run"), 60);
+ statistics->AddColumn(_("Status"), 90);
+ statistics->AddColumn(_("Result"), 90);
+ statistics->AddColumn(_("Start time"), 125);
+ statistics->AddColumn(_("End time"), 125);
+ statistics->AddColumn(_("Duration"), 110);
+
+ pgSet *stats = database->ExecuteSet(sql);
+ wxString status;
+ wxDateTime startTime;
+ wxDateTime endTime;
+
+ if (stats)
+ {
+ while (!stats->Eof())
+ {
+ if (stats->GetVal(1) == wxT("r"))
+ status = _("Running");
+ else if (stats->GetVal(1) == wxT("s"))
+ status = _("Successful");
+ else if (stats->GetVal(1) == wxT("f"))
+ status = _("Failed");
+ else if (stats->GetVal(1) == wxT("i"))
+ status = _("Ignored");
+ else
+ status = _("Unknown");
+
+ startTime.ParseDateTime(stats->GetVal(3));
+ endTime.ParseDateTime(stats->GetVal(5));
+
+ long pos=statistics->AppendItem(stats->GetVal(0), status, stats->GetVal(2));
+ statistics->SetItem(pos, 3, startTime.Format());
+ statistics->SetItem(pos, 4, endTime.Format());
+ statistics->SetItem(pos, 5, stats->GetVal(4));
+
+ stats->MoveNext();
+ }
+ delete stats;
+ }
+ }
+}
\ No newline at end of file

Browse pgadmin-hackers by date

  From Date Subject
Next Message Adam H.Pendleton 2005-05-19 11:57:10 Re: New acinclude.m4
Previous Message svn 2005-05-19 10:06:30 SVN Commit by dpage: r4217 - trunk/pgadmin3/xtra/pgagent