Skip to content

Commit

Permalink
Tsakorpus auto-refreshing -- #907 (#1151)
Browse files Browse the repository at this point in the history
* handling updated_at

* uploading on parserresult removing

* minor
  • Loading branch information
vmonakhov authored Nov 20, 2024
1 parent 2de2ec2 commit c81dff2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/components/UploadModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Upload = props => {
{getTranslation("Uploaded at")}
{": "}
{ uploaded_at
? new Date(uploaded_at).toLocaleString()
? new Date(uploaded_at * 1000).toLocaleString()
: "<never>"
}
{ user.id == 1 && (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Perspective/PerspectivePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const queryAvailablePerspectives = gql`

const uploadPerspective = gql`
mutation uploadPerspective($id: LingvodocID!, $debugFlag: Boolean) {
tsakorpus(perspective_id: $id, debug_flag: $debugFlag) {
tsakorpus(perspective_id: $id, force: true, debug_flag: $debugFlag) {
triumph
}
}
Expand Down
32 changes: 4 additions & 28 deletions src/pages/Perspective/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,17 +1113,6 @@ const Filter = handlers(({ value, onChange, onSubmit, isCaseSens, onToggleCaseSe
);
});

const getUploadDate = gql`
query getUploadDate($id: LingvodocID!) {
perspective(id: $id) {
id
additional_metadata {
uploaded_at
}
}
}
`;

const uploadPerspective = gql`
mutation uploadPerspective($id: LingvodocID!, $debugFlag: Boolean) {
tsakorpus(perspective_id: $id, debug_flag: $debugFlag) {
Expand Down Expand Up @@ -1151,23 +1140,10 @@ const ModeSelector = compose(
}) => {
const getTranslation = useContext(TranslationContext);

const {data: dateData, error: dateError, loading: dateLoading, refetch} = (
useQuery(getUploadDate, { variables: { id }, fetchPolicy: "network-only" }));

const [runUploadPerspective, {data, error, loading}] = (
useMutation(uploadPerspective, { variables: { id }, onCompleted: refetch }));

if (dateLoading || dateError) {
return null;
}

const {
perspective: { additional_metadata: { uploaded_at }}
} = dateData;
useMutation(uploadPerspective, { variables: { id } }));

if (!uploaded_at && !loading && !error && !data) {
runUploadPerspective();
}
useEffect(() => { runUploadPerspective(); }, []);

const modes = {};
if (user.id !== undefined) {
Expand Down Expand Up @@ -1210,10 +1186,10 @@ const ModeSelector = compose(
{info.component === PerspectiveView ? <Counter id={id} mode={info.entitiesMode} /> : null}
</Menu.Item>
))}
{ (uploaded_at || loading) && (
{ (loading || (!error && data && data.tsakorpus.triumph)) && (
<Menu.Item
key="corpus_search"
onClick={() => uploaded_at && window.open(`http://83.149.198.78/${id[0]}_${id[1]}/search`, "_blank")}
onClick={() => !loading && window.open(`http://83.149.198.78/${id[0]}_${id[1]}/search`, "_blank")}
content={
loading ? (
<span>
Expand Down

0 comments on commit c81dff2

Please sign in to comment.