Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CSCE 361
scripts
Commits
eea9a8a1
Commit
eea9a8a1
authored
Nov 25, 2019
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Ready to start tracking issues.
Still cannot track commits. Has some hard-coded values.
parent
8d70ad09
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
1198-capstones.json
+50
-0
50 additions, 0 deletions
1198-capstones.json
Timeline.py
+45
-2
45 additions, 2 deletions
Timeline.py
with
95 additions
and
2 deletions
1198-capstones.json
0 → 100644
+
50
−
0
View file @
eea9a8a1
[
{
"name"
:
"Airline Crew Scheduler 1"
,
"file"
:
"airline_crew_scheduler_1.json"
},
{
"name"
:
"Airline Crew Scheduler 2"
,
"file"
:
"airline_crew_scheduler_2.json"
},
{
"name"
:
"Airline Crew Scheduler 3"
,
"file"
:
"airline_crew_scheduler_3.json"
},
{
"name"
:
"Boggle 1"
,
"file"
:
"boggle_1.json"
},
{
"name"
:
"Boggle 2"
,
"file"
:
"boggle_2.json"
},
{
"name"
:
"Boggle 3"
,
"file"
:
"boggle_3.json"
},
{
"name"
:
"Chess 1"
,
"file"
:
"chess_1.json"
},
{
"name"
:
"Chess 2"
,
"file"
:
"chess_2.json"
},
{
"name"
:
"Chess 3"
,
"file"
:
"chess_4.json"
},
{
"name"
:
"Chess 4"
,
"file"
:
"chess_4.json"
},
{
"name"
:
"Package Tracker 1"
,
"file"
:
"package_tracker_1.json"
},
{
"name"
:
"Package Tracker 2"
,
"file"
:
"package_tracker_2.json"
}
]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Timeline.py
+
45
−
2
View file @
eea9a8a1
import
json
import
logging
import
threading
import
time
from
pathlib
import
Path
from
api.gitlab_classes
import
*
from
course
import
Course
class
Timeline
:
class
Timeline
(
threading
.
Thread
)
:
# noinspection PyShadowingNames
def
__init__
(
self
,
project
,
filename
):
def
__init__
(
self
,
project
,
filename
,
interval
=
60
):
super
().
__init__
()
self
.
interval
=
interval
self
.
project
=
project
self
.
save_file
=
filename
if
Path
(
self
.
save_file
).
exists
():
logging
.
info
(
f
'
Loading timeline for
{
project
}
from
{
filename
}
.
'
)
with
open
(
self
.
save_file
,
mode
=
'
r
'
)
as
json_file
:
this_dict
=
json
.
load
(
json_file
)
self
.
start_time
=
this_dict
[
'
start_time
'
]
self
.
issues
=
this_dict
[
'
issues
'
]
self
.
observational_periods
=
this_dict
[
'
observational_periods
'
]
else
:
logging
.
info
(
f
'
Creating timeline for
{
project
}
that will be stored in
{
filename
}
.
'
)
self
.
project
=
project
# self.commits = project.get_commits() # we'll worry about commits later
self
.
start_time
=
datetime
.
now
().
isoformat
()
...
...
@@ -25,6 +32,16 @@ class Timeline:
self
.
observational_periods
.
append
({
'
from
'
:
datetime
.
now
().
isoformat
(),
'
to
'
:
datetime
.
now
().
isoformat
()})
self
.
issues
=
list
(
map
(
lambda
issue
:
self
.
update_issue_timeline
(
issue
),
project
.
get_issues
()))
def
run
(
self
):
while
True
:
self
.
observational_periods
[
-
1
][
'
to
'
]
=
datetime
.
now
().
isoformat
()
# we'll worry about updating commits later
self
.
issues
=
list
(
map
(
lambda
issue
:
self
.
update_issue_timeline
(
issue
),
self
.
project
.
get_issues
()))
self
.
save
()
time
.
sleep
(
self
.
interval
)
# logging.info(f'Terminating observation of {self.project}.')
# noinspection PyShadowingNames
def
save
(
self
):
this_dict
=
{
'
project
'
:
self
.
project
.
get_path_with_namespace
(),
'
issues
'
:
self
.
issues
,
...
...
@@ -39,21 +56,26 @@ class Timeline:
json
.
dump
(
this_dict
,
json_file
,
indent
=
4
)
def
update_issue_timeline
(
self
,
issue
):
logging
.
info
(
f
'
Checking for updates to
{
self
.
project
}
\'
s issue
{
issue
}
.
'
)
possible_issue_timeline
=
list
(
filter
(
lambda
i
:
i
[
'
number
'
]
==
issue
.
get_project_issue_id
(),
self
.
issues
))
if
len
(
possible_issue_timeline
)
==
0
:
logging
.
info
(
f
'
{
issue
}
is a new issue.
'
)
issue_timeline
=
{
'
number
'
:
issue
.
get_project_issue_id
(),
'
opened
'
:
issue
.
get_created_at
().
isoformat
(),
'
events
'
:
[]}
old_labels
=
set
()
else
:
logging
.
info
(
f
'
{
issue
}
is an existing issue.
'
)
issue_timeline
=
possible_issue_timeline
[
0
]
old_labels
=
set
(
issue_timeline
[
'
current_labels
'
])
new_labels
=
issue
.
get_labels
()
all_labels
=
old_labels
.
union
(
new_labels
)
for
label
in
all_labels
:
if
label
in
old_labels
.
difference
(
new_labels
):
logging
.
info
(
f
'
{
issue
}
lost a label:
{
label
}
.
'
)
issue_timeline
[
'
events
'
].
append
((
'
Remove Label
'
,
label
,
datetime
.
now
().
isoformat
()))
if
label
in
new_labels
.
difference
(
old_labels
):
logging
.
info
(
f
'
{
issue
}
gained a label:
{
label
}
.
'
)
issue_timeline
[
'
events
'
].
append
((
'
Add Label
'
,
label
,
datetime
.
now
().
isoformat
()))
issue_timeline
[
'
current_labels
'
]
=
list
(
issue
.
get_labels
())
if
issue
.
get_closed_at
()
is
not
None
:
...
...
@@ -63,6 +85,7 @@ class Timeline:
return
issue_timeline
"""
if __name__ ==
'
__main__
'
:
# A handy project to work from for now
projects = GitlabProject.get_projects_by_group(Course.gitlab_namespace)
...
...
@@ -75,3 +98,23 @@ if __name__ == '__main__':
new_timeline = Timeline(project,
'
chess4.json
'
)
print(new_timeline.project)
new_timeline.save()
"""
"""
if __name__ ==
'
__main__
'
:
logging.getLogger().setLevel(logging.INFO)
project = GitlabProject(5569) # sandbox/quux
timeline = Timeline(project,
'
sandbox.json
'
)
timeline.run()
"""
if
__name__
==
'
__main__
'
:
projects
=
GitlabProject
.
get_projects_by_group
(
Course
.
gitlab_namespace
)
with
open
(
'
1198-capstones.json
'
,
mode
=
'
r
'
)
as
json_file
:
capstones
=
json
.
load
(
json_file
)
for
capstone
in
capstones
:
project
=
list
(
filter
(
lambda
p
:
p
.
get_name
()
==
capstone
[
'
name
'
],
projects
))[
0
]
# timeline = Timeline(project, capstone['file'], 300)
print
(
f
'
Timeline created for
{
project
}
, starting...
'
)
# threading.Thread(target=timeline.run()).start()
Timeline
(
project
,
capstone
[
'
file
'
],
300
).
start
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment