Skip to content

Commit

Permalink
fix tombstone ingest and add tombstone UI (#1378)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarosenb authored Jul 29, 2024
1 parent 3db894e commit ab6dc48
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 22 deletions.
4 changes: 4 additions & 0 deletions client/modules/_hooks/src/datafiles/projects/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export type TBaseProjectValue = {

title: string;
description: string;
tombstone?: boolean;
tombstoneMessage?: string;
users: TProjectUser[];
dataTypes?: TDropdownValue[];
authors: TProjectUser[];
Expand All @@ -100,6 +102,8 @@ export type TBaseProjectValue = {

export type TEntityValue = {
title: string;
tombstone?: boolean;
tombstoneMessage?: string;
description?: string;
dataCollectors?: TProjectUser[];
projectId?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ export function useDataciteEvents(doi: string, enabled: boolean = true) {
return getDataciteEvents({ doi, signal });
},
enabled: enabled && !!doi,
retry: false,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export function useDataciteMetrics(doi: string, enabled: boolean = true) {
return getDataciteMetrics({ doi, signal });
},
enabled: enabled && !!doi,
retry: false,
});
}
20 changes: 20 additions & 0 deletions client/modules/datafiles/src/projects/PublishedEntityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
LicenseDisplay,
UsernamePopover,
} from './BaseProjectDetails';
import { Alert } from 'antd';

export const PublishedEntityDetails: React.FC<{
entityValue: TEntityValue;
Expand All @@ -15,6 +16,25 @@ export const PublishedEntityDetails: React.FC<{
}> = ({ entityValue, publicationDate, license }) => {
return (
<section style={{ marginBottom: '20px' }}>
{entityValue.tombstone && (
<Alert
showIcon
style={{ marginBottom: '12px' }}
type="warning"
message={
<strong>The following Dataset does not exist anymore</strong>
}
description={
<div>
The Dataset with DOI:{' '}
<a href={`https://doi.org/${entityValue.dois?.[0]}`}>
{entityValue.dois?.[0]}
</a>{' '}
was incomplete and removed. The metadata is still available.
</div>
}
/>
)}
<table
style={{ width: '100%', marginBottom: '20px', borderSpacing: '200px' }}
>
Expand Down
54 changes: 37 additions & 17 deletions client/src/datafiles/layouts/published/PublishedDetailLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,47 @@ export const PublishedDetailLayout: React.FC = () => {
</div>

{data.baseProject.projectType === 'other' && (
<section
style={{
backgroundColor: '#eef9fc',
padding: '10px 20px',
margin: '10px 0px',
}}
>
<strong>Cite This Data:</strong>
<>
{data.baseProject.tombstone && (
<Alert
showIcon
type="warning"
message={
<strong>The following Dataset does not exist anymore</strong>
}
description={
<div>
The Dataset with DOI:{' '}
<a href={`https://doi.org/${data.baseProject.dois[0]}`}>
{data.baseProject.dois[0]}
</a>{' '}
was incomplete and removed. The metadata is still available.
</div>
}
/>
)}
<section
style={{
backgroundColor: '#eef9fc',
padding: '10px 20px',
margin: '10px 0px',
}}
>
<strong>Cite This Data:</strong>

<PublishedCitation
projectId={projectId}
entityUuid={data.tree.children[0].uuid}
/>
<br />
<div>
<DownloadCitation
<PublishedCitation
projectId={projectId}
entityUuid={data.tree.children[0].uuid}
/>
</div>
</section>
<br />
<div>
<DownloadCitation
projectId={projectId}
entityUuid={data.tree.children[0].uuid}
/>
</div>
</section>
</>
)}
<BaseProjectDetails
projectValue={data?.baseProject}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Utilities to update the database with existing project file associations"""

import json
import os
from typing import Iterator
import requests
from urllib3.util import Retry
from requests import Session
from requests.exceptions import RetryError
from requests.adapters import HTTPAdapter
from django.conf import settings
from designsafe.apps.api.agave import service_account
from designsafe.apps.api.agave import get_service_account_client_v2 as service_account
from designsafe.apps.api.projects_v2.schema_models._field_models import FileObj
from designsafe.apps.api.projects_v2.models.project_metadata import ProjectMetadata
from designsafe.apps.api.projects_v2.operations.project_meta_operations import (
Expand Down Expand Up @@ -98,7 +99,7 @@ def get_files_for_entity(
file_meta = resp.json()["result"][0]
entity_file_objs.append(
FileObj(
name=file_meta["name"],
name=os.path.basename(file_meta["path"]),
system=file_meta["system"],
path=file_meta["path"],
type=file_meta["type"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,33 @@ def ingest_publications():
def ingest_tombstones():
"""Ingest Elasticsearch tombstones into the db"""

tombstone_ids = [
"PRJ-1945",
"PRJ-1895",
"PRJ-2329",
"PRJ-2016",
"PRJ-2227",
"PRJ-2420",
"PRJ-3815",
"PRJ-3908",
"PRJ-4151",
"PRJ-4014",
]
all_pubs = (
IndexedPublication.search().filter(Q("term", status="tombstone")).execute().hits
IndexedPublication.search()
.filter(
Q("term", status="tombstone")
| Q("terms", **{"projectId._exact": tombstone_ids})
)
.execute()
.hits
)
print(all_pubs)
for pub in all_pubs:
try:
pub_graph = combine_pub_versions(pub["projectId"])
for published_entity_node_id in pub_graph.successors("NODE_ROOT"):
pub_graph.nodes[published_entity_node_id]["value"]["tombstone"] = True
latest_version: int = IndexedPublication.max_revision(pub["projectId"]) or 1
pub_base = next(
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def convert_v2_user(user):
role = "team_member"
username = user["name"]

if not user.get("fname"):
user = {**user, **get_user_info(user["name"], role)}

return {
"fname": user["fname"],
"lname": user["lname"],
Expand Down
8 changes: 6 additions & 2 deletions designsafe/apps/api/publications_v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,17 @@ def get(self, request: HttpRequest):
if has_query:
hits, total = handle_search(query_opts, offset, limit)
publications_query = (
Publication.objects.filter(project_id__in=hits)
Publication.objects.filter(project_id__in=hits, is_published=True)
.defer("tree")
.order_by("-created")
)
publications = publications_query
else:
publications_query = Publication.objects.defer("tree").order_by("-created")
publications_query = (
Publication.objects.filter(is_published=True)
.defer("tree")
.order_by("-created")
)
total = publications_query.count()
publications = publications_query[offset : offset + limit]
result = [
Expand Down

0 comments on commit ab6dc48

Please sign in to comment.