1
+ import { createCardDetails } from "./create.ts" ;
2
+
1
3
import { CardDetail } from "@interfaces/card.ts" ;
2
4
import { ImasparqlResponse } from "@interfaces/imasparql.ts" ;
3
5
4
- const baseUrl = "https://sparql.crssnky.xyz/spql/imas/query" ;
6
+ const endpointUrl = "https://sparql.crssnky.xyz/spql/imas/query" ;
5
7
6
8
const query = `PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
9
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@@ -12,52 +14,18 @@ PREFIX imas: <https://sparql.crssnky.xyz/imasrdf/URIs/imas-schema.ttl#>
12
14
SELECT (IF(CONTAINS(STR(?o), "#"), STRAFTER(str(?o), "#"), STRAFTER(STR(?o), STR(schema:))) AS ?class) ?label (COUNT(DISTINCT ?s) AS ?count)
13
15
WHERE {
14
16
?s rdf:type ?o.
15
- FILTER(?o NOT IN (rdf:Property, rdfs:Class, owl:Ontology, imas:Idol_1st, schema:MusicRelease ))
17
+ FILTER(?o NOT IN (rdf:Property, rdfs:Class, owl:Ontology))
16
18
OPTIONAL { ?o rdfs:label ?label }
17
19
}
18
20
GROUP BY ?o ?label
19
- ORDER BY ?o` ;
20
-
21
- /**
22
- * APIのレスポンスからカードに表示するデータを作成
23
- * @param json レスポンス
24
- * @returns カードに表示するデータの配列
25
- */
26
- function createCardDetails ( json : ImasparqlResponse ) : CardDetail [ ] {
27
- console . log ( json ) ;
28
-
29
- const cards : CardDetail [ ] = [
30
- {
31
- title : "アイドル" ,
32
- count : "335" ,
33
- icon : "user" ,
34
- } ,
35
- {
36
- title : "ユニット" ,
37
- count : "1520" ,
38
- icon : "users" ,
39
- } ,
40
- {
41
- title : "ボイスアイドルオーディション" ,
42
- count : "6" ,
43
- icon : "microphone-2" ,
44
- } ,
45
- {
46
- title : "呼び名" ,
47
- count : "5923" ,
48
- icon : "messages" ,
49
- } ,
50
- ] ;
51
-
52
- return cards ;
53
- }
21
+ ORDER BY DESC (?count)` ;
54
22
55
23
/**
56
24
* カードに表示するデータを取得
57
25
* @returns カードに表示するデータの配列
58
26
*/
59
27
export async function fetchCardDetails ( ) : Promise < CardDetail [ ] > {
60
- const url = new URL ( baseUrl ) ;
28
+ const url = new URL ( endpointUrl ) ;
61
29
url . searchParams . append ( "query" , query ) ;
62
30
63
31
// TODO: アクセスエラー時の処理・タイムアウトの実装
0 commit comments