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
Hide 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,34 +46,30 @@ def project(request, project_id):
# Let's find out about the children nodes of the project
ChildrenNode
=
aliased
(
Node
)
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
(
Node_Resource
,
Node_Resource
.
node_id
==
Node
.
id
)
.
outerjoin
(
Resource
,
Resource
.
id
==
Node_Resource
.
resource_id
)
.
filter
(
Node
.
parent_id
==
project
.
id
)
.
group_by
(
Node
,
Resource
)
.
group_by
(
Node
.
id
,
Node
.
name
,
Resource
.
type_id
)
.
order_by
(
Node
.
name
)
)
corpora_by_resourcetype
=
defaultdict
(
list
)
documents_count_by_resourcetype
=
defaultdict
(
int
)
corpora_count
=
0
corpusID_dict
=
{}
for
corpus
,
resource
,
document_count
in
corpus_query
:
if
not
corpus
.
id
in
corpusID_dict
:
if
resource
is
None
:
resourcetype_name
=
'(no resource)'
else
:
resourcetype
=
cache
.
ResourceType
[
resource
.
type_id
]
resourcetype_name
=
resourcetype
.
name
corpusID_dict
[
corpus
.
id
]
=
True
corpora_by_resourcetype
[
resourcetype_name
]
.
append
({
'id'
:
corpus
.
id
,
'name'
:
corpus
.
name
,
'count'
:
document_count
,
})
documents_count_by_resourcetype
[
resourcetype_name
]
+=
document_count
corpora_count
+=
1
for
corpus_id
,
corpus_name
,
resource_type_id
,
document_count
in
corpus_query
:
if
resource_type_id
is
None
:
resourcetype_name
=
'(no resource)'
else
:
resourcetype
=
cache
.
ResourceType
[
resource_type_id
]
resourcetype_name
=
resourcetype
.
name
corpora_by_resourcetype
[
resourcetype_name
]
.
append
({
'id'
:
corpus_id
,
'name'
:
corpus_name
,
'count'
:
document_count
,
})
documents_count_by_resourcetype
[
resourcetype_name
]
+=
document_count
corpora_count
+=
1
# do the donut
total_documents_count
=
sum
(
documents_count_by_resourcetype
.
values
())
...
...
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
from
django.contrib.auth.models
import
User
from
django_hstore
import
hstore
import
jsonfield
from
cte_tree.models
import
CTENode
,
CTENodeManager
# from cte_tree.query import CTEQuerySet
#from cte_tree.fields import DepthField, PathField, OrderingField
...
...
@@ -125,7 +125,7 @@ class Node(CTENode):
language
=
models
.
ForeignKey
(
Language
,
blank
=
True
,
null
=
True
,
on_delete
=
models
.
SET_NULL
)
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'
)
...
...
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