Flockingbird / hunter2

Hunter2 is a job hunt bot that indexes jobs and candidates from the fediverse
https://search.flockingbird.social
MIT License
14 stars 1 forks source link

Document how jobs are filtered. #3

Open berkes opened 2 years ago

berkes commented 2 years ago

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))
    }