1
This commit is contained in:
		
							parent
							
								
									2b15e68017
								
							
						
					
					
						commit
						3bb3bf5e3a
					
				@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization;
 | 
				
			|||||||
using Microsoft.AspNetCore.Identity;
 | 
					using Microsoft.AspNetCore.Identity;
 | 
				
			||||||
using Microsoft.AspNetCore.Mvc;
 | 
					using Microsoft.AspNetCore.Mvc;
 | 
				
			||||||
using Microsoft.EntityFrameworkCore;
 | 
					using Microsoft.EntityFrameworkCore;
 | 
				
			||||||
 | 
					using Newtonsoft.Json;
 | 
				
			||||||
using System.Buffers.Text;
 | 
					using System.Buffers.Text;
 | 
				
			||||||
using System.Data;
 | 
					using System.Data;
 | 
				
			||||||
using System.Security.Claims;
 | 
					using System.Security.Claims;
 | 
				
			||||||
@ -190,9 +191,16 @@ namespace asg_form.Controllers
 | 
				
			|||||||
            public string username { get; set; }
 | 
					            public string username { get; set; }
 | 
				
			||||||
            public string joinTime { get; set; }
 | 
					            public string joinTime { get; set; }
 | 
				
			||||||
            public string base64 { get; set; }
 | 
					            public string base64 { get; set; }
 | 
				
			||||||
 | 
					            public int joinCount { get; set; }
 | 
				
			||||||
            public int count { get; set; }
 | 
					            public int count { get; set; }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public class Item
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public int id { get; set; }
 | 
				
			||||||
 | 
					            public string chinaname { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 解说排行榜
 | 
					        /// 解说排行榜
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
@ -204,23 +212,44 @@ namespace asg_form.Controllers
 | 
				
			|||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                DateTime currentTime = DateTime.Now;
 | 
					                DateTime currentTime = DateTime.Now;
 | 
				
			||||||
 | 
					                Dictionary<string, int> comCount = new Dictionary<string, int>();
 | 
				
			||||||
 | 
					                comCount.Add("默认",0);
 | 
				
			||||||
 | 
					                TestDbContext db = new TestDbContext();
 | 
				
			||||||
 | 
					                var gameAll = db.team_Games.Select(g => g.commentary).ToList();
 | 
				
			||||||
 | 
					                foreach (var game in gameAll)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (game == null) continue;
 | 
				
			||||||
 | 
					                    List<Item> items = JsonConvert.DeserializeObject<List<Item>>(game);
 | 
				
			||||||
 | 
					                    foreach (var item in items)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (comCount.ContainsKey(item.chinaname))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            comCount.Add(item.chinaname, 1);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            comCount[item.chinaname] += 1;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                var rankings = userManager.Users
 | 
					                var rankings = userManager.Users
 | 
				
			||||||
                        .Where(u => u.joinTime != null && u.officium == "Commentator")
 | 
					                        .Where(u => u.joinTime != null && u.officium == "Commentator")
 | 
				
			||||||
                        .AsEnumerable()
 | 
					                        .AsEnumerable()
 | 
				
			||||||
                    .OrderByDescending(u => (currentTime - u.joinTime.ToDateTime()).TotalSeconds)
 | 
					 | 
				
			||||||
                    .Skip((page - 1) * limit)
 | 
					 | 
				
			||||||
                    .Take(limit)
 | 
					 | 
				
			||||||
                        .Select(u => new userRanking
 | 
					                        .Select(u => new userRanking
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            userId = u.Id,
 | 
					                            userId = u.Id,
 | 
				
			||||||
                            username = u.chinaname,
 | 
					                            username = u.chinaname,
 | 
				
			||||||
                            joinTime = u.joinTime,
 | 
					                            joinTime = u.joinTime,
 | 
				
			||||||
                            base64 = u.UserBase64,
 | 
					                            base64 = u.UserBase64,
 | 
				
			||||||
                        //count = (int)((currentTime - u.joinTime.ToDateTime()).TotalSeconds/ 86400),
 | 
					                            joinCount = (int)((currentTime - u.joinTime.ToDateTime()).TotalSeconds / 86400),
 | 
				
			||||||
 | 
					                            count = comCount[u.chinaname == null ? "默认" : u.chinaname]
 | 
				
			||||||
                        })
 | 
					                        })
 | 
				
			||||||
 | 
					                        .OrderByDescending(u => u.count)
 | 
				
			||||||
 | 
					                        .Skip((page - 1) * limit)
 | 
				
			||||||
 | 
					                        .Take(limit)
 | 
				
			||||||
                        .ToList();
 | 
					                        .ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return Ok(new { code = 200, message = "", rankings });
 | 
					                return Ok(new { code = 200, message = "", rankings });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            catch (Exception ex)
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user