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
0824a3d8
Commit
0824a3d8
authored
Mar 12, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
[FIX] Conflicts and file to convert into json
parents
838d911b
2ca6ff65
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
21 deletions
+55
-21
views_optimized.py
gargantext_web/views_optimized.py
+15
-19
hstore2jsonb.sql
init/hstore2jsonb.sql
+30
-0
init2.sql
init/init2.sql
+8
-0
models.py
node/models.py
+2
-2
No files found.
gargantext_web/views_optimized.py
View file @
0824a3d8
...
@@ -46,30 +46,26 @@ def project(request, project_id):
...
@@ -46,30 +46,26 @@ def project(request, project_id):
# Let's find out about the children nodes of the project
# Let's find out about the children nodes of the project
ChildrenNode
=
aliased
(
Node
)
ChildrenNode
=
aliased
(
Node
)
corpus_query
=
(
session
corpus_query
=
(
session
.
query
(
Node
,
Resource
,
func
.
count
(
ChildrenNode
.
id
))
.
query
(
Node
.
id
,
Node
.
name
,
Resource
.
type_id
,
func
.
count
(
ChildrenNode
.
id
))
.
outerjoin
(
ChildrenNode
,
ChildrenNode
.
parent_id
==
Node
.
id
)
.
outerjoin
(
ChildrenNode
,
ChildrenNode
.
parent_id
==
Node
.
id
)
.
outerjoin
(
Node_Resource
,
Node_Resource
.
node_id
==
Node
.
id
)
.
outerjoin
(
Node_Resource
,
Node_Resource
.
node_id
==
Node
.
id
)
.
outerjoin
(
Resource
,
Resource
.
id
==
Node_Resource
.
resource_id
)
.
outerjoin
(
Resource
,
Resource
.
id
==
Node_Resource
.
resource_id
)
.
filter
(
Node
.
parent_id
==
project
.
id
)
.
filter
(
Node
.
parent_id
==
project
.
id
)
.
group_by
(
Node
,
Resource
)
.
group_by
(
Node
.
id
,
Node
.
name
,
Resource
.
type_id
)
.
order_by
(
Node
.
name
)
.
order_by
(
Node
.
name
)
)
)
corpora_by_resourcetype
=
defaultdict
(
list
)
corpora_by_resourcetype
=
defaultdict
(
list
)
documents_count_by_resourcetype
=
defaultdict
(
int
)
documents_count_by_resourcetype
=
defaultdict
(
int
)
corpora_count
=
0
corpora_count
=
0
for
corpus_id
,
corpus_name
,
resource_type_id
,
document_count
in
corpus_query
:
corpusID_dict
=
{}
if
resource_type_id
is
None
:
for
corpus
,
resource
,
document_count
in
corpus_query
:
if
not
corpus
.
id
in
corpusID_dict
:
if
resource
is
None
:
resourcetype_name
=
'(no resource)'
resourcetype_name
=
'(no resource)'
else
:
else
:
resourcetype
=
cache
.
ResourceType
[
resource
.
type_id
]
resourcetype
=
cache
.
ResourceType
[
resource_
type_id
]
resourcetype_name
=
resourcetype
.
name
resourcetype_name
=
resourcetype
.
name
corpusID_dict
[
corpus
.
id
]
=
True
corpora_by_resourcetype
[
resourcetype_name
]
.
append
({
corpora_by_resourcetype
[
resourcetype_name
]
.
append
({
'id'
:
corpus
.
id
,
'id'
:
corpus_
id
,
'name'
:
corpus
.
name
,
'name'
:
corpus_
name
,
'count'
:
document_count
,
'count'
:
document_count
,
})
})
documents_count_by_resourcetype
[
resourcetype_name
]
+=
document_count
documents_count_by_resourcetype
[
resourcetype_name
]
+=
document_count
...
...
init/hstore2jsonb.sql
0 → 100644
View file @
0824a3d8
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
metadata
DROP
NOT
NULL
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
metadata
DROP
DEFAULT
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
metadata
TYPE
JSON
USING
hstore_to_json
(
metadata
)
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
metadata
SET
DEFAULT
'{}'
::
json
;
-- for JSONB ?
-- ALTER TABLE ONLY node_node ALTER COLUMN metadata TYPE JSONB USING metadata::text::jsonb;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
metadata
SET
NOT
NULL
;
init/init2.sql
0 → 100644
View file @
0824a3d8
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
date
SET
DEFAULT
CURRENT_DATE
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
metadata
SET
DEFAULT
''
::
hstore
;
-- ALTER TABLE ONLY node_node ALTER COLUMN metadata TYPE JSONB;
-- ALTER TABLE ONLY node_node ALTER COLUMN metadata SET DEFAULT '{}'::JSONB;
node/models.py
View file @
0824a3d8
...
@@ -3,7 +3,7 @@ from django.utils import timezone
...
@@ -3,7 +3,7 @@ from django.utils import timezone
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django_hstore
import
hstore
import
jsonfield
from
cte_tree.models
import
CTENode
,
CTENodeManager
from
cte_tree.models
import
CTENode
,
CTENodeManager
# from cte_tree.query import CTEQuerySet
# from cte_tree.query import CTEQuerySet
#from cte_tree.fields import DepthField, PathField, OrderingField
#from cte_tree.fields import DepthField, PathField, OrderingField
...
@@ -125,7 +125,7 @@ class Node(CTENode):
...
@@ -125,7 +125,7 @@ class Node(CTENode):
language
=
models
.
ForeignKey
(
Language
,
blank
=
True
,
null
=
True
,
on_delete
=
models
.
SET_NULL
)
language
=
models
.
ForeignKey
(
Language
,
blank
=
True
,
null
=
True
,
on_delete
=
models
.
SET_NULL
)
date
=
models
.
DateField
(
default
=
timezone
.
now
,
blank
=
True
)
date
=
models
.
DateField
(
default
=
timezone
.
now
,
blank
=
True
)
metadata
=
hstore
.
Dictionary
Field
(
blank
=
True
)
metadata
=
jsonfield
.
JSON
Field
(
blank
=
True
)
ngrams
=
models
.
ManyToManyField
(
through
=
'Node_Ngram'
,
to
=
'Ngram'
)
ngrams
=
models
.
ManyToManyField
(
through
=
'Node_Ngram'
,
to
=
'Ngram'
)
...
...
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