当前位置:网站首页>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
边栏推荐
- 2022.4.22-----leetcode.396
- How to classify proxy IP?
- Under the pressure of sales, domestic mobile phones began to reduce prices, but they haven't put down their final face
- How to "gracefully" measure system performance
- MySQL basic record
- Leetcode-阶乘函数后 K 个零
- 有哪些业务会用到物理服务器?
- Encrypted compressed backup bat script
- Problem solving: dpkg DEB: error: package name has characters that are't lowercase alphanums or '- +‘
- 单片机和4G模块通信总结(EC20)
猜你喜欢

有哪些常见的代理ip问题?

拨号vps会遇到什么问题?

教程】如何用GCC“零汇编”白嫖MDK

Cc2541 emulator CC debugger tutorial

DO447管理用户和团队的访问

代理IP可用率是不是等同于代理IP的效率?

2022 crane driver (limited to bridge crane) examination question bank and online simulation examination

What is a dial-up server and what is its use?

Shardingsphere sub database and sub table

Performance introduction of the first new version of cdr2022
随机推荐
Ziguang micro financial report is outstanding. What does the triple digit growth of net profit in 2021 depend on
最长公共子序列(记录路径版)
What problems will you encounter when dialing VPS?
W801/W800-wifi-socket开发(二)-UDP蓝牙控制wifi连接
MySQL active / standby configuration binary log problem
Question bank and online simulation examination for safety management personnel of hazardous chemical business units in 2022
d盘分给C盘后,数据库恢复挂起怎么办,求各位解答
Sqlserver data transfer to MySQL
JSP basic knowledge summary
ESP32蓝牙Bluetooth Controller API介绍
Chapter 6 uses Matplotlib to draw thermodynamic diagram
中金财富是国企吗,开户安全吗
Jerry's AI server [chapter]
2022第六季完美童模 IPA國民賽領跑元宇宙賽道
如何对代理IP进行分类?
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?
About how to import C4d animation into lumion
Technology cloud report: cloud computing has entered the "second half". Where is the way out for domestic cloud?
Digital collection platform settled in digital collection platform to develop SaaS platform of digital collection
BGP服务器在什么业务场景会被用到?