@@ -61,18 +61,18 @@ func (a Article) String() string {
61
61
return "Article(\n title=" + a .title + "\n authors=" + a .authors + "\n scholarURL=" + a .scholarURL + "\n year=" + strconv .Itoa (a .year ) + "\n month=" + strconv .Itoa (a .month ) + "\n day=" + strconv .Itoa (a .day ) + "\n numCitations=" + strconv .Itoa (a .numCitations ) + "\n articles=" + strconv .Itoa (a .articles ) + "\n description=" + a .description + "\n pdfURL=" + a .pdfURL + "\n journal=" + a .journal + "\n volume=" + a .volume + "\n pages=" + a .pages + "\n publisher=" + a .publisher + "\n scholarCitedByURL=" + strings .Join (a .scholarCitedByURLs , ", " ) + "\n scholarVersionsURL=" + strings .Join (a .scholarVersionsURLs , ", " ) + "\n scholarRelatedURL=" + strings .Join (a .scholarRelatedURLs , ", " ) + "\n lastRetrieved=" + a .lastRetrieved .String () + "\n )"
62
62
}
63
63
64
- func (sch Scholar ) QueryProfile (user string ) []Article {
65
- return sch .QueryProfileDumpResponse (user , true , false )
64
+ func (sch Scholar ) QueryProfile (user string , limit int ) []Article {
65
+ return sch .QueryProfileDumpResponse (user , true , limit , false )
66
66
}
67
67
68
- func (sch Scholar ) QueryProfileWithCache (user string ) []Article {
68
+ func (sch Scholar ) QueryProfileWithCache (user string , limit int ) []Article {
69
69
if sch .profile .Has (user ) {
70
70
p , _ := sch .profile .Get (user )
71
71
lastAccess := p .lastRetrieved
72
72
if (time .Now ().Sub (lastAccess )).Seconds () > MAX_TIME_PROFILE .Seconds () {
73
73
println ("Profile cache expired for user: " + user )
74
74
sch .profile .Remove (user )
75
- articles := sch .QueryProfileDumpResponse (user , true , false )
75
+ articles := sch .QueryProfileDumpResponse (user , true , limit , false )
76
76
var articleList []string
77
77
for _ , article := range articles {
78
78
articleList = append (articleList , article .scholarURL )
@@ -107,7 +107,7 @@ func (sch Scholar) QueryProfileWithCache(user string) []Article {
107
107
108
108
} else {
109
109
println ("Profile cache miss for user: " + user )
110
- articles := sch .QueryProfileDumpResponse (user , true , false )
110
+ articles := sch .QueryProfileDumpResponse (user , true , limit , false )
111
111
var articleList []string
112
112
for _ , article := range articles {
113
113
articleList = append (articleList , article .scholarURL )
@@ -127,12 +127,12 @@ func (sch Scholar) QueryProfileWithCache(user string) []Article {
127
127
// want to get updated information from the profile page only to save requests
128
128
//
129
129
// if dumpResponse is true, it will print the response to stdout (useful for debugging)
130
- func (sch Scholar ) QueryProfileDumpResponse (user string , queryArticles bool , dumpResponse bool ) []Article {
130
+ func (sch Scholar ) QueryProfileDumpResponse (user string , queryArticles bool , limit int , dumpResponse bool ) []Article {
131
131
var articles []Article
132
132
client := & http.Client {}
133
133
134
134
// todo: make page size configurable, also support getting more than one page of citations
135
- req , err := http .NewRequest ("GET" , BaseURL + "/citations?user=" + user + "&cstart=0&pagesize=1" , nil )
135
+ req , err := http .NewRequest ("GET" , BaseURL + "/citations?user=" + user + "&cstart=0&pagesize=" + strconv . Itoa ( limit ) , nil )
136
136
if err != nil {
137
137
log .Fatalln (err )
138
138
}
0 commit comments