Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
0cc607d3
Commit
0cc607d3
authored
Jan 20, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] delete all duplicates
parent
6d6ccfa1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
12 deletions
+49
-12
api.py
gargantext_web/api.py
+16
-12
urls.py
gargantext_web/urls.py
+1
-0
corpus.html
templates/corpus.html
+1
-0
subcorpus.html
templates/subcorpus.html
+31
-0
No files found.
gargantext_web/api.py
View file @
0cc607d3
...
@@ -234,20 +234,23 @@ class NodesChildrenDuplicates(APIView):
...
@@ -234,20 +234,23 @@ class NodesChildrenDuplicates(APIView):
# get the minimum ID for each of the nodes sharing the same metadata
# get the minimum ID for each of the nodes sharing the same metadata
kept_node_ids_query
=
self
.
_fetch_duplicates
(
request
,
node_id
,
[
func
.
min
(
Node
.
id
)
.
label
(
'id'
)],
0
)
kept_node_ids_query
=
self
.
_fetch_duplicates
(
request
,
node_id
,
[
func
.
min
(
Node
.
id
)
.
label
(
'id'
)],
0
)
kept_node_ids
=
[
kept_node
.
id
for
kept_node
in
kept_node_ids_query
]
kept_node_ids
=
[
kept_node
.
id
for
kept_node
in
kept_node_ids_query
]
# delete the stuff
duplicate_nodes
=
models
.
Node
.
objects
.
filter
(
parent_id
=
node_id
)
.
exclude
(
id__in
=
kept_node_ids
)
delete_query
=
(
session
# # delete the stuff
.
query
(
Node
)
# delete_query = (session
.
filter
(
Node
.
parent_id
==
node_id
)
# .query(Node)
.
filter
(
~
Node
.
id
.
in_
(
kept_node_ids
))
# .filter(Node.parent_id == node_id)
)
# .filter(~Node.id.in_(kept_node_ids))
count
=
delete_query
.
count
()
# )
delete_query
.
delete
(
synchronize_session
=
False
)
count
=
len
(
duplicate_nodes
)
session
.
flush
()
for
node
in
duplicate_nodes
:
# return the result
print
(
"deleting node "
,
node
.
id
)
node
.
delete
()
# print(delete_query)
# # delete_query.delete(synchronize_session=True)
# session.flush()
return
JsonHttpResponse
({
return
JsonHttpResponse
({
'deleted'
:
count
,
'deleted'
:
count
})
})
# return duplicates_query
...
@@ -621,6 +624,7 @@ class Nodes(APIView):
...
@@ -621,6 +624,7 @@ class Nodes(APIView):
})
})
# deleting node by id
# deleting node by id
# currently, very dangerous
def
delete
(
self
,
request
,
node_id
):
def
delete
(
self
,
request
,
node_id
):
session
=
get_session
()
session
=
get_session
()
node
=
models
.
Node
.
objects
.
filter
(
id
=
node_id
)
node
=
models
.
Node
.
objects
.
filter
(
id
=
node_id
)
...
...
gargantext_web/urls.py
View file @
0cc607d3
...
@@ -53,6 +53,7 @@ urlpatterns = patterns('',
...
@@ -53,6 +53,7 @@ urlpatterns = patterns('',
url
(
r'^api/nodes/(\d+)/children/metadata$'
,
gargantext_web
.
api
.
NodesChildrenMetatadata
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/metadata$'
,
gargantext_web
.
api
.
NodesChildrenMetatadata
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/queries$'
,
gargantext_web
.
api
.
NodesChildrenQueries
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/queries$'
,
gargantext_web
.
api
.
NodesChildrenQueries
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/duplicates$'
,
gargantext_web
.
api
.
NodesChildrenDuplicates
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/duplicates$'
,
gargantext_web
.
api
.
NodesChildrenDuplicates
.
as_view
()),
# url(r'^api/nodes/(\d+)/children/duplicates/delete$', gargantext_web.api.NodesChildrenDuplicates.delete ),
url
(
r'^api/nodes/(\d+)$'
,
gargantext_web
.
api
.
Nodes
.
as_view
()),
url
(
r'^api/nodes/(\d+)$'
,
gargantext_web
.
api
.
Nodes
.
as_view
()),
url
(
r'^api/nodes$'
,
gargantext_web
.
api
.
NodesList
.
as_view
()),
url
(
r'^api/nodes$'
,
gargantext_web
.
api
.
NodesList
.
as_view
()),
...
...
templates/corpus.html
View file @
0cc607d3
...
@@ -239,6 +239,7 @@ $.ajax({
...
@@ -239,6 +239,7 @@ $.ajax({
BIS_dict
[
untitlebis
[
0
]]
=
[
bisarray
[
i
].
count
,
0
];
// [ total amount , removed ]
BIS_dict
[
untitlebis
[
0
]]
=
[
bisarray
[
i
].
count
,
0
];
// [ total amount , removed ]
}
}
pr
(
BIS_dict
)
pr
(
BIS_dict
)
if
(
Object
.
keys
(
BIS_dict
).
length
>
0
)
$
(
"#delAll"
).
css
(
"visibility"
,
"visible"
);
$
(
"#delAll"
).
show
();
}
}
});
});
...
...
templates/subcorpus.html
View file @
0cc607d3
...
@@ -19,6 +19,12 @@
...
@@ -19,6 +19,12 @@
{% if documents %}
{% if documents %}
<div
id=
"delAll"
style=
"visibility: hidden;"
>
<button
onclick=
"deleteDuplicates(theurl);"
>
Delete Duplicates
</button>
</div>
<ul>
<ul>
{% for doc in documents %}
{% for doc in documents %}
{% if doc.date %}
{% if doc.date %}
...
@@ -45,6 +51,26 @@ function getCookie(name) {
...
@@ -45,6 +51,26 @@ function getCookie(name) {
return
cookieValue
;
return
cookieValue
;
}
}
function
deleteDuplicates
(
url
)
{
console
.
log
(
"hello world"
)
console
.
log
(
url
)
$
.
ajax
({
url
:
url
,
type
:
'DELETE'
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
data
)
{
console
.
log
(
"in DeleteDuplicates"
)
console
.
log
(
data
)
$
(
"#delAll"
).
remove
();
},
error
:
function
(
result
)
{
console
.
log
(
"Data not found"
);
console
.
log
(
result
)
}
});
}
function
deleteNode
(
node_id
)
{
function
deleteNode
(
node_id
)
{
$
.
ajax
({
$
.
ajax
({
...
@@ -111,6 +137,11 @@ function deleteNode(node_id) {
...
@@ -111,6 +137,11 @@ function deleteNode(node_id) {
//'
+
"{{doc.id}}"
+
',
\
"'
+
title
+
'
\
"
//'
+
"{{doc.id}}"
+
',
\
"'
+
title
+
'
\
"
current_docs = {}
current_docs = {}
if(Object.keys(BIS_dict).length>0) {
$("#delAll").css("visibility", "visible");
$("#delAll").show();
} else $("#delAll").remove()
{% for doc in documents %}
{% for doc in documents %}
id = "doc_{{doc.id}}"
id = "doc_{{doc.id}}"
title = $("<div/>").html("{{doc.name}}").text()
title = $("<div/>").html("{{doc.name}}").text()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment