Преглед на файлове

moved tags from pages to documents

master
Pascal Gloor преди 5 години
родител
ревизия
5ebf446344
променени са 2 файла, в които са добавени 18 реда и са изтрити 16 реда
  1. 10
    8
      cgi/autodoc.fcgi
  2. 8
    8
      etc/openapi.json

+ 10
- 8
cgi/autodoc.fcgi Целия файл

@@ -108,6 +108,7 @@ sub db_get_document_object {
my $document;
my @pages;
my @pageids;
my @tags;

my $q = sqlquery($dbh, "SELECT * FROM documents WHERE id = ?", $id);
while(my $hash = $q->fetchrow_hashref()) { $document = $hash; }
@@ -115,6 +116,12 @@ sub db_get_document_object {
$q = sqlquery($dbh, "SELECT * FROM pages WHERE documentId = ?", $id);
while(my $hash = $q->fetchrow_hashref()) { push @pages, $hash; push @pageids, $hash->{id}; }

$q = sqlquery($dbh, "
SELECT tags.tag AS tag
FROM documents_tags LEFT JOIN tags ON documents_tags.tagId = tags.id
WHERE documentId = ?i SORT BY tag", $id);
while(my ($tag) = $q->fetchrow_array()) { push @tags, $tag; }

my %lang;

foreach my $page ( @pages ) {
@@ -134,8 +141,9 @@ sub db_get_document_object {
owner => $document->{owner},
status => $document->{status},
languages => [ keys %lang ],
tags => [ @tags ],
};
return (200, "application/json", $out);
}

@@ -147,18 +155,13 @@ sub db_get_page_object {

my $out;
my %lang;
my @tags;

my $q = sqlquery($dbh, "SELECT * FROM pages_lang WHERE pageId = ?", $id);
while(my $hash = $q->fetchrow_hashref()) {
$lang{$hash->{language}}++;
}

$q = sqlquery($dbh, "
SELECT tags.tag AS tag
FROM pages_tags LEFT JOIN tags ON pages_tags.tagId = tags.id
WHERE pageId = ?i SORT BY tag", $id);
while(my ($tag) = $q->fetchrow_array()) { push @tags, $tag; }


$q = sqlquery($dbh, "SELECT * FROM pages WHERE documentId = ?", $id);
while(my $hash = $q->fetchrow_hashref()) {
@@ -170,7 +173,6 @@ sub db_get_page_object {
owner => $hash->{owner},
status => $hash->{status},
language => [ keys %lang ],
tags => [ @tags ],
};
}


+ 8
- 8
etc/openapi.json Целия файл

@@ -88,14 +88,6 @@
"fr"
]
}
},
"tags": {
"readOnly": true,
"description": "List of all tags",
"type": "array",
"items": {
"type": "string"
}
}
}
},
@@ -159,6 +151,14 @@
"fr"
]
}
},
"tags": {
"readOnly": true,
"description": "List of all tags",
"type": "array",
"items": {
"type": "string"
}
}
}
}

Loading…
Отказ
Запис