当前位置:网站首页>App optimization and advanced scoreboard Part 2 [Mui + flask + mongodb]
App optimization and advanced scoreboard Part 2 [Mui + flask + mongodb]
2022-04-23 01:50:00 【Progressive vegetable pig】
List of articles
Author's brief introduction : Hello everyone , I'm an up and comer pig . Inner Mongolia University of science and technology , Sophomore Planning Department . Technology is good, but don't give up , Try to do the whole stack . Love development , Development software , Develop web site , Develop all kinds of things .️
️ Personal home page : The blog of self-motivated vegetable pig
Series column : This article is written in 《APP Development from 0 To 1》 special column ️ If there is something wrong with the knowledge of the article , Please correct me. ! Study with you and make progress together
If you think the blogger's article is good , Three companies, please + Pay attention to and support bloggers
One , Preface
Next chapter . Mentioned in the previous article :
Today, there is another small demand : as follows : The ranking list can view the class ranking .
Problems to be solved :
1, Class attributes need to be added when registering .
2, The database needs a small change .
3, For the sake of friendliness , I added a segment display in the personal championship . Very friendly .
4, Add class ranking to the ranking list .
And I wrote the first three requirements , Write down the fourth requirement today .
Two , Back end —— Class ranking
First , Define a sum Variable , Inside mongo All data of table .
list_clss=[]
sum = db.mongo.find()
Define an empty list_clss list .
Purpose : Let's traverse the class value .
for i in sum:
sum_fries.append(i)
if(i['class'] not in list_clss):
list_clss.append(i['class'])
The above code block is explained as follows :
Let's loop through sum.
then sum_fries Is another storage sum Table content ( It's equivalent to making a copy of ).
Add a traversal storage condition . If , Now traverse to the value . stay list_clss If it is not in the list, add it , If . Some words , No additional .
Realization function :
De duplication function , Extract the registered user class now , Convenient follow-up operation .
list_clss_sum=[]
list_clss_people=[]
The above code block is explained as follows : Define two empty lists .
One is to put the total class points , The other is to put the number of classes , The listed method stores .

The above code block is explained as follows : Get list length , loop , Accumulate the current points of the people in the target class , Store in the corresponding sum In the list .
The number of people is the same , Every time you find a target , Self increase one .
str(list_clss[j])==str(ii[‘class’]), This is the screening criteria .
for jj in range(0,len(list_clss)):
The following is all right mongodb Data operation problems , as follows :

Get our dictionary set ready .
if(find==None):
db.classdb.insert_one(classdb)
if(find!=None and find_again==None):
db.classdb.update_one(
class_find,
{
'$set':class_again
}
)
The above code block is explained as follows :
Situation 1 : If you don't find the current content in the class data , Do the add operation , The code above find==none.
Situation two : If the goal is already in the class database , But it's not exactly the same , We need to perform the update mongodb Operation of database .
after_find=db.classdb.find({
}).sort([("average", -1)])
Last , Code above , We use mongodb Sorting function of , Has been evenly divided into goals , Sort in descending order .
append=[]
for i in after_find:
append.append(i)
print(append)
Then write a traversal , Put the sorted database target value , Add one by one to append in . Then pass it to the front end , Realize the functional requirements of class ranking .
3、 ... and , Results display

Last .MUI Zhenwen !
版权声明
本文为[Progressive vegetable pig]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220911390799.html
边栏推荐
- 代理IP可用率是不是等同于代理IP的效率?
- 2022第六季完美童模 IPA国民赛领跑元宇宙赛道
- 如何对代理IP进行分类?
- Technology cloud report: cloud computing has entered the "second half". Where is the way out for domestic cloud?
- 什么是代理IP池,如何构建?
- Shardingsphere introduction and sub table usage
- J-Link RTT使用
- What is a boolean type?
- mb_substr()、mb_strpos()函数(故事篇)
- .NET单元测试第一篇:常见.NET单元测试框架有哪些?
猜你喜欢

How to change the size of SVG pictures without width in openlayer

Leetcode 112 Total path (2022.04.22)

紫光国微财报一枝独秀 2021年净利润三位数增长靠什么

领导/老师让填写电子excel表格文档可手机上如何编辑word/excel文件填写excel/word电子文档?

有哪些业务会用到物理服务器?

2022 low voltage electrician examination questions and answers

客户端项目管理经常面临的挑战

浅析一下隧道代理IP的优缺点。

关于C4D动画如何导入Lumion

Solve the problem when installing MySQL
随机推荐
Basic knowledge of software testing, you can meet the interviewer after reading it
What business scenarios will the BGP server be used in?
keil mdk中文乱码,两种解决方法,字体不再难看
什么时候应该编写单元测试?什么是TDD?
PID refinement
2022.4.10-----leetcode.804
[tutorial] how to use GCC "zero assembly" for white whoring MDK
postman里面使用 xdebug 断点调试
代理IP可用率是不是等同于代理IP的效率?
Deployment of mask detection flash for yolov5
J-Link RTT使用
领导/老师让填写电子excel表格文档可手机上如何编辑word/excel文件填写excel/word电子文档?
How to write the resume of Software Test Engineer so that HR can see it?
NR polar code VII - SCL (successful cancellation list coding)
哪些代码需要做单元测试?
Problem solving: dpkg DEB: error: package name has characters that are't lowercase alphanums or '- +‘
What is a dial-up server and what is its use?
2022 crane driver (limited to bridge crane) examination question bank and online simulation examination
C语言中如何“指名道姓”的进行初始化
ESP32蓝牙Bluetooth Controller API介绍