Compare commits

...

4 Commits

Author SHA1 Message Date
dependabot[bot] 42dedf187e
Merge 9c1b62e7d5 into be67f965eb 2024-11-21 22:27:28 +00:00
Robbie Antenesse be67f965eb Restore PublicDictionary's details_only option 2023-10-31 16:25:42 -06:00
Robbie Antenesse ed7f06d061 omg don't query for every reference! 2023-10-31 16:23:58 -06:00
dependabot[bot] 9c1b62e7d5
Bump shell-quote from 1.7.2 to 1.7.3
Bumps [shell-quote](https://github.com/substack/node-shell-quote) from 1.7.2 to 1.7.3.
- [Release notes](https://github.com/substack/node-shell-quote/releases)
- [Changelog](https://github.com/substack/node-shell-quote/blob/master/CHANGELOG.md)
- [Commits](https://github.com/substack/node-shell-quote/compare/v1.7.2...1.7.3)

---
updated-dependencies:
- dependency-name: shell-quote
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-22 07:02:48 +00:00
2 changed files with 17 additions and 22 deletions

View File

@ -10,7 +10,7 @@ class PublicDictionary {
public $details; public $details;
public $words; public $words;
function __construct ($dictionary_id) { function __construct ($dictionary_id, $details_only = false) {
$this->db = new Db(); $this->db = new Db();
$this->token = new Token(); $this->token = new Token();
@ -19,7 +19,7 @@ class PublicDictionary {
); );
$this->details = $this->getPublicDictionaryDetails($dictionary_id); $this->details = $this->getPublicDictionaryDetails($dictionary_id);
$this->words = $this->getPublicDictionaryWords($dictionary_id); $this->words = $details_only ? [] : $this->getPublicDictionaryWords($dictionary_id);
if ($this->details !== false) { if ($this->details !== false) {
$this->details['wordStats'] = $this->getWordStats(); $this->details['wordStats'] = $this->getWordStats();
} }
@ -123,13 +123,10 @@ class PublicDictionary {
return array(); return array();
} }
public function getSpecificPublicDictionaryWord ($dictionary, $word) { public function getSpecificPublicDictionaryWord ($dictionary, $word_id) {
if (is_numeric($dictionary) && is_numeric($word)) { if (is_numeric($dictionary) && is_numeric($word_id)) {
$query = "SELECT words.*, wa.etymology, wa.related, wa.principal_parts FROM words $results = array_filter($this->getWordsAsEntered(), fn ($row) => $row['word_id'] == $word_id);
LEFT JOIN words_advanced wa ON wa.dictionary = words.dictionary AND wa.word_id = words.word_id $result = array_values($results)[0] ?? null;
JOIN dictionaries ON dictionaries.id = words.dictionary
WHERE words.dictionary=? AND words.word_id=? AND dictionaries.is_public=1";
$result = $this->db->query($query, array($dictionary, $word))->fetch();
if ($result) { if ($result) {
$word = array( $word = array(
'name' => $this->translateOrthography($result['name'], $dictionary), 'name' => $this->translateOrthography($result['name'], $dictionary),
@ -265,7 +262,7 @@ WHERE words.dictionary=? AND is_public=1";
} }
$target_id = false; $target_id = false;
$reference_ids = $this->getWordIdsWithName($dictionary_id, $word_to_find); $reference_ids = $this->getWordIdsFromName($word_to_find);
if (count($reference_ids) > 0) { if (count($reference_ids) > 0) {
if ($homonymn !== false && $homonymn > 0) { if ($homonymn !== false && $homonymn > 0) {
@ -293,16 +290,14 @@ WHERE words.dictionary=? AND is_public=1";
return $reference; return $reference;
} }
private function getWordIdsWithName($dictionary, $word_name) { private function getWordIdsFromName($word_name) {
if (is_numeric($dictionary)) { $results = array_filter($this->getWordsAsEntered(), fn ($row) => $row['name'] == $word_name);
$query = "SELECT word_id FROM words WHERE dictionary=? AND name=?"; $results = array_values($results);
$results = $this->db->query($query, array($dictionary, $word_name))->fetchAll();
if ($results) { if ($results) {
return array_map(function ($row) { return array_map(function ($row) {
return intval($row['word_id']); return intval($row['word_id']);
}, $results); }, $results);
} }
}
return array(); return array();
} }

View File

@ -5519,9 +5519,9 @@ shebang-regex@^1.0.0:
integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=
shell-quote@^1.6.1: shell-quote@^1.6.1:
version "1.7.2" version "1.7.3"
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2" resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.3.tgz#aa40edac170445b9a431e17bb62c0b881b9c4123"
integrity sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg== integrity sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==
side-channel@^1.0.4: side-channel@^1.0.4:
version "1.0.4" version "1.0.4"