Merge pull request #1119 from nymkappa/feature/order-statistics-by-added
statistics: `ORDER BY id` => `ORDER BY added`
This commit is contained in:
		
						commit
						9b6d679739
					
				@ -314,7 +314,7 @@ class Statistics {
 | 
				
			|||||||
      FROM statistics \
 | 
					      FROM statistics \
 | 
				
			||||||
      WHERE added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() \
 | 
					      WHERE added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() \
 | 
				
			||||||
      GROUP BY UNIX_TIMESTAMP(added) DIV ${div} \
 | 
					      GROUP BY UNIX_TIMESTAMP(added) DIV ${div} \
 | 
				
			||||||
      ORDER BY id DESC;`;
 | 
					      ORDER BY added DESC;`;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private getQueryForDays(div: number, interval: string) {
 | 
					  private getQueryForDays(div: number, interval: string) {
 | 
				
			||||||
@ -362,7 +362,7 @@ class Statistics {
 | 
				
			|||||||
      FROM statistics \
 | 
					      FROM statistics \
 | 
				
			||||||
      WHERE added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() \
 | 
					      WHERE added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() \
 | 
				
			||||||
      GROUP BY UNIX_TIMESTAMP(added) DIV ${div} \
 | 
					      GROUP BY UNIX_TIMESTAMP(added) DIV ${div} \
 | 
				
			||||||
      ORDER BY id DESC;`;
 | 
					      ORDER BY added DESC;`;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public async $get(id: number): Promise<OptimizedStatistic | undefined> {
 | 
					  public async $get(id: number): Promise<OptimizedStatistic | undefined> {
 | 
				
			||||||
@ -382,7 +382,7 @@ class Statistics {
 | 
				
			|||||||
  public async $list2H(): Promise<OptimizedStatistic[]> {
 | 
					  public async $list2H(): Promise<OptimizedStatistic[]> {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      const connection = await DB.pool.getConnection();
 | 
					      const connection = await DB.pool.getConnection();
 | 
				
			||||||
      const query = `SELECT *, UNIX_TIMESTAMP(added) as added FROM statistics ORDER BY id DESC LIMIT 120`;
 | 
					      const query = `SELECT *, UNIX_TIMESTAMP(added) as added FROM statistics ORDER BY added DESC LIMIT 120`;
 | 
				
			||||||
      const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
 | 
					      const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
 | 
				
			||||||
      connection.release();
 | 
					      connection.release();
 | 
				
			||||||
      return this.mapStatisticToOptimizedStatistic(rows);
 | 
					      return this.mapStatisticToOptimizedStatistic(rows);
 | 
				
			||||||
@ -395,7 +395,7 @@ class Statistics {
 | 
				
			|||||||
  public async $list24H(): Promise<OptimizedStatistic[]> {
 | 
					  public async $list24H(): Promise<OptimizedStatistic[]> {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      const connection = await DB.pool.getConnection();
 | 
					      const connection = await DB.pool.getConnection();
 | 
				
			||||||
      const query = `SELECT *, UNIX_TIMESTAMP(added) as added FROM statistics ORDER BY id DESC LIMIT 1440`;
 | 
					      const query = `SELECT *, UNIX_TIMESTAMP(added) as added FROM statistics ORDER BY added DESC LIMIT 1440`;
 | 
				
			||||||
      const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
 | 
					      const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
 | 
				
			||||||
      connection.release();
 | 
					      connection.release();
 | 
				
			||||||
      return this.mapStatisticToOptimizedStatistic(rows);
 | 
					      return this.mapStatisticToOptimizedStatistic(rows);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user