Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Document how jobs are filtered. #3

Open
berkes opened this issue May 19, 2022 · 0 comments
Open

Document how jobs are filtered. #3

berkes opened this issue May 19, 2022 · 0 comments

Comments

@berkes
Copy link
Contributor

berkes commented May 19, 2022

From https://fosstodon.org/web/@flockingbird/108328191983805661

@humanetech I'll document this and will link to it.
Currently is simply uses a fixed list of hastags. Which are job related. And a fixed list that filters results too. Nothing fancy.
As the sidebar mentions, just use a hash-vacancy hashtag to denote job postings.
But I'll spend some time writing this for a help page. Good suggestion,thanks

In code, this is:


fn job_tags() -> Vec<String> {
    vec![
        "job".to_string(),
        "jobs".to_string(),
        "jobsearch".to_string(),
        "joboffer".to_string(),
        "hiring".to_string(),
        "vacancy".to_string(),
        "offredemploi".to_string(),
        "emploi".to_string(),
        "jobangebot".to_string(),
    ]
}

fn has_job_related_tags(tags: &[elefren::entities::status::Tag]) -> bool {
    !tags.is_empty()
        && tags
            .iter()
            .map(|t| t.name.to_owned())
            .any(|e| job_tags().contains(&e))
}

Tests:

    #[test]
    fn test_has_job_related_tags_with_jobs_tag() {
        let tags = vec![Tag {
            url: "".to_string(),
            name: "jobs".to_string(),
        }];
        assert!(has_job_related_tags(&tags))
    }

    #[test]
    fn test_has_job_related_tags_with_multiple_tags() {
        let tags = vec![
            Tag {
                url: "".to_string(),
                name: "jobs".to_string(),
            },
            Tag {
                url: "".to_string(),
                name: "steve".to_string(),
            },
        ];
        assert!(has_job_related_tags(&tags))
    }

    #[test]
    fn test_has_no_job_related_tags_without_tags() {
        let tags = vec![];
        assert!(!has_job_related_tags(&tags))
    }

    #[test]
    fn test_has_no_job_related_tags_without_allowed_tags() {
        let tags = vec![Tag {
            url: "".to_string(),
            name: "steve".to_string(),
        }];
        assert!(!has_job_related_tags(&tags))
    }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant