Skip to content
Snippets Groups Projects
Commit 2931ae3b authored by Tim Repke's avatar Tim Repke
Browse files

include lexisnexis

parent e82c6302
No related branches found
No related tags found
1 merge request!61Master
......@@ -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']
......
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).')
......
......@@ -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),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment