Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tank
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
tank
Commits
026e955b
Commit
026e955b
authored
5 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
add new api endpoint to fetch import logs
parent
4474d2f3
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
api/v1/api.go
+2
-1
2 additions, 1 deletion
api/v1/api.go
api/v1/files.go
+19
-0
19 additions, 0 deletions
api/v1/files.go
api/v1/types.go
+4
-0
4 additions, 0 deletions
api/v1/types.go
store/logs.go
+24
-0
24 additions, 0 deletions
store/logs.go
with
49 additions
and
1 deletion
api/v1/api.go
+
2
−
1
View file @
026e955b
...
...
@@ -81,8 +81,9 @@ func InstallHTTPHandler(r *gin.RouterGroup, st *store.Store, im *importer.Import
files
.
GET
(
":file-id"
,
api
.
ReadFileOfShow
)
files
.
PATCH
(
":file-id"
,
api
.
PatchFileOfShow
)
files
.
DELETE
(
":file-id"
,
api
.
DeleteFileOfShow
)
files
.
GET
(
":file-id/usage"
,
api
.
ReadUsageOfFile
)
files
.
GET
(
":file-id/logs"
,
api
.
ReadLogsOfFile
)
files
.
GET
(
":file-id/import"
,
api
.
ReadImportOfFile
)
files
.
DELETE
(
":file-id/import"
,
api
.
CancelImportOfFile
)
...
...
This diff is collapsed.
Click to expand it.
api/v1/files.go
+
19
−
0
View file @
026e955b
...
...
@@ -210,3 +210,22 @@ func (api *API) ReadUsageOfFile(c *gin.Context) {
}
c
.
JSON
(
http
.
StatusOK
,
result
)
}
func
(
api
*
API
)
ReadLogsOfFile
(
c
*
gin
.
Context
)
{
showID
:=
c
.
Param
(
"show-id"
)
if
authorized
,
_
:=
authorizeRequest
(
c
,
showID
);
!
authorized
{
return
}
id
,
err
:=
idFromString
(
c
.
Param
(
"file-id"
))
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"invalid file-id: "
+
err
.
Error
()})
return
}
result
:=
FileImportLogs
{}
if
result
.
Logs
,
err
=
api
.
store
.
GetImportLogs
(
showID
,
id
);
err
!=
nil
{
sendError
(
c
,
err
)
return
}
c
.
JSON
(
http
.
StatusOK
,
result
)
}
This diff is collapsed.
Click to expand it.
api/v1/types.go
+
4
−
0
View file @
026e955b
...
...
@@ -67,6 +67,10 @@ type FileUsageListing struct {
}
`json:"results"`
}
type
FileImportLogs
struct
{
Logs
store
.
ImportLogs
`json:"results"`
}
// Playlists
type
PlaylistsListing
struct
{
Playlists
store
.
Playlists
`json:"results"`
...
...
This diff is collapsed.
Click to expand it.
store/logs.go
+
24
−
0
View file @
026e955b
...
...
@@ -119,3 +119,27 @@ func (st *Store) AddImportLog(show string, id uint64, importStep string, log *Lo
return
st
.
db
.
Create
(
&
ImportLog
{
File
:
File
{
ID
:
id
,
ShowName
:
show
},
ImportStep
:
importStep
,
Encoded
:
encodedLog
})
.
Error
}
func
(
st
*
Store
)
GetImportLogs
(
show
string
,
id
uint64
)
(
logs
ImportLogs
,
err
error
)
{
cnt
:=
0
if
err
=
st
.
db
.
Model
(
&
File
{
ID
:
id
})
.
Where
(
"show_name = ?"
,
show
)
.
Count
(
&
cnt
)
.
Error
;
err
!=
nil
{
return
}
if
cnt
==
0
{
return
nil
,
ErrNotFound
}
var
results
[]
ImportLog
if
err
=
st
.
db
.
Where
(
"file_id = ?"
,
id
)
.
Find
(
&
results
)
.
Error
;
err
!=
nil
{
return
}
logs
=
make
(
map
[
string
]
*
Log
)
for
_
,
result
:=
range
results
{
l
:=
&
Log
{}
if
err
=
l
.
decode
(
result
.
Encoded
);
err
!=
nil
{
return
}
logs
[
result
.
ImportStep
]
=
l
}
return
}
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