forked from mrlan/EnglishPal
				
			Refactor: 2 helper functions added in article.py (get_article_by_id and get_all_articles)
							parent
							
								
									d9f6df7fbe
								
							
						
					
					
						commit
						75d43137e0
					
				|  | @ -32,3 +32,16 @@ def get_page_articles(num, size): | |||
|             x | ||||
|             for x in Article.select().order_by(desc(Article.article_id)).page(num, size) | ||||
|         ] | ||||
| 
 | ||||
| 
 | ||||
| def get_article_by_id(article_id): | ||||
|     article_id &= 0xFFFFFFFF  # max 32 bits | ||||
|     with db_session: | ||||
|         article = Article.select(article_id=article_id).first() | ||||
|         if article: | ||||
|             return article.to_dict() | ||||
| 
 | ||||
| 
 | ||||
| def get_all_articles(): | ||||
|     with db_session: | ||||
|         return [art.to_dict() for art in Article.select()[:]] | ||||
		Loading…
	
		Reference in New Issue