bigcalendar引入github-following

/ 默认分类 / 0 条评论 / 2188浏览

目标

bigcalendar首页点击github登陆,日历便可获取所有该user的following的项目进展

实现

编写github-api请求工具 项目地址:githubApiTools 如需引入,添加maven依赖

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

<dependency>
    <groupId>com.github.s-lion-h</groupId>
    <artifactId>githubApiTools</artifactId>
</dependency>

工具实现方法

List<Repository> getFollowingRepo(String username);
List<Owner> getFollowingList(String username);
List<Repository> getRepositoryLists(String username);

bigcalendar请求过程

index->请求github-OAuth->controller获取OAuth请求结果,唯一标识id和身份资料->入库

对github认证的user不需要登陆

service请求git的following api->Repositery List服务器渲染index

##怎么渲染呢,是个大问题,做不好服务器资源消耗巨大

2018.07.12 think1.

以每日为单位,检索model是否含有对应日期

Thymeleaf后台渲染,

结果计算资源开销巨大

每个api返回数据量超过5kb

一个user关注10个人,10个人每个人有20个仓库

总计调用api1+10=11次,api请求完时间高达12秒,此处不足将在GithubUtil下一个版本中改进api请求为多线程请求式

总计单个首页遍历30天*200Reposity实体=6000次

在10个user同时请求时将导致CPU工作量巨大

同时calendarTable的thymeleaf页面过于臃肿

要改要改,还有很多地方要优化

##急需调整


gitapi每小时请求数量60,需申请token添加到5000一小时 gitapi请求过慢,需要在following请求repositories时改为可选择的多线程 已请求的user的following数据不应该重复获取,应创建redis储存一定时间