Skip to content

Commit ccbeb92

Browse files
authored
Merge pull request #5 from NorwegianVeterinaryInstitute/develop
NVIdb v0.5.2
2 parents be916ab + 62cfb0b commit ccbeb92

19 files changed

+577
-247
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
^\.git$
1515
^\.gitignore$
1616
^\.Rhistory$
17+
^CODE_OF_CONDUCT\.md$

CODE_OF_CONDUCT.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the overall
26+
community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards
42+
of acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies
54+
when an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail
56+
address, posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at [INSERT CONTACT
63+
METHOD]. All complaints will be reviewed and investigated promptly and fairly.
64+
65+
All community leaders are obligated to respect the privacy and security of the
66+
reporter of any incident.
67+
68+
## Enforcement Guidelines
69+
70+
Community leaders will follow these Community Impact Guidelines in determining
71+
the consequences for any action they deem in violation of this Code of Conduct:
72+
73+
### 1. Correction
74+
75+
**Community Impact**: Use of inappropriate language or other behavior deemed
76+
unprofessional or unwelcome in the community.
77+
78+
**Consequence**: A private, written warning from community leaders, providing
79+
clarity around the nature of the violation and an explanation of why the
80+
behavior was inappropriate. A public apology may be requested.
81+
82+
### 2. Warning
83+
84+
**Community Impact**: A violation through a single incident or series of
85+
actions.
86+
87+
**Consequence**: A warning with consequences for continued behavior. No
88+
interaction with the people involved, including unsolicited interaction with
89+
those enforcing the Code of Conduct, for a specified period of time. This
90+
includes avoiding interactions in community spaces as well as external channels
91+
like social media. Violating these terms may lead to a temporary or permanent
92+
ban.
93+
94+
### 3. Temporary Ban
95+
96+
**Community Impact**: A serious violation of community standards, including
97+
sustained inappropriate behavior.
98+
99+
**Consequence**: A temporary ban from any sort of interaction or public
100+
communication with the community for a specified period of time. No public or
101+
private interaction with the people involved, including unsolicited interaction
102+
with those enforcing the Code of Conduct, is allowed during this period.
103+
Violating these terms may lead to a permanent ban.
104+
105+
### 4. Permanent Ban
106+
107+
**Community Impact**: Demonstrating a pattern of violation of community
108+
standards, including sustained inappropriate behavior, harassment of an
109+
individual, or aggression toward or disparagement of classes of individuals.
110+
111+
**Consequence**: A permanent ban from any sort of public interaction within the
112+
community.
113+
114+
## Attribution
115+
116+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
117+
version 2.0,
118+
available at https://www.contributor-covenant.org/version/2/0/
119+
code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at https://
128+
www.contributor-covenant.org/translations.

CONTRIBUTING.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Thank you for taking interest in contributing to *NVIdb*.
44

5-
There are four ways you can contribute to the development of *NVIdb*: reporting a bug, fixing documentation errors, contributing new code, or commenting on issues/pull requests. Note that the majority of these activities do not require you to be proficient in R.
5+
There are several ways you can contribute to the development of *NVIdb*: reporting a bug, fixing documentation errors, contributing new code, or commenting on issues/pull requests. Note that the majority of these activities do not require you to be proficient in R.
66

77
All new code or documentation must be approved by @PetterHopp.
88

@@ -106,16 +106,21 @@ If you want to contribute code, you are welcome to do so. Please try to adhere t
106106

107107
* You should add yourself as a contributor to the `DESCRIPTION`.
108108

109-
* If you can, also write a test. *NVIdb* uses [testthat](https://cran.r-project.org/package=testthat) for tests.
110-
111-
* If you're adding new parameters or a new function, you'll also need
109+
* If you're adding a new function or new arguments to an existing function, you'll also need
112110
to document them. *NVIdb* uses [roxygen2](https://cran.r-project.org/package=roxygen2), with
113111
[Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/markdown.html),
114112
for documentation. Make sure to re-run `devtools::document()` on the code before submitting.
113+
114+
* *NVIdb* uses functions from [checkmate](https://CRAN.R-project.org/package=checkmate) package for argument checking. Adding argument checking for new functions and/or arguments will be highly appreciated.
115115

116-
* Also run `devtools::check()` to make sure your function doesn't imply downstream errors or warnings.
116+
* If you can, also write a test. *NVIdb* uses [testthat](https://cran.r-project.org/package=testthat) for tests.
117117

118+
* Also run `devtools::check()` to make sure your function doesn't imply downstream errors or warnings.
118119

120+
### Code of Conduct
121+
122+
Please note that the NVIdb project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
123+
119124
### References
120125
Based on [CONTRIBUTING to poppr](https://github.com/grunwaldlab/poppr/blob/main/CONTRIBUTING.md) by @zkamvar and [CONTRIBUTING to dittodb](https://raw.githubusercontent.com/ropensci/dittodb/main/CONTRIBUTING.mdd) by @jonkeane.
121126

DESCRIPTION

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: NVIdb
22
Title: Facilitating use of Norwegian Veterinary Institute's databases
3-
Version: 0.5.1
4-
Date: 2021-04-08
3+
Version: 0.5.2
4+
Date: 2021-04-24
55
Authors@R:
66
c(person(given = "Petter",
77
family = "Hopp",
@@ -19,8 +19,9 @@ Description: The Norwegian Veterinary Institute has several internal databases a
1919
package comprises four categories of functions:
2020
1) Manage credentials (i.e. password and username),
2121
2) Login functions for database services,
22-
3) Read, copy and update different in-house data registers,
23-
4) Translate codes into descriptions.
22+
3) Read, copy and update different in-house data registers,
23+
4) Translate codes into descriptions.
24+
NVIdb is dependant of NVIconfig which has to be installed manually from GitHub.
2425
URL: https://github.com/NorwegianVeterinaryInstitute/NVIdb
2526
BugReports: https://github.com/NorwegianVeterinaryInstitute/NVIdb/issues
2627
Depends: R (>= 3.5.0)

NEWS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
NVIdb 0.5.2 - (2021-04-24)
2+
--------------------------
3+
4+
Bug fixes:
5+
6+
- The selection statement when selecing PJS-codes, for example hensiktkode, is now correct also in he case that only codes with sub-levels are included.
7+
8+
- Corrected add_kommune_fylke so that Møre og Romsdal and Nordland are added correctly to fylkenr 15 and 18, respectively, in the case that gjeldende_fylkenr and/or gjeldende_fylke are added to fylkenr
9+
10+
111
NVIdb 0.5.1 - (2021-04-08)
212
--------------------------
313

R/add_kommune_fylke.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ add_kommune_fylke <- function(data,
112112
code_2_new <- unique(translation_table[, c(unname(code_column), unname(new_column))])
113113

114114
if (code_column == "fylkenr") {
115-
code_2_new <- merge(code_2_new, translation_table[, c(new_column, "komnr")], by = c(new_column))
115+
code_2_new <- merge(code_2_new, translation_table[, c("fylkenr", new_column, "komnr")], by = c("fylkenr", new_column))
116116
code_2_new <- stats::aggregate(stats::as.formula(paste("komnr", "~", paste(c(code_column, new_column), collapse = " + "))), data = code_2_new, FUN = length)
117117

118118
# For fylkenr, select the fylke where most kommuner is within the fylke. This to avoid fylkenr to be translated to fylker

R/build_query_hensikt.R

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#'
2323

2424
build_query_hensikt <- function(year, hensikt, db = "PJS") {
25-
25+
2626
# Argument checking
2727
# Object to store check-results
2828
checks <- checkmate::makeAssertCollection()
@@ -32,38 +32,38 @@ build_query_hensikt <- function(year, hensikt, db = "PJS") {
3232
checkmate::assert_choice(db, choices = c("PJS"), add = checks)
3333
# Report check-results
3434
checkmate::reportAssertions(checks)
35-
35+
3636
select_year <- NVIdb::build_sql_select_year(year = year, varname = "aar")
37-
37+
3838
select_hensikt <- NVIdb::build_sql_select_code(values = hensikt, varname = "hensiktkode")
3939
# select_hensikt <- paste0("hensiktkode in ('", paste(hensikt, collapse = "', '"), "')")
40-
40+
4141
selection_v2_sak_m_res <- paste("SELECT * FROM v2_sak_m_res",
42-
"WHERE", select_year , "AND",
43-
"(",
44-
select_hensikt,
45-
")" )
46-
42+
"WHERE", select_year , "AND",
43+
"(",
44+
select_hensikt,
45+
")" )
46+
4747
select_year <- NVIdb::build_sql_select_year(year = year, varname = "sak.aar")
48-
48+
4949
select_hensikt <- NVIdb::build_sql_select_code(values = hensikt, varname = "sak.hensiktkode")
5050
# select_hensikt <- paste0("sak.hensiktkode in ('", paste(hensikt, collapse = "', '"), "')")
51-
51+
5252
selection_sakskonklusjon <- paste("SELECT v_sakskonklusjon.*,",
53-
"sak.mottatt_dato, sak.uttaksdato, sak.sak_avsluttet, sak.hensiktkode,",
54-
"sak.eier_lokalitetstype, sak.eier_lokalitetnr",
55-
"FROM v_innsendelse AS sak",
56-
"INNER JOIN v_sakskonklusjon",
57-
"ON (v_sakskonklusjon.aar = sak.aar AND",
58-
"v_sakskonklusjon.ansvarlig_seksjon = sak.ansvarlig_seksjon AND",
59-
"v_sakskonklusjon.innsendelsesnummer = sak.innsendelsesnummer)",
60-
"WHERE", select_year, "AND (",
61-
select_hensikt,
62-
")")
63-
53+
"sak.mottatt_dato, sak.uttaksdato, sak.sak_avsluttet, sak.hensiktkode,",
54+
"sak.eier_lokalitetstype, sak.eier_lokalitetnr",
55+
"FROM v_innsendelse AS sak",
56+
"INNER JOIN v_sakskonklusjon",
57+
"ON (v_sakskonklusjon.aar = sak.aar AND",
58+
"v_sakskonklusjon.ansvarlig_seksjon = sak.ansvarlig_seksjon AND",
59+
"v_sakskonklusjon.innsendelsesnummer = sak.innsendelsesnummer)",
60+
"WHERE", select_year, "AND (",
61+
select_hensikt,
62+
")")
63+
6464
select_statement <- list("selection_v2_sak_m_res" = selection_v2_sak_m_res,
6565
"selection_sakskonklusjon" = selection_sakskonklusjon)
66-
66+
6767
return(select_statement)
6868
}
6969

0 commit comments

Comments
 (0)