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
8ba25bfd
Commit
8ba25bfd
authored
May 25, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] removable subforms in groups + simplified group management in js
parent
3b0313c9
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
446 additions
and
300 deletions
+446
-300
ngramlists.py
gargantext/views/api/ngramlists.py
+72
-20
NGrams_dyna_chart_and_table.js
static/lib/gargantext/NGrams_dyna_chart_and_table.js
+372
-275
tables.css
static/lib/gargantext/tables.css
+2
-5
No files found.
gargantext/views/api/ngramlists.py
View file @
8ba25bfd
...
@@ -34,24 +34,36 @@ def _query_list(list_id,
...
@@ -34,24 +34,36 @@ def _query_list(list_id,
"""
"""
if
not
details
:
if
not
details
:
# simple contents
# simple contents
query
=
session
.
query
(
NodeNgram
.
ngram_id
)
query
=
session
.
query
(
NodeNgram
.
ngram_id
)
.
filter
(
NodeNgram
.
node_id
==
list_id
)
else
:
else
:
# detailed contents (terms and some NodeNodeNgram for score)
# detailed contents (terms and some NodeNodeNgram for score)
# NB: score can be undefined (eg ex-subform that now became free)
# ==> we need outerjoin
# and the filter needs to have scoring_metric_id so we do it before
ScoresTable
=
(
session
.
query
(
NodeNodeNgram
.
score
,
NodeNodeNgram
.
ngram_id
)
.
filter
(
NodeNodeNgram
.
node1_id
==
scoring_metric_id
)
.
subquery
()
)
query
=
(
session
query
=
(
session
.
query
(
.
query
(
NodeNgram
.
ngram_id
,
NodeNgram
.
ngram_id
,
Ngram
.
terms
,
Ngram
.
terms
,
NodeNodeNgram
.
score
ScoresTable
.
c
.
score
)
)
.
join
(
Ngram
,
NodeNgram
.
ngram_id
==
Ngram
.
id
)
.
join
(
Ngram
,
NodeNgram
.
ngram_id
==
Ngram
.
id
)
.
join
(
NodeNodeNgram
,
NodeNgram
.
ngram_id
==
NodeNodeNgram
.
ngram_id
)
.
filter
(
NodeNodeNgram
.
node1_id
==
scoring_metric_id
)
.
order_by
(
desc
(
NodeNodeNgram
.
score
))
)
# main filter
# main filter ----------------------
# -----------
.
filter
(
NodeNgram
.
node_id
==
list_id
)
query
=
query
.
filter
(
NodeNgram
.
node_id
==
list_id
)
# scores if possible
.
outerjoin
(
ScoresTable
,
ScoresTable
.
c
.
ngram_id
==
NodeNgram
.
ngram_id
)
.
order_by
(
desc
(
ScoresTable
.
c
.
score
))
)
if
pagination_limit
:
if
pagination_limit
:
query
=
query
.
limit
(
pagination_limit
)
query
=
query
.
limit
(
pagination_limit
)
...
@@ -128,13 +140,18 @@ class GroupChange(APIView):
...
@@ -128,13 +140,18 @@ class GroupChange(APIView):
}
}
Chained effect:
Chained effect:
any previous group under mainformA or B will be overwritten
The DELETE HTTP method also works, with same url
(and simple array in the data)
NB: request.user is also checked for current authentication status
NB: request.user is also checked for current authentication status
"""
"""
def
initial
(
self
,
request
):
def
initial
(
self
,
request
):
"""
"""
Before dispatching to post()
Before dispatching to post()
or delete()
Checks current user authentication to prevent remote DB manipulation
Checks current user authentication to prevent remote DB manipulation
"""
"""
...
@@ -150,28 +167,29 @@ class GroupChange(APIView):
...
@@ -150,28 +167,29 @@ class GroupChange(APIView):
=> removes couples where newly reconnected ngrams where involved
=> removes couples where newly reconnected ngrams where involved
=> adds new couples from GroupsBuffer of terms view
=> adds new couples from GroupsBuffer of terms view
TODO recalculate scores after new groups
TODO see use of util.lists.Translations
TODO see use of util.lists.Translations
TODO benchmark selective delete compared to entire list rewrite
POST data:
<QueryDict: {'1228[]': ['891', '1639']}> => creates 1228 - 891
and 1228 - 1639
request.POST.lists() iterator where each elt is like :('1228[]',['891','1639'])
"""
"""
group_node
=
get_parameters
(
request
)[
'node'
]
group_node
=
get_parameters
(
request
)[
'node'
]
all_
nodes_involved
=
[]
all_
mainforms
=
[]
links
=
[]
links
=
[]
for
(
mainform_key
,
subforms_ids
)
in
request
.
POST
.
lists
():
for
(
mainform_key
,
subforms_ids
)
in
request
.
POST
.
lists
():
mainform_id
=
mainform_key
[:
-
2
]
# remove brackets '543[]' -> '543'
mainform_id
=
mainform_key
[:
-
2
]
# remove brackets '543[]' -> '543'
all_
nodes_involved
.
append
(
mainform_id
)
all_
mainforms
.
append
(
mainform_id
)
for
subform_id
in
subforms_ids
:
for
subform_id
in
subforms_ids
:
links
.
append
((
mainform_id
,
subform_id
))
links
.
append
((
mainform_id
,
subform_id
))
all_nodes_involved
.
append
(
subform_id
)
# remove selectively all groupings with these nodes involved
# remove selectively all groupings with these mainforms
# TODO benchmark
# using IN is correct in this case: list of ids is short and external
# see stackoverflow.com/questions/444475/
old_links
=
(
session
.
query
(
NodeNgramNgram
)
old_links
=
(
session
.
query
(
NodeNgramNgram
)
.
filter
(
NodeNgramNgram
.
node_id
==
group_node
)
.
filter
(
NodeNgramNgram
.
node_id
==
group_node
)
.
filter
(
or_
(
.
filter
(
NodeNgramNgram
.
ngram1_id
.
in_
(
all_mainforms
))
NodeNgramNgram
.
ngram1_id
.
in_
(
all_nodes_involved
),
NodeNgramNgram
.
ngram2_id
.
in_
(
all_nodes_involved
)))
)
)
n_removed
=
old_links
.
delete
(
synchronize_session
=
False
)
n_removed
=
old_links
.
delete
(
synchronize_session
=
False
)
session
.
commit
()
session
.
commit
()
...
@@ -189,6 +207,40 @@ class GroupChange(APIView):
...
@@ -189,6 +207,40 @@ class GroupChange(APIView):
},
200
)
},
200
)
def
delete
(
self
,
request
):
"""
Deletes some groups from the group node
Send in data format is simply a json { 'keys':'["11492","16438"]' }
==> it means removing any synonym groups having these 2 as mainform
(within the url's groupnode_id)
NB: At reception here it becomes like:
<QueryDict: {'keys[]': ['11492', '16438']}>
"""
# from the url
group_node
=
get_parameters
(
request
)[
'node'
]
print
(
request
.
POST
)
# from the data in body
all_mainforms
=
request
.
POST
.
getlist
(
'keys[]'
)
links_to_remove
=
(
session
.
query
(
NodeNgramNgram
)
.
filter
(
NodeNgramNgram
.
node_id
==
group_node
)
.
filter
(
NodeNgramNgram
.
ngram1_id
.
in_
(
all_mainforms
))
)
n_removed
=
links_to_remove
.
delete
(
synchronize_session
=
False
)
session
.
commit
()
return
JsonHttpResponse
({
'count_removed'
:
n_removed
},
200
)
class
ListChange
(
APIView
):
class
ListChange
(
APIView
):
"""
"""
...
...
static/lib/gargantext/NGrams_dyna_chart_and_table.js
View file @
8ba25bfd
This diff is collapsed.
Click to expand it.
static/lib/gargantext/tables.css
View file @
8ba25bfd
...
@@ -61,6 +61,7 @@ span.note {
...
@@ -61,6 +61,7 @@ span.note {
span
.note.glyphicon
{
span
.note.glyphicon
{
color
:
#555
;
color
:
#555
;
top
:
0
;
}
}
p
.note
{
p
.note
{
...
@@ -129,14 +130,10 @@ tr:hover {
...
@@ -129,14 +130,10 @@ tr:hover {
margin-bottom
:
1em
;
margin-bottom
:
1em
;
}
}
.
old
subform
{
.subform
{
color
:
#777
;
color
:
#777
;
}
}
.usersubform
{
color
:
blue
;
}
.dynatable-record-count
{
.dynatable-record-count
{
font-size
:
0.7em
;
font-size
:
0.7em
;
}
}
...
...
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