5 #include "GitlabEvent.h"
14 Event::Event() : TObject(), fID(0), fNIssues(0), fNMergeRequests(0), fIssues(0), fMergeRequests(0)
21 Event::Event(Long64_t
id) : TObject(), fID(id), fNIssues(0), fNMergeRequests(0), fIssues(0), fMergeRequests(0)
26 fIssues =
new TClonesArray(
"Ndmspc::Gitlab::Track");
28 fAuthors =
new TH1S(
"authors",
"Authors", 0, 0, 0);
29 fProjects =
new TH1S(
"projects",
"Projects", 0, 0, 0);
30 fMilestones =
new TH1S(
"milestones",
"Milestones", 0, 0, 0);
74 if (!issues.empty()) {
75 Printf(
"Processing '%s' ...", issues.data());
76 std::ifstream fileIssues(issues.data());
77 if (!fileIssues.is_open()) {
78 Printf(
"Error: Unable to open file '%s' !!!", issues.data());
82 iss = json::parse(fileIssues);
86 if (!mergrerequests.empty()) {
87 Printf(
"Processing '%s' ...", mergrerequests.data());
88 std::ifstream fileMRs(mergrerequests);
89 if (!fileMRs.is_open()) {
90 Printf(
"Error: Unable to open file '%s' !!!", mergrerequests.data());
94 mrs = json::parse(fileMRs);
105 for (
const auto & jv : root) {
107 t->
SetState(jv[
"state"].get<std::string>());
111 t->
SetAuthor(jv[
"author"][
"username"].get<std::string>());
112 if (!jv[
"milestone"].is_null()) {
114 t->
SetMilestone(jv[
"milestone"][
"title"].get<std::string>());
120 fAuthors->GetXaxis()->FindBin(t->
GetAuthor().c_str());
123 Printf(
"Issue %d project [%s] author [%s] state [%s]", jv[
"iid"].get<int>(), t->
GetProject().data(),
135 for (
const auto & jv : root) {
137 t->
SetState(jv[
"state"].get<std::string>());
141 t->
SetAuthor(jv[
"author"][
"username"].get<std::string>());
142 if (!jv[
"milestone"].is_null()) {
144 t->
SetMilestone(jv[
"milestone"][
"title"].get<std::string>());
150 fAuthors->GetXaxis()->FindBin(t->
GetAuthor().c_str());
153 Printf(
"MR %d project [%s] author [%s] state [%s]", jv[
"iid"].get<int>(), t->
GetProject().data(),
184 ShrinkHistogram(
"autors", fAuthors, verbose);
185 ShrinkHistogram(
"projects",
fProjects, verbose);
186 ShrinkHistogram(
"milestoness",
fMilestones, verbose);
208 fDateTime.Set(year, month, day, hour, min, sec);
217 std::stringstream ss(in);
218 std::getline(ss, s, d);
222 void Event::ShrinkHistogram(
const char * name, TH1 * h,
bool verbose)
226 if (h->GetXaxis()->GetNbins() <= 0)
return;
229 for (
int i = 1; i < h->GetXaxis()->GetNbins(); i++) {
230 s = h->GetXaxis()->GetBinLabel(i);
233 Printf(
"%s label [%d] : %s", name, count, h->GetXaxis()->GetBinLabel(i));
239 h->GetXaxis()->Set(count, 0, count);
virtual void Print(Option_t *option="") const
bool FillIssuesFromJson(const json root)
void SetTimeDate(Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec)
bool FillMergeRequestsFromJson(const json root)
Int_t fNIssues
Number of Issues.
Track * AddMergeRequest()
TDatime fDateTime
Time of event.
std::string ParseProjectName(std::string in, char d='!') const
not implemented
TClonesArray * fIssues
Array with all issues.
virtual void Clear(Option_t *option="")
void ShrinkMappingHistograms(bool verbose=true)
Int_t fNMergeRequests
Number of MergeRequests.
bool FillGitlabFromJson(std::string issues, std::string mergrerequests)
TH1S * fProjects
! List of authors in current event
TH1S * fMilestones
! List of projects in current event
TClonesArray * fMergeRequests
Array with all merge requests.
std::string GetAuthor() const
Returns author.
void SetAuthor(std::string name)
void SetState(std::string t)
std::string GetMilestone() const
Returns Milestone.
void SetProjectID(Int_t id)
void SetAuthorID(Int_t id)
void SetProject(std::string name)
std::string GetProject() const
Returns Project.
void SetMilestoneID(Int_t id)
std::string GetState() const
Returns state.
void SetMilestone(std::string name)