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
3afda3a0
Commit
3afda3a0
authored
Jun 27, 2017
by
sim
Committed by
delanoe
Jul 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
query_list: Get rid of subquery
parent
08d52f99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
21 deletions
+10
-21
ngramlists_tools.py
gargantext/util/ngramlists_tools.py
+10
-21
No files found.
gargantext/util/ngramlists_tools.py
View file @
3afda3a0
...
...
@@ -95,30 +95,19 @@ def query_list(list_id,
else
:
# 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
()
)
NNN
=
NodeNodeNgram
query
=
(
session
.
query
(
NodeNgram
.
ngram_id
,
Ngram
.
terms
,
ScoresTable
.
c
.
score
)
.
join
(
Ngram
,
NodeNgram
.
ngram_id
==
Ngram
.
id
)
# main filter ----------------------
.
filter
(
NodeNgram
.
node_id
==
list_id
)
# scores if possible
.
outerjoin
(
ScoresTable
,
ScoresTable
.
c
.
ngram_id
==
NodeNgram
.
ngram_id
)
.
order_by
(
desc
(
ScoresTable
.
c
.
score
))
.
query
(
Ngram
.
id
,
Ngram
.
terms
,
NNN
.
score
)
# Ngrams must be related to our list <Node(id=list_id)>
.
join
(
NodeNgram
,
(
NodeNgram
.
ngram_id
==
Ngram
.
id
)
&
(
NodeNgram
.
node_id
==
list_id
))
# Select by metric <Node(id=scoring_metric_id)>
.
outerjoin
(
NNN
,
(
NNN
.
ngram_id
==
Ngram
.
id
)
&
(
NNN
.
node1_id
==
scoring_metric_id
))
# Sort by descending score
.
order_by
(
NNN
.
score
.
desc
())
)
if
pagination_limit
:
...
...
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