Skip to content
Snippets Groups Projects
Commit 4d4bba17 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Merge branch 'meilisearch-fetch-articles' into rework-references

parents 689c4ea5 7cdf0f60
No related branches found
No related tags found
1 merge request!224Resolve "Rework references"
Pipeline #124497 waiting for manual action with stages
in 8 minutes and 11 seconds
import { useArticlesStore, type CslJson } from '../stores/articles'
import { useArticlesStore } from '../stores/articles'
import { ref, computed, watchEffect, toValue } from "vue"
// import { useFetch } from '#app';
// import { useFetch } from "nuxt"
import { type MaybeRef, useFetch } from '#imports'
import article from "@/public/articles.json"
export interface CrossrefArticle {
DOI: string;
issue: number;
type: string;
title: string[];
author: Array<{ family: string; given: string }>;
// "container-title-short": string;
"short-container-title": string;
"container-title": string;
abstract?: string;
published: {
"date-parts": string[];
};
issued: {
"date-parts": string[];
};
}
import type { CslJson, CrossrefArticle, SrcArticle } from '@/types/articles';
export interface WikiArticle {
DOI: string
title: string
subtitle: string
author: Array<{ family: string; given: string }>
containerTitle: string
abstract: string
year: string
href: string
target: string
prependIcon: string
}
export interface RawArticle {
message: CrossrefArticle
}
type SrcArticle = CrossrefArticle | CslJson
export function useFetchArticle(doi: MaybeRef<string> = ref("")) {
// const article = ref<Article>()
......
......@@ -308,6 +308,29 @@ def update_systems(
index.update_typo_tolerance({"enabled": False})
def update_articles(
host: str,
key: str,
file: Path,
document: str,
):
client = meilisearch.Client(host, key)
index = client.index(document.lower())
with open(file, "r") as jsonfile:
json_object = json.load(jsonfile)
for obj in json_object:
obj["ms_id"] = obj["id"].replace("/", "_")
tasks = index.add_documents_in_batches(json_object, primary_key="ms_id")
for task in tasks:
print(task)
pagination_settings_task = index.update_pagination_settings(
{"maxTotalHits": 100000}
)
print(pagination_settings_task)
def split_on_comma(str_val: str) -> List[str]:
for val in str_val.split(","):
yield val.strip()
......@@ -3,10 +3,11 @@ import meilisearch
from typing_extensions import Annotated
from pathlib import Path
from df_wiki_cli.meilisearch import (
update_refseqtaxo,
update_articles,
update_refseq,
update_structure,
update_systems,
update_refseqtaxo,
)
from enum import Enum
from types import SimpleNamespace
......@@ -23,6 +24,7 @@ class Documents(str, Enum):
refseq = "refseq"
structure = "structure"
systems = "systems"
article = "article"
@app.callback()
......@@ -69,6 +71,8 @@ def update(
update_structure(ctx.obj.host, ctx.obj.key, file, document)
if document == "systems":
update_systems(ctx.obj.host, ctx.obj.key, file, document)
if document == "article":
update_articles(ctx.obj.host, ctx.obj.key, file, document)
@app.command()
......
import { defineStore } from 'pinia'
import { ref } from 'vue'
// import jsonArticles from '@/assets/articles.json'
import type { CslJson } from "@/types/articles"
export interface CslJson {
// id: string
type: string
title: string
"container-title": string
// page: string,
// volume: string,
abstract: string
// URL: string
DOI: string
// journalAbbreviation: string
// language: string
author: Array<{ family: string, given: string }>
issued: {
"date-parts": Array<string>
},
}
export const useArticlesStore = defineStore('articles', () => {
const articleMap = new Map([])
......
export interface WikiArticle {
DOI: string
title: string
subtitle: string
author: Array<{ family: string; given: string }>
containerTitle: string
abstract: string
year: string
href: string
target: string
prependIcon: string
}
export interface CslJson {
// id: string
type: string
title: string
"container-title": string
// page: string,
// volume: string,
abstract: string
// URL: string
DOI: string
// journalAbbreviation: string
// language: string
author: Array<{ family: string, given: string }>
issued: {
"date-parts": Array<string>
},
}
export interface CrossrefArticle {
DOI: string;
issue: number;
type: string;
title: string[];
author: Array<{ family: string; given: string }>;
// "container-title-short": string;
"short-container-title": string;
"container-title": string;
abstract?: string;
published: {
"date-parts": string[];
};
issued: {
"date-parts": string[];
};
}
export interface RawArticle {
message: CrossrefArticle
}
export type SrcArticle = CrossrefArticle | CslJson
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment