当前位置:网站首页>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
边栏推荐
- [experience tutorial] Alipay balance automatically transferred to the balance of treasure how to set off, cancel Alipay balance automatically transferred to balance treasure?
- 动态代理ip的测试步骤有哪些?
- mb_ substr()、mb_ Strpos() function (story)
- 哪些代码需要做单元测试?
- LSF的常用使用命令总结
- How to initialize "naming and surname" in C language
- How to classify proxy IP?
- 腾讯云接口进行人脸检测 和签名出错问题
- CDR2022首发全新版本性能介绍
- Virtual serial port function of j-link V9 using skills
猜你喜欢
W801 / w800 WiFi socket development (II) - UDP Bluetooth control WiFi connection
When should I write unit tests? What is TDD?
Performance introduction of the first new version of cdr2022
Encrypted compressed backup bat script
2022 melting welding and thermal cutting operation certificate examination question simulation examination platform operation
揭秘被Arm编译器所隐藏的浮点运算
在使用代理IP前需要了解哪些分类?
Challenges often faced by client project management
What is a dial-up server and what is its use?
How to "gracefully" measure system performance
随机推荐
Communication summary between MCU and 4G module (EC20)
Server 2019 the available memory of the server is half of the actual memory
Use of j-link RTT
Glide set fillet image (support custom fillet position)
Encrypted compressed backup bat script
紫光国微财报一枝独秀 2021年净利润三位数增长靠什么
浅析一下隧道代理IP的优缺点。
mb_ substr()、mb_ Strpos() function (story)
How to install mysql-5.7.9 in RPM mode under Linux system
领导/老师让填写电子excel表格文档可手机上如何编辑word/excel文件填写excel/word电子文档?
Digital collection platform settled in digital collection platform to develop SaaS platform of digital collection
动态代理ip的测试步骤有哪些?
如何“优雅”的测量系统性能
How can e-procurement become a value-added function in the supply chain?
Learning methods and career development guide (2022 Edition)
What are the common proxy IP problems?
电子采购如何成为供应链中的增值功能?
Jerry's CPU performance test [chapter]
The leader / teacher asks to fill in the EXCEL form document. How to edit the word / Excel file on the mobile phone and fill in the Excel / word electronic document?
2022 low voltage electrician examination questions and answers