mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Made Split to Nearby Query into a fast query for coordinates + a details query for each pin (#5731)
* Splitted the query * Made changes to the query * Improvised query * Improvised query by dividing in the batches * Fixed failing tests * Improved batches * Improved sorting * Fixes issue caused by search this area button * Fixed failing tests * Fixed unnecessary reloads on onResume * Fixed few pins not loading on changing apps * Improved zoom level and fixed the pins not loading from the center * Removed toggle chips and changed pin's color * Fixed wikidata url * Fixed unit tests * Implemented retry with delay of 5000ms * Fixed exception issue and pins issue * Added change color icon to pin * Improved pin clicking * Removed search this area button * Implemented caching of places * Fixed unit test * Factorized methods * Changed primary key from location to entity id * Fixed tests * Fixed conflicts * Fixed unit test * Fixed unit test * Fixed the bug * Fixed issue with pin loading on the first launch * Updated javadocs * Temporary commit - only for testing * Replaced Temporary commit * Temporary commit - Added jcenter * Made minor changes * Fixed unit tests * Fixed unit tests * Fixed minor bug
This commit is contained in:
parent
ba6c8fe8d0
commit
2d63f351ed
39 changed files with 1147 additions and 814 deletions
64
app/src/main/resources/queries/query_for_item.rq
Normal file
64
app/src/main/resources/queries/query_for_item.rq
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
SELECT
|
||||
?item
|
||||
(SAMPLE(?label) AS ?label)
|
||||
(SAMPLE(?class) AS ?class)
|
||||
(SAMPLE(?description) AS ?description)
|
||||
(SAMPLE(?classLabel) AS ?classLabel)
|
||||
(SAMPLE(?pic) AS ?pic)
|
||||
(SAMPLE(?destroyed) AS ?destroyed)
|
||||
(SAMPLE(?endTime) AS ?endTime)
|
||||
(SAMPLE(?wikipediaArticle) AS ?wikipediaArticle)
|
||||
(SAMPLE(?commonsArticle) AS ?commonsArticle)
|
||||
(SAMPLE(?commonsCategory) AS ?commonsCategory)
|
||||
WHERE {
|
||||
SERVICE <https://query.wikidata.org/sparql> {
|
||||
values ?item {
|
||||
${ENTITY}
|
||||
}
|
||||
}
|
||||
|
||||
# Get the label in the preferred language of the user, or any other language if no label is available in that language.
|
||||
OPTIONAL {?item rdfs:label ?itemLabelPreferredLanguage. FILTER (lang(?itemLabelPreferredLanguage) = "en")}
|
||||
OPTIONAL {?item rdfs:label ?itemLabelAnyLanguage}
|
||||
BIND(COALESCE(?itemLabelPreferredLanguage, ?itemLabelAnyLanguage, "?") as ?label)
|
||||
|
||||
# Get the description in the preferred language of the user, or any other language if no description is available in that language.
|
||||
OPTIONAL {?item schema:description ?itemDescriptionPreferredLanguage. FILTER (lang(?itemDescriptionPreferredLanguage) = "${LANG}")}
|
||||
OPTIONAL {?item schema:description ?itemDescriptionAnyLanguage}
|
||||
BIND(COALESCE(?itemDescriptionPreferredLanguage, ?itemDescriptionAnyLanguage, "?") as ?description)
|
||||
|
||||
# Get the class label in the preferred language of the user, or any other language if no label is available in that language.
|
||||
OPTIONAL {
|
||||
?item p:P31/ps:P31 ?class.
|
||||
OPTIONAL {?class rdfs:label ?classLabelPreferredLanguage. FILTER (lang(?classLabelPreferredLanguage) = "${LANG}")}
|
||||
OPTIONAL {?class rdfs:label ?classLabelAnyLanguage}
|
||||
BIND(COALESCE(?classLabelPreferredLanguage, ?classLabelAnyLanguage, "?") as ?classLabel)
|
||||
}
|
||||
|
||||
OPTIONAL {
|
||||
?item p:P31/ps:P31 ?class.
|
||||
}
|
||||
|
||||
# Get picture
|
||||
OPTIONAL {?item wdt:P18 ?pic}
|
||||
|
||||
# Get existence
|
||||
OPTIONAL {?item wdt:P576 ?destroyed}
|
||||
OPTIONAL {?item wdt:P582 ?endTime}
|
||||
|
||||
# Get Commons category
|
||||
OPTIONAL {?item wdt:P373 ?commonsCategory}
|
||||
|
||||
# Get Wikipedia article
|
||||
OPTIONAL {
|
||||
?wikipediaArticle schema:about ?item.
|
||||
?wikipediaArticle schema:isPartOf <https://en.wikipedia.org/>. # TODO internationalization
|
||||
}
|
||||
|
||||
# Get Commons article
|
||||
OPTIONAL {
|
||||
?commonsArticle schema:about ?item.
|
||||
?commonsArticle schema:isPartOf <https://commons.wikimedia.org/>.
|
||||
}
|
||||
}
|
||||
GROUP BY ?item
|
||||
|
|
@ -1,16 +1,6 @@
|
|||
SELECT
|
||||
?item
|
||||
(SAMPLE(?location) as ?location)
|
||||
(SAMPLE(?label) AS ?label)
|
||||
(SAMPLE(?description) AS ?description)
|
||||
(SAMPLE(?class) AS ?class)
|
||||
(SAMPLE(?classLabel) AS ?classLabel)
|
||||
(SAMPLE(?pic) AS ?pic)
|
||||
(SAMPLE(?destroyed) AS ?destroyed)
|
||||
(SAMPLE(?endTime) AS ?endTime)
|
||||
(SAMPLE(?wikipediaArticle) AS ?wikipediaArticle)
|
||||
(SAMPLE(?commonsArticle) AS ?commonsArticle)
|
||||
(SAMPLE(?commonsCategory) AS ?commonsCategory)
|
||||
WHERE {
|
||||
# Around given location
|
||||
SERVICE wikibase:box {
|
||||
|
|
@ -19,38 +9,5 @@ WHERE {
|
|||
bd:serviceParam wikibase:cornerEast "Point(${LONG_EAST} ${LAT_EAST})"^^geo:wktLiteral.
|
||||
}
|
||||
|
||||
OPTIONAL {
|
||||
?item p:P31/ps:P31 ?class.
|
||||
}
|
||||
|
||||
# Get picture
|
||||
OPTIONAL {?item wdt:P18 ?pic}
|
||||
|
||||
# Get existence
|
||||
OPTIONAL {?item wdt:P576 ?destroyed}
|
||||
OPTIONAL {?item wdt:P582 ?endTime}
|
||||
|
||||
# Get Commons category
|
||||
OPTIONAL {?item wdt:P373 ?commonsCategory}
|
||||
|
||||
# Get Wikipedia article
|
||||
OPTIONAL {
|
||||
?wikipediaArticle schema:about ?item.
|
||||
?wikipediaArticle schema:isPartOf <https://${LANG}.wikipedia.org/>.
|
||||
}
|
||||
|
||||
# Get Commons article
|
||||
OPTIONAL {
|
||||
?commonsArticle schema:about ?item.
|
||||
?commonsArticle schema:isPartOf <https://commons.wikimedia.org/>.
|
||||
}
|
||||
|
||||
# Labels and descriptions
|
||||
SERVICE wikibase:label {
|
||||
bd:serviceParam wikibase:language "${LANG},en,fr,de,es,ja,ru,it,zh,pt,ar,fa,pl,nl,id,uk,he,sv,cs,ko,vi,ca,no,fi,hu,tr,th,hi,bn,ceb,ro,sw,kk,da,eo,sr,lt,sk,bg,sl,eu,et,hr,ms,el,arz,ur,ta,te,nn,gl,az,af,bs,be,ml,ka,is,sq,uz,la,br,mk,lv,azb,mr,sh,tl,cy,ckb,ast,be-tarask,zh-yue,hy,pa,as,my,kn,ne,si,tt,ha,war,zh-min-nan,vo,min,lmo,ht,lb,gu,tg,sco,ku,new,bpy,nds,io,pms,su,oc,jv,nap,ba,scn,wa,bar,an,ksh,szl,fy,frr,als,ia,ga,yi,mg,gd,vec,ce,sa,mai,xmf,sd,wuu,mrj,mhr,km,roa-tara,am,roa-rup,map-bms,bh,mnw,shn,bcl,co,cv,dv,nds-nl,fo,hif,fur,gan,glk,hak,ilo,pam,csb,avk,lij,li,gv,mi,mt,nah,nrm,se,nov,qu,os,pi,pag,ps,pdc,rm,bat-smg,sc,to,tk,hsb,fiu-vro,vls,yo,diq,zh-classical,frp,lad,kw,mn,haw,ang,ln,ie,wo,tpi,ty,crh,nv,jbo,ay,pcd,zea,eml,ky,ig,or,cbk-zam,kg,arc,rmy,ab,gn,so,kab,ug,stq,udm,ext,mzn,pap,cu,sah,tet,sn,lo,pnb,iu,na,got,bo,dsb,chr,cdo,om,sm,ee,ti,av,bm,zu,pnt,cr,pih,ss,ve,bi,rw,ch,xh,kl,ik,bug,dz,ts,tn,kv,tum,xal,st,tw,bxr,ak,ny,fj,lbe,za,ks,ff,lg,sg,rn,chy,mwl,lez,bjn,gom,tyv,vep,nso,kbd,ltg,rue,pfl,gag,koi,krc,ace,olo,kaa,mdf,myv,srn,ady,jam,tcy,dty,atj,kbp,din,lfn,gor,inh,sat,hyw,nqo,ban,szy,awa,ary,lld,smn,skr,mad,dag,shi,nia,ki,gcr".
|
||||
?item rdfs:label ?label.
|
||||
?item schema:description ?description.
|
||||
?class rdfs:label ?classLabel.
|
||||
}
|
||||
}
|
||||
GROUP BY ?item
|
||||
|
|
@ -1,16 +1,6 @@
|
|||
SELECT
|
||||
?item
|
||||
(SAMPLE(?location) as ?location)
|
||||
(SAMPLE(?label) AS ?label)
|
||||
(SAMPLE(?description) AS ?description)
|
||||
(SAMPLE(?class) AS ?class)
|
||||
(SAMPLE(?classLabel) AS ?classLabel)
|
||||
(SAMPLE(?pic) AS ?pic)
|
||||
(SAMPLE(?destroyed) AS ?destroyed)
|
||||
(SAMPLE(?endTime) AS ?endTime)
|
||||
(SAMPLE(?wikipediaArticle) AS ?wikipediaArticle)
|
||||
(SAMPLE(?commonsArticle) AS ?commonsArticle)
|
||||
(SAMPLE(?commonsCategory) AS ?commonsCategory)
|
||||
(SAMPLE(?monument) AS ?monument)
|
||||
WHERE {
|
||||
# Around given location
|
||||
|
|
@ -20,32 +10,6 @@ WHERE {
|
|||
bd:serviceParam wikibase:cornerEast "Point(${LONG_EAST} ${LAT_EAST})"^^geo:wktLiteral.
|
||||
}
|
||||
|
||||
OPTIONAL {
|
||||
?item p:P31/ps:P31 ?class.
|
||||
}
|
||||
|
||||
# Get picture
|
||||
OPTIONAL {?item wdt:P18 ?pic}
|
||||
|
||||
# Get existence
|
||||
OPTIONAL {?item wdt:P576 ?destroyed}
|
||||
OPTIONAL {?item wdt:P582 ?endTime}
|
||||
|
||||
# Get Commons category
|
||||
OPTIONAL {?item wdt:P373 ?commonsCategory}
|
||||
|
||||
# Get Wikipedia article
|
||||
OPTIONAL {
|
||||
?wikipediaArticle schema:about ?item.
|
||||
?wikipediaArticle schema:isPartOf <https://${LANG}.wikipedia.org/>.
|
||||
}
|
||||
|
||||
# Get Commons article
|
||||
OPTIONAL {
|
||||
?commonsArticle schema:about ?item.
|
||||
?commonsArticle schema:isPartOf <https://commons.wikimedia.org/>.
|
||||
}
|
||||
|
||||
# Wiki Loves Monuments
|
||||
OPTIONAL {?item p:P1435 ?monument}
|
||||
OPTIONAL {?item p:P2186 ?monument}
|
||||
|
|
@ -57,12 +21,5 @@ WHERE {
|
|||
OPTIONAL {?item p:P5694 ?monument}
|
||||
OPTIONAL {?item p:P3426 ?monument}
|
||||
|
||||
# Labels and descriptions
|
||||
SERVICE wikibase:label {
|
||||
bd:serviceParam wikibase:language "${LANG},en,fr,de,es,ja,ru,it,zh,pt,ar,fa,pl,nl,id,uk,he,sv,cs,ko,vi,ca,no,fi,hu,tr,th,hi,bn,ceb,ro,sw,kk,da,eo,sr,lt,sk,bg,sl,eu,et,hr,ms,el,arz,ur,ta,te,nn,gl,az,af,bs,be,ml,ka,is,sq,uz,la,br,mk,lv,azb,mr,sh,tl,cy,ckb,ast,be-tarask,zh-yue,hy,pa,as,my,kn,ne,si,tt,ha,war,zh-min-nan,vo,min,lmo,ht,lb,gu,tg,sco,ku,new,bpy,nds,io,pms,su,oc,jv,nap,ba,scn,wa,bar,an,ksh,szl,fy,frr,als,ia,ga,yi,mg,gd,vec,ce,sa,mai,xmf,sd,wuu,mrj,mhr,km,roa-tara,am,roa-rup,map-bms,bh,mnw,shn,bcl,co,cv,dv,nds-nl,fo,hif,fur,gan,glk,hak,ilo,pam,csb,avk,lij,li,gv,mi,mt,nah,nrm,se,nov,qu,os,pi,pag,ps,pdc,rm,bat-smg,sc,to,tk,hsb,fiu-vro,vls,yo,diq,zh-classical,frp,lad,kw,mn,haw,ang,ln,ie,wo,tpi,ty,crh,nv,jbo,ay,pcd,zea,eml,ky,ig,or,cbk-zam,kg,arc,rmy,ab,gn,so,kab,ug,stq,udm,ext,mzn,pap,cu,sah,tet,sn,lo,pnb,iu,na,got,bo,dsb,chr,cdo,om,sm,ee,ti,av,bm,zu,pnt,cr,pih,ss,ve,bi,rw,ch,xh,kl,ik,bug,dz,ts,tn,kv,tum,xal,st,tw,bxr,ak,ny,fj,lbe,za,ks,ff,lg,sg,rn,chy,mwl,lez,bjn,gom,tyv,vep,nso,kbd,ltg,rue,pfl,gag,koi,krc,ace,olo,kaa,mdf,myv,srn,ady,jam,tcy,dty,atj,kbp,din,lfn,gor,inh,sat,hyw,nqo,ban,szy,awa,ary,lld,smn,skr,mad,dag,shi,nia,ki,gcr".
|
||||
?item rdfs:label ?label.
|
||||
?item schema:description ?description.
|
||||
?class rdfs:label ?classLabel.
|
||||
}
|
||||
}
|
||||
GROUP BY ?item
|
||||
Loading…
Add table
Add a link
Reference in a new issue