Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endpoint to retrieve the last uploaded CVs #95 #155

Merged
merged 7 commits into from
Feb 15, 2021
Merged

Conversation

CharlesKimMaina
Copy link
Collaborator

@CharlesKimMaina CharlesKimMaina commented Feb 11, 2021

Title : Endpoint to retrieve the last uploaded CVs #95

One can retrieve from the DB a list the 3 last upload CVs or All the whole list (limit to 20), so that you can view them on Frontend.

Fixes # #95

How to test?

On frontend, you can see the 3 last uploaded CVs as below;
last3uploadedCvs

On backend Testing,., I joined users and cv tables, I created new usercv router and usercv controller. I also limit the cvs numbers to be fetched from backend to max 20 cvs. see joined table below;
users+cvs_JOINED_tables

Checklist

  • [*] I have performed a self-review of my own code
  • [*] I have commented my code, particularly in hard-to-understand areas
  • [*] I have made corresponding changes to the documentation
  • [*] This PR is ready to be merged and not breaking any other functionality

@CharlesKimMaina CharlesKimMaina linked an issue Feb 11, 2021 that may be closed by this pull request
useEffect(() => {
(async () => {
const result = await fetch('/api/usercv').then((res) => res.json());
console.log(result);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove console.logs

setCvs(result);
})();
}, []);
console.log(cvs);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove console.logs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okey, thanks ,.,i will remove all console.logs

import React, { useState, useEffect } from 'react';
import { CardCvViewSearchComponent } from '../CardCvViewSearchComponent/CardCvViewSearchComponent';

export default function RetriveCvs() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export default function RetriveCvs() {
export default function RetrieveCvs() {

console.log(cvs);
return (
<div>
{cvs.slice(-3).map((item) => (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this sliced?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to upload only 3 last uploaded cvs,. The original array will not be modified, but the task requires that we show only 3 latest cvs,.,Thats why i use slice like in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice ,.,.,under parameters

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use conditions instead by using array length and boolean value

@pdsorensen pdsorensen removed their request for review February 12, 2021 08:43
@dpfernandes dpfernandes added this to the Version 1.0 milestone Feb 13, 2021
Copy link
Collaborator

@kamalrsa kamalrsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that .slice (-3) working fine to isplay last 3 cvs

@CharlesKimMaina
Copy link
Collaborator Author

CharlesKimMaina commented Feb 14, 2021

Thanks Mr Kamal

Copy link
Contributor

@dpfernandes dpfernandes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the Frontend changes on this PR.

This PR should be have endpoint code

* @swagger
* /modules:
* get:
* summary: Get all cvs and users
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should say that there is a limit on 20?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, Patrick,.let me change on swagger documentation, Thanks

Copy link
Collaborator

@pdsorensen pdsorensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, only have some minor suggestions.


const knex = require('../../config/db');

const getCvsnUsers = async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think getUserCvs makes more sense.

Copy link
Collaborator Author

@CharlesKimMaina CharlesKimMaina Feb 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, let me change it and push again, thanks,

@pdsorensen pdsorensen dismissed stale reviews from dpfernandes and bytewiz February 15, 2021 21:21

Has been resolved.

@pdsorensen pdsorensen merged commit e003cb5 into develop Feb 15, 2021
@pdsorensen pdsorensen deleted the RetrivingCvs#95 branch February 15, 2021 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Endpoint to retrieve the last uploaded CVs
6 participants