From 80bd4ff35b4040473b9085f55ac5514de33c8434 Mon Sep 17 00:00:00 2001 From: CapooL <111524029+CapooL@users.noreply.github.com> Date: Thu, 23 Nov 2023 21:39:19 +0800 Subject: [PATCH] fix(words): remove duplicated characters on CH0204 (#345) --- hinghwa-dict-backend/word/character/views.py | 6 ++++++ .../word/migrations/0005_listadmin.py | 16 ---------------- 2 files changed, 6 insertions(+), 16 deletions(-) delete mode 100644 hinghwa-dict-backend/word/migrations/0005_listadmin.py diff --git a/hinghwa-dict-backend/word/character/views.py b/hinghwa-dict-backend/word/character/views.py index a3d9f159..a995f339 100644 --- a/hinghwa-dict-backend/word/character/views.py +++ b/hinghwa-dict-backend/word/character/views.py @@ -117,6 +117,12 @@ def searchCharactersPinyin(request): result1[pinyin]["characters"].append( {"character": character, "word": word, "traditional": traditional} ) + unique_result = [] + exist_set = set() + for item in result1.values(): + if item["pinyin"] not in exist_set: + unique_result.append(item) + exist_set.add(item["pinyin"]) return JsonResponse({"result": list(result1.values())}, status=200) else: return JsonResponse({}, status=405) diff --git a/hinghwa-dict-backend/word/migrations/0005_listadmin.py b/hinghwa-dict-backend/word/migrations/0005_listadmin.py deleted file mode 100644 index 7466a2d9..00000000 --- a/hinghwa-dict-backend/word/migrations/0005_listadmin.py +++ /dev/null @@ -1,16 +0,0 @@ -# Generated by Django 3.1.14 on 2023-09-16 08:49 - -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("word", "0004_word_list"), - ] - - operations = [ - migrations.AlterModelOptions( - name="list", - options={"verbose_name": "词单", "verbose_name_plural": "词单"}, - ), - ]