Compare commits

...

2 Commits

Author SHA1 Message Date
Lucas Verney 3b9cf0917a Lint 2021-04-28 20:11:37 +02:00
Lucas Verney 7fc9077520 Fix SeLoger pagination 2021-04-28 20:10:27 +02:00
2 changed files with 39 additions and 36 deletions

View File

@ -9,80 +9,80 @@ export default {
isLoading: (state) => state.loading > 0, isLoading: (state) => state.loading > 0,
inseeCodesFlatsBuckets: (state, getters) => (filter) => { inseeCodesFlatsBuckets: (state, getters) => (filter) => {
const buckets = {}; const buckets = {}
state.flats.forEach((flat) => { state.flats.forEach((flat) => {
if (!filter || filter(flat)) { if (!filter || filter(flat)) {
const insee = flat.flatisfy_postal_code.insee_code; const insee = flat.flatisfy_postal_code.insee_code
if (!buckets[insee]) { if (!buckets[insee]) {
buckets[insee] = { buckets[insee] = {
name: flat.flatisfy_postal_code.name, name: flat.flatisfy_postal_code.name,
flats: [], flats: []
}; }
} }
buckets[insee].flats.push(flat); buckets[insee].flats.push(flat)
} }
}); })
return buckets; return buckets
}, },
flatsMarkers: (state, getters) => (router, filter) => { flatsMarkers: (state, getters) => (router, filter) => {
const markers = []; const markers = []
state.flats.forEach((flat) => { state.flats.forEach((flat) => {
if (filter && filter(flat)) { if (filter && filter(flat)) {
const gps = findFlatGPS(flat); const gps = findFlatGPS(flat)
if (gps) { if (gps) {
const previousMarker = markers.find( const previousMarker = markers.find(
(marker) => (marker) =>
marker.gps[0] === gps[0] && marker.gps[1] === gps[1] marker.gps[0] === gps[0] && marker.gps[1] === gps[1]
); )
if (previousMarker) { if (previousMarker) {
// randomize position a bit // randomize position a bit
// gps[0] += (Math.random() - 0.5) / 500 // gps[0] += (Math.random() - 0.5) / 500
// gps[1] += (Math.random() - 0.5) / 500 // gps[1] += (Math.random() - 0.5) / 500
} }
const href = router.resolve({ const href = router.resolve({
name: "details", name: 'details',
params: { id: flat.id }, params: { id: flat.id }
}).href; }).href
const cost = flat.cost const cost = flat.cost
? costFilter(flat.cost, flat.currency) ? costFilter(flat.cost, flat.currency)
: ""; : ''
markers.push({ markers.push({
title: "", title: '',
content: content:
'<a href="' + '<a href="' +
href + href +
'">' + '">' +
flat.title + flat.title +
"</a>" + '</a>' +
cost, cost,
gps: gps, gps: gps,
flatId: flat.id, flatId: flat.id
}); })
} }
} }
}); })
return markers; return markers
}, },
allTimeToPlaces: (state) => { allTimeToPlaces: (state) => {
const places = {}; const places = {}
Object.keys(state.timeToPlaces).forEach((constraint) => { Object.keys(state.timeToPlaces).forEach((constraint) => {
const constraintTimeToPlaces = state.timeToPlaces[constraint]; const constraintTimeToPlaces = state.timeToPlaces[constraint]
Object.keys(constraintTimeToPlaces).forEach((name) => { Object.keys(constraintTimeToPlaces).forEach((name) => {
places[name] = constraintTimeToPlaces[name]; places[name] = constraintTimeToPlaces[name]
}); })
}); })
return places; return places
}, },
timeToPlaces: (state, getters) => (constraintName) => { timeToPlaces: (state, getters) => (constraintName) => {
return state.timeToPlaces[constraintName]; return state.timeToPlaces[constraintName]
}, },
metadata: (state) => state.metadata, metadata: (state) => state.metadata
}; }

View File

@ -72,7 +72,7 @@ class SearchResultsPage(HTMLPage):
def next_page(self): def next_page(self):
page_nb = Dict('navigation/pagination/page')(self) page_nb = Dict('navigation/pagination/page')(self)
max_results = Dict('navigation/pagination/maxResults')(self) max_results = Dict('navigation/counts/count')(self)
results_per_page = Dict('navigation/pagination/resultsPerPage')(self) results_per_page = Dict('navigation/pagination/resultsPerPage')(self)
if int(max_results) / int(results_per_page) > int(page_nb): if int(max_results) / int(results_per_page) > int(page_nb):
@ -85,7 +85,7 @@ class SearchResultsPage(HTMLPage):
def condition(self): def condition(self):
return ( return (
Dict('cardType')(self) not in ['advertising', 'localExpert'] Dict('cardType')(self) not in ['advertising', 'ali', 'localExpert']
and Dict('id', default=False)(self) and Dict('id', default=False)(self)
and Dict('classifiedURL', default=False)(self) and Dict('classifiedURL', default=False)(self)
) )
@ -171,11 +171,14 @@ class HousingPage(HTMLPage):
def obj_type(self): def obj_type(self):
idType = Dict('idTransactionType')(self) idType = Dict('idTransactionType')(self)
type = next(k for k, v in TYPES.items() if v == idType) try:
if type == POSTS_TYPES.FURNISHED_RENT: type = next(k for k, v in TYPES.items() if v == idType)
# SeLoger does not let us discriminate between furnished and not furnished. if type == POSTS_TYPES.FURNISHED_RENT:
return POSTS_TYPES.RENT # SeLoger does not let us discriminate between furnished and not furnished.
return type return POSTS_TYPES.RENT
return type
except StopIteration:
return NotAvailable
def obj_advert_type(self): def obj_advert_type(self):
if 'Agences' in self.agency_doc['type']: if 'Agences' in self.agency_doc['type']: