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
476ce7a0
Commit
476ce7a0
authored
Mar 13, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Project view, number of docs.
parent
19e1783b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
66 deletions
+26
-66
urls.py
gargantext_web/urls.py
+2
-1
views.py
gargantext_web/views.py
+23
-65
views_optimized.py
gargantext_web/views_optimized.py
+1
-0
No files found.
gargantext_web/urls.py
View file @
476ce7a0
...
@@ -31,7 +31,8 @@ urlpatterns = patterns('',
...
@@ -31,7 +31,8 @@ urlpatterns = patterns('',
# Project Management
# Project Management
url
(
r'^projects/$'
,
views
.
projects
),
url
(
r'^projects/$'
,
views
.
projects
),
url
(
r'^project/(\d+)/$'
,
views_optimized
.
project
),
url
(
r'^project/(\d+)/$'
,
views_optimized
.
project
),
url
(
r'^project/(\d+)/delete/$'
,
views
.
delete_project
),
url
(
r'^project/(\d+)/delete/$'
,
views
.
delete_node
),
url
(
r'^delete/(\d+)$'
,
views
.
delete_node
),
# Corpus management
# Corpus management
url
(
r'^project/(\d+)/corpus/(\d+)/$'
,
views
.
corpus
),
url
(
r'^project/(\d+)/corpus/(\d+)/$'
,
views
.
corpus
),
...
...
gargantext_web/views.py
View file @
476ce7a0
...
@@ -39,7 +39,7 @@ from django.contrib.auth import authenticate, login, logout
...
@@ -39,7 +39,7 @@ from django.contrib.auth import authenticate, login, logout
from
scrap_pubmed.admin
import
Logger
from
scrap_pubmed.admin
import
Logger
from
gargantext_web.db
import
*
from
gargantext_web.db
import
*
from
sqlalchemy
import
or_
,
func
def
login_user
(
request
):
def
login_user
(
request
):
logout
(
request
)
logout
(
request
)
...
@@ -441,66 +441,11 @@ def corpus(request, project_id, corpus_id):
...
@@ -441,66 +441,11 @@ def corpus(request, project_id, corpus_id):
user
=
request
.
user
user
=
request
.
user
date
=
datetime
.
datetime
.
now
()
date
=
datetime
.
datetime
.
now
()
project
=
Node
.
objects
.
get
(
id
=
project_id
)
project
=
cache
.
Node
[
project_id
]
corpus
=
Node
.
objects
.
get
(
id
=
corpus_id
)
corpus
=
cache
.
Node
[
corpus_id
]
type_doc
=
NodeType
.
objects
.
get
(
name
=
"Document"
)
type_doc_id
=
cache
.
NodeType
[
'Document'
]
.
id
number
=
Node
.
objects
.
filter
(
parent
=
corpus
,
type
=
type_doc
)
.
count
()
number
=
session
.
query
(
func
.
count
(
Node
.
id
))
.
filter
(
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
type_doc_id
)
.
all
()[
0
][
0
]
# try:
# sources = defaultdict(int)
# for document in documents.all():
# sources[document.metadata['journal']] += 1
#
# sources_donut = []
#
# for source in sources.keys():
# source_count = dict()
# source_count['count'] = source['count']
# try:
# source_count['part'] = round(source_count['count'] * 100 / number)
# except:
# source_count['part'] = None
# source_count['source'] = source['source']
# sources_donut.append(source_count)
# except:
# sources_donut = []
# Do a javascript query/api for that
# query_date = """
# SELECT
# id,
# metadata -> 'publication_year' as year,
# metadata -> 'publication_month' as month,
# metadata -> 'publication_day' as day,
# metadata -> 'title'
# FROM
# node_node AS n
# WHERE
# n.parent_id = %d
# ORDER BY
# year, month, day DESC
# LIMIT
# 20
# OFFSET
# %d
# """ % (corpus.id, 0)
# try:
# cursor = connection.cursor()
#
# cursor.execute(query_date)
# documents = list()
# while True:
# document = dict()
# row = cursor.fetchone()
#
# if row is None:
# break
# document['id'] = row[0]
# document['date'] = row[1] + '/' + row[2] + '/' + row[3]
# document['title'] = row[4]
# documents.append(document)
# except Exception as error:
# print(error)
try
:
try
:
chart
=
dict
()
chart
=
dict
()
...
@@ -667,12 +612,25 @@ def subcorpusJSON(request, project_id, corpus_id, start , end ):
...
@@ -667,12 +612,25 @@ def subcorpusJSON(request, project_id, corpus_id, start , end ):
# return HttpResponse(html)
# return HttpResponse(html)
return
HttpResponse
(
serializer
.
data
,
content_type
=
'application/json'
)
return
HttpResponse
(
serializer
.
data
,
content_type
=
'application/json'
)
def
delete_project
(
request
,
node_id
):
def
delete_node
(
request
,
node_id
):
Node
.
objects
.
filter
(
id
=
node_id
)
.
all
()
.
delete
()
return
HttpResponseRedirect
(
'/projects/'
)
def
delete_corpus
(
request
,
project_id
,
corpus_id
):
#nodes = session.query(Node).filter(or_(Node.id == node_id, Node.parent_id == node_id)).all()
Node
.
objects
.
filter
(
id
=
corpus_id
)
.
all
()
.
delete
()
node
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
session
.
delete
(
node
)
session
.
flush
()
if
node
.
type_id
==
cache
.
NodeType
[
'Project'
]
.
id
:
return
HttpResponseRedirect
(
'/projects/'
)
elif
node
.
type_id
==
cache
.
NodeType
[
'Corpus'
]
.
id
:
return
HttpResponseRedirect
(
'/project/'
+
node_id
)
def
delete_corpus
(
request
,
project_id
,
node_id
):
node
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
session
.
delete
(
node
)
session
.
commit
()
session
.
flush
()
return
HttpResponseRedirect
(
'/project/'
+
project_id
)
return
HttpResponseRedirect
(
'/project/'
+
project_id
)
def
chart
(
request
,
project_id
,
corpus_id
):
def
chart
(
request
,
project_id
,
corpus_id
):
...
...
gargantext_web/views_optimized.py
View file @
476ce7a0
...
@@ -27,6 +27,7 @@ def project(request, project_id):
...
@@ -27,6 +27,7 @@ def project(request, project_id):
project_id
=
int
(
project_id
)
project_id
=
int
(
project_id
)
except
ValueError
:
except
ValueError
:
raise
Http404
()
raise
Http404
()
# do we have a valid project?
# do we have a valid project?
project
=
(
session
project
=
(
session
.
query
(
Node
)
.
query
(
Node
)
...
...
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