Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
medialibrary
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mehdi Sabwat
medialibrary
Commits
f193eb99
Commit
f193eb99
authored
4 years ago
by
Hugo Beauzée-Luyssen
Browse files
Options
Downloads
Patches
Plain Diff
Movie: Allow deletion by a media ID
refs #297
parent
7b1f7b05
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Movie.cpp
+6
-0
6 additions, 0 deletions
src/Movie.cpp
src/Movie.h
+1
-0
1 addition, 0 deletions
src/Movie.h
test/unittest/MovieTests.cpp
+16
-0
16 additions, 0 deletions
test/unittest/MovieTests.cpp
with
23 additions
and
0 deletions
src/Movie.cpp
+
6
−
0
View file @
f193eb99
...
...
@@ -152,4 +152,10 @@ MoviePtr Movie::fromMedia( MediaLibraryPtr ml, int64_t mediaId )
return
fetch
(
ml
,
req
,
mediaId
);
}
bool
Movie
::
deleteByMediaId
(
MediaLibraryPtr
ml
,
int64_t
mediaId
)
{
const
std
::
string
req
=
"DELETE FROM "
+
Table
::
Name
+
" WHERE media_id = ?"
;
return
sqlite
::
Tools
::
executeDelete
(
ml
->
getConn
(),
req
,
mediaId
);
}
}
This diff is collapsed.
Click to expand it.
src/Movie.h
+
1
−
0
View file @
f193eb99
...
...
@@ -60,6 +60,7 @@ class Movie : public IMovie, public DatabaseHelpers<Movie>
static
bool
checkDbModel
(
MediaLibraryPtr
ml
);
static
std
::
shared_ptr
<
Movie
>
create
(
MediaLibraryPtr
ml
,
int64_t
mediaId
);
static
MoviePtr
fromMedia
(
MediaLibraryPtr
ml
,
int64_t
mediaId
);
static
bool
deleteByMediaId
(
MediaLibraryPtr
ml
,
int64_t
mediaId
);
private
:
MediaLibraryPtr
m_ml
;
...
...
This diff is collapsed.
Click to expand it.
test/unittest/MovieTests.cpp
+
16
−
0
View file @
f193eb99
...
...
@@ -103,3 +103,19 @@ TEST_F( Movies, CheckDbModel )
auto
res
=
Movie
::
checkDbModel
(
ml
.
get
()
);
ASSERT_TRUE
(
res
);
}
TEST_F
(
Movies
,
DeleteByMediaId
)
{
auto
media1
=
std
::
static_pointer_cast
<
Media
>
(
ml
->
addMedia
(
"movie.mkv"
,
IMedia
::
Type
::
Video
)
);
auto
media2
=
std
::
static_pointer_cast
<
Media
>
(
ml
->
addMedia
(
"movie2.mkv"
,
IMedia
::
Type
::
Video
)
);
auto
movie1
=
ml
->
createMovie
(
*
media1
);
auto
movie2
=
ml
->
createMovie
(
*
media2
);
ASSERT_NE
(
movie1
,
nullptr
);
ASSERT_NE
(
movie2
,
nullptr
);
Movie
::
deleteByMediaId
(
ml
.
get
(),
media1
->
id
()
);
movie1
=
std
::
static_pointer_cast
<
Movie
>
(
ml
->
movie
(
movie1
->
id
()
)
);
ASSERT_EQ
(
nullptr
,
movie1
);
movie2
=
std
::
static_pointer_cast
<
Movie
>
(
ml
->
movie
(
movie2
->
id
()
)
);
ASSERT_NE
(
nullptr
,
movie2
);
}
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