Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
NACSOS Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MCC APSIS
NACSOS
NACSOS Core
Commits
2931ae3b
Commit
2931ae3b
authored
1 year ago
by
Tim Repke
Browse files
Options
Downloads
Patches
Plain Diff
include lexisnexis
parent
e82c6302
No related branches found
No related tags found
1 merge request
!61
Master
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/api/routes/export.py
+2
-0
2 additions, 0 deletions
server/api/routes/export.py
server/api/routes/project/items.py
+12
-2
12 additions, 2 deletions
server/api/routes/project/items.py
server/api/routes/stats.py
+17
-3
17 additions, 3 deletions
server/api/routes/stats.py
with
31 additions
and
5 deletions
server/api/routes/export.py
+
2
−
0
View file @
2931ae3b
...
...
@@ -109,6 +109,8 @@ async def get_export_baseinfo(permissions: UserPermissions = Depends(UserPermiss
fields
=
[
'
text
'
,
'
twitter_id
'
,
'
created_at
'
,
'
twitter_author_id
'
,
'
conversation_id
'
]
elif
project
.
type
==
ItemType
.
academic
:
fields
=
[
'
text
'
,
'
title
'
,
'
doi
'
,
'
wos_id
'
,
'
scopus_id
'
,
'
openalex_id
'
,
'
publication_year
'
,
'
source
'
]
elif
project
.
type
==
ItemType
.
lexis
:
fields
=
[
'
text
'
,
'
teaser
'
,
'
author
'
]
# TODO: ideally we would also export the source data
else
:
fields
=
[
'
text
'
]
...
...
This diff is collapsed.
Click to expand it.
server/api/routes/project/items.py
+
12
−
2
View file @
2931ae3b
from
fastapi
import
APIRouter
,
Depends
,
HTTPException
,
status
,
Query
from
nacsos_data.db.schemas
import
Project
,
ItemTypeLiteral
,
GenericItem
,
AcademicItem
,
ItemType
,
Item
from
nacsos_data.db.schemas
import
Project
,
ItemTypeLiteral
,
GenericItem
,
AcademicItem
,
ItemType
,
Item
,
LexisNexisItem
from
nacsos_data.models.items
import
AnyItemModel
,
GenericItemModel
,
AcademicItemModel
,
AnyItemModelList
from
nacsos_data.models.items
import
AnyItemModel
,
GenericItemModel
,
AcademicItemModel
,
AnyItemModelList
,
\
LexisNexisItemModel
from
nacsos_data.models.items.twitter
import
TwitterItemModel
from
nacsos_data.db.crud.items
import
\
read_item_count_for_project
,
\
...
...
@@ -36,6 +37,9 @@ async def list_project_data(item_type: ItemTypeLiteral,
if
item_type
==
'
academic
'
:
return
await
read_all_for_project
(
Model
=
AcademicItemModel
,
Schema
=
AcademicItem
,
project_id
=
project_id
,
engine
=
db_engine
)
if
item_type
==
'
lexis
'
:
return
await
read_all_for_project
(
Model
=
LexisNexisItemModel
,
Schema
=
LexisNexisItem
,
project_id
=
project_id
,
engine
=
db_engine
)
if
item_type
==
'
twitter
'
:
return
await
read_all_twitter_items_for_project
(
project_id
=
project_id
,
engine
=
db_engine
)
raise
HTTPException
(
status_code
=
status
.
HTTP_501_NOT_IMPLEMENTED
,
...
...
@@ -54,6 +58,10 @@ async def list_project_data_paged(item_type: ItemTypeLiteral, page: int, page_si
return
await
read_paged_for_project
(
Model
=
AcademicItemModel
,
Schema
=
AcademicItem
,
page
=
page
,
page_size
=
page_size
,
project_id
=
project_id
,
engine
=
db_engine
)
if
item_type
==
'
lexis
'
:
return
await
read_paged_for_project
(
Model
=
LexisNexisItemModel
,
Schema
=
LexisNexisItem
,
page
=
page
,
page_size
=
page_size
,
project_id
=
project_id
,
engine
=
db_engine
)
if
item_type
==
'
twitter
'
:
return
await
read_all_twitter_items_for_project_paged
(
project_id
=
project_id
,
page
=
page
,
page_size
=
page_size
,
engine
=
db_engine
)
...
...
@@ -78,6 +86,8 @@ async def get_detail_for_item(item_id: str,
result
=
await
read_twitter_item_by_item_id
(
item_id
=
item_id
,
engine
=
db_engine
)
elif
item_type
==
'
academic
'
:
result
=
await
read_any_item_by_item_id
(
item_id
=
item_id
,
item_type
=
ItemType
.
academic
,
engine
=
db_engine
)
elif
item_type
==
'
lexis
'
:
result
=
await
read_any_item_by_item_id
(
item_id
=
item_id
,
item_type
=
ItemType
.
lexis
,
engine
=
db_engine
)
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_501_NOT_IMPLEMENTED
,
detail
=
f
'
Detail getter for
{
item_type
}
not implemented (yet).
'
)
...
...
This diff is collapsed.
Click to expand it.
server/api/routes/stats.py
+
17
−
3
View file @
2931ae3b
...
...
@@ -6,8 +6,19 @@ from pydantic import BaseModel
from
fastapi
import
APIRouter
,
Depends
,
Query
from
sqlalchemy
import
select
,
func
as
F
,
desc
,
text
from
nacsos_data.db.schemas
import
Item
,
Import
,
AnnotationScheme
,
AssignmentScope
,
Annotation
,
User
,
Project
,
ItemType
,
\
AcademicItem
,
TwitterItem
from
nacsos_data.db.schemas
import
(
Item
,
Import
,
AnnotationScheme
,
AssignmentScope
,
Annotation
,
User
,
Project
,
ItemType
,
AcademicItem
,
TwitterItem
,
LexisNexisItemSource
)
from
nacsos_data.util.auth
import
UserPermissions
from
server.api.errors
import
ProjectNotFoundError
...
...
@@ -132,8 +143,11 @@ async def get_publication_year_histogram(
elif
project
.
type
==
ItemType
.
twitter
:
table
=
TwitterItem
.
__tablename__
column
=
TwitterItem
.
created_at
.
name
elif
project
.
type
==
ItemType
.
lexis
:
table
=
LexisNexisItemSource
.
__tablename__
column
=
LexisNexisItemSource
.
published_at
.
name
else
:
raise
NotImplementedError
(
'
Only available for academic and twitter projects!
'
)
raise
NotImplementedError
(
'
Only available for academic
, lexisnexis,
and twitter projects!
'
)
stmt
=
text
(
f
'''
WITH buckets as (SELECT generate_series(:from_date ::timestamp, :to_date ::timestamp,
'
1 year
'
) as bucket),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment