Skip to content

Commit

Permalink
Adds filter query fixes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
cw00dw0rd committed Mar 10, 2021
1 parent 5e6d60b commit 51bba69
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"install-react": "cd ./workspaces/frontend-react && npm install --legacy-peer-deps",
"serve": "cd ./workspaces/frontend-vue && npm run serve",
"serve-react": "cd ./workspaces/frontend-react && npm run start",
"serve-backend": "cd ./workspaces/backend && npm run start",
"serve-backend": "cd ./workspaces/backend && npm run dev",
"build": "cd ./workspaces/frontend-vue && npm run build",
"lint": "cd ./workspaces/frontend-vue && npm run lint"
},
Expand Down
16 changes: 16 additions & 0 deletions workspaces/backend/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ ApiRouter.post("/api/mapResults", async (ctx) => {
sendResponse(ctx, result);
})

ApiRouter.get("/api/filters", async (ctx) => {
const result = [];
const cursor = await ctx.db.query(aql`
FOR doc in arangobnb
FOR amenity in doc.amenities
COLLECT item = amenity with COUNT into c
SORT c DESC
LIMIT 20
RETURN item
`);
for await (const c of cursor){
result.push(c);
}
sendResponse(ctx, result);
})

ApiRouter.all("(.*)", async (ctx) => {
sendResponse(ctx, { text: "Nothing to see here" }, 404);
})
Expand Down
23 changes: 21 additions & 2 deletions workspaces/frontend-vue/src/store/modules/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const state = () => ({
mapArea: [[13.3733650830416,52.513472114606735],[13.380215444865636,52.513472114606735],[13.387065806689671,52.513472114606735],[13.387065806689671,52.51550916176831],[13.387065806689671,52.51754620892988],[13.380215444865636,52.51754620892988],[13.3733650830416,52.51754620892988],[13.3733650830416,52.51550916176831],[13.3733650830416,52.513472114606735]],
listings: [],
markers:[],
mapPosition: {}
mapPosition: {},
filters: []
});

// getters
Expand Down Expand Up @@ -55,6 +56,17 @@ const actions = {
} catch (e) {
console.log(e)
}
},
getFilters: ({commit}) => {
let config = {
method: 'get',
url: API + '/api/filters'
};
axios(config)
.then( (response) => {
console.log(response.data)
commit("setFilters", { filters: response.data });
})
}
};

Expand Down Expand Up @@ -83,7 +95,14 @@ const mutations = {
try {
Vue.set(state, 'mapPosition', position.destination);
} catch (e) {
console.log(e)
console.log(e);
}
},
setFilters(state, filters) {
try {
Vue.set(state, 'filters', filters);
} catch(e) {
console.log(e);
}
}
};
Expand Down

0 comments on commit 51bba69

Please sign in to comment.