backend/model/entity.rs
1//! Contains all entities used in `PermaplanT`.
2
3pub mod application_settings_impl;
4pub mod areas;
5pub mod areas_impl;
6pub mod base_layer_images;
7pub mod base_layer_images_impl;
8pub mod blossoms_impl;
9pub mod drawings;
10pub mod drawings_impl;
11pub mod guided_tours_impl;
12pub mod layers;
13pub mod layers_impl;
14pub mod map_collaborator_impl;
15pub mod map_impl;
16pub mod plant_layer;
17pub mod plantings;
18pub mod plantings_impl;
19pub mod plants_impl;
20pub mod seed_impl;
21pub mod timeline;
22pub mod users_impl;
23
24use chrono::NaiveDate;
25use chrono::NaiveDateTime;
26
27use diesel::AsChangeset;
28use diesel::QueryableByName;
29use diesel::{Identifiable, Insertable, Queryable};
30use postgis_diesel::types::Point;
31use postgis_diesel::types::Polygon;
32use uuid::Uuid;
33
34use crate::schema::{
35 application_settings, blossoms, gained_blossoms, guided_tours, map_collaborators, maps, plants,
36 seeds, users,
37};
38
39use super::r#enum::experience::Experience;
40use super::r#enum::membership::Membership;
41use super::r#enum::privacy_option::PrivacyOption;
42use super::r#enum::salutation::Salutation;
43use super::r#enum::track::Track;
44use super::r#enum::{
45 herbaceous_or_woody::HerbaceousOrWoody, life_cycle::LifeCycle,
46 light_requirement::LightRequirement, quality::Quality, quantity::Quantity, shade::Shade,
47 soil_texture::SoilTextureEnum, taxonomic_rank::TaxonomicRank,
48 water_requirement::WaterRequirementEnum,
49};
50
51/// The `Plants` entity builds up an hierarchical structure, see `/doc/database/hierarchy.md`:
52///
53#[doc = include_str!("../../../doc/database/hierarchy.md")]
54///
55#[derive(Debug, Identifiable, Queryable, QueryableByName)]
56#[diesel(table_name = plants)]
57pub struct Plants {
58 /// - The internal id of the plant.
59 /// - *Fill ratio:* 100%
60 pub id: i32,
61
62 /// - The unique name of the plant.
63 /// - The structure is described above (`doc/database/hierarchy.md`).
64 /// - *Fill ratio:* 100%
65 pub unique_name: String,
66
67 /// - The list of the common names of the plant in English.
68 /// - *Fetched from* `PracticalPlants` and Permapeople.
69 /// - *Fill ratio:* 90%
70 pub common_name_en: Option<Vec<Option<String>>>,
71
72 /// - The list of the common names of the plant in German.
73 /// - *Fetched from* Wikidata API if not present in any source datasets.
74 /// - *Fill ratio:* 25%
75 pub common_name_de: Option<Vec<Option<String>>>,
76
77 // /// - The edible use of the plant, answering: Which food type can be produced from this plant, e.g. oil?
78 // /// - Interesting for search functionality.
79 // /// - *Fetched from* Permapeople as `edible_uses` and merged with Reinsaat.
80 // /// - *Fill ratio:* 6%
81 // pub edible_uses_en: Option<String>,
82
83 // /// - Not used.
84 // /// - *Fetched from* PracticalPlants as `medicinal_uses` and merged with Permapeople.
85 // /// - *Fill ratio:* 1%
86 //pub medicinal_uses: Option<String>,
87
88 // /// - Only for references.
89 // /// - *Fetched from* PracticalPlants)
90 // /// - *Fill ratio:* 34%
91 // pub material_uses_and_functions: Option<String>,
92
93 // /// - Only for references.
94 // /// - *Fetched from* PracticalPlants)
95 // /// - *Fill ratio:* 63%
96 // pub botanic: Option<String>,
97
98 // /// - Only informational.
99 // /// - *Fetched from* PracticalPlants
100 // /// - Plants are not only used for food but also for other uses, e.g. fiber to produce paper.
101 // /// - *Fill ratio:* 1%
102 // pub material_uses: Option<String>,
103 //
104 /// - *Used* for search ranking (diversity) and to be displayed in plant attributes.
105 /// - ecological and environmental function of the plant, especially nitrogen fixer is relevant for `PermaplanT`.
106 /// - *Fetched from* `PracticalPlants`)
107 /// - *Fill ratio:* 13%
108 pub functions: Option<String>,
109
110 // /// - Not used.
111 // /// - Use `hardiness_zone` instead.
112 // /// - indication of the heat range a plant endures.
113 // /// - *Fetched from* `PracticalPlants`.
114 // /// - *Fill ratio:* 0.05%
115 // pub heat_zone: Option<i16>,
116 //
117 /// - Shade tolerance of the plant, to be used together with `light_requirement`.
118 /// - *Used* in shade layer.
119 /// - *For example* a plant that has "no shade", should get a warning if placed in a shade.
120 /// - No shade: full sun exposure
121 /// - Light shade: moderately shaded throughout the day
122 /// - Partial shade: about 3-6 hours of direct sunlight
123 /// - Permanent shade: less than 3 hours of direct sunlight
124 /// - Shade indicates the shade tolerance. Plants obviously grow better with better light conditions.
125 /// - Warnings should only show if a plant is moved into a too dark spot.
126 /// No warning should be shown when moved into a lighter spot.
127 /// - *Fetched from* `PracticalPlants`.
128 /// - *Fill ratio:* 63%
129 pub shade: Option<Shade>,
130
131 // /// - Currently unused (maybe later used in pH layer).
132 // /// - *See* explanation in `/doc/architecture/context.md`
133 // /// - Soil PH can be tested by the user with simple means (e.g. litmus).
134 // /// - *Fetched from* `PracticalPlants` and Permapeople (merged between Permapeople and `PracticalPlants`).
135 // /// - *Fill ratio:* 1%
136 // pub soil_ph: Option<Vec<Option<SoilPh>>>,
137 //
138 /// - *See* explanation in `/doc/architecture/context.md`
139 /// - *Used* in soil layer.
140 /// - *Fetched from* `PracticalPlants` and Permapeople (merged with `soil_type` of Permapeople).
141 /// - *Fill ratio:* 88%
142 pub soil_texture: Option<Vec<Option<SoilTextureEnum>>>,
143
144 // /// - *NOT used* in hydrology layer
145 // /// as it has poor quality and no additional data compared to water_requirement
146 // /// - *Fill ratio:* 37%
147 // /// - *Fetched from* PracticalPlants
148 // /// - wet = drowned, (often) flooded or in general very moist, e.g. swamp
149 // /// - moist = humid, can hold some water, e.g. flat bed with humus
150 // /// - well drained = dry, low capacity to hold water, e.g. sandhill.
151 // pub soil_water_retention: Option<Vec<Option<SoilWaterRetention>>>,
152
153 // /// - Only informational.
154 // /// - *Fetched from* PracticalPlants
155 // /// - gives information about environmental conditions, such as drought or wind tolerance
156 // /// - *Fill ratio:* 15%
157 //pub environmental_tolerances: Option<Vec<Option<String>>>,
158
159 // /// - Not used.
160 // /// - *Fetched from* PracticalPlants
161 // /// - *Fill ratio:* 0.2%
162 //pub native_geographical_range: Option<String>,
163
164 // /// - Not used.
165 // /// - *Fetched from* `PracticalPlants`
166 // /// - *Fill ratio:* 0.1%
167 //pub native_environment: Option<String>,
168
169 // /// - Interesting for search functionality.
170 // /// - *Fetched from* `PracticalPlants`
171 // /// - informs about the (vertical) layer, that the plant usually inhabits, e.g. soil surface or canopy
172 // /// - *Fill ratio:* 16%
173 // pub ecosystem_niche: Option<String>,
174
175 // /// - Only informational.
176 // /// - deciduous = plants loose leaves in winter.
177 // /// - evergreen = Plants don't throw leaves (e.g. pine tree).
178 // /// - Not applicable for annual plants.
179 // /// - *Fetched from* `PracticalPlants` and merged with `leaves` of Permapeople.
180 // /// - *Fill ratio:* 30%
181 // pub deciduous_or_evergreen: Option<DeciduousOrEvergreen>,
182 /// - *Used* Displayed in the plant attributes.
183 /// - Only informational.
184 /// - Fetched from `PracticalPlants`
185 /// - informs about the plant physiology
186 /// - woody = grows woody parts
187 /// - herbaceous = doesn't grow wood, shoots remain soft/green.
188 /// - *Fill ratio:* 26%
189 pub herbaceous_or_woody: Option<HerbaceousOrWoody>,
190
191 /// - Use in search and attribute
192 /// - Determines life span of the plant.
193 /// - *Fetched from* `PracticalPlants` and Permapeople (merged with `life_cycle` of Permapeople).
194 /// - *Fill ratio:* 68%
195 pub life_cycle: Option<Vec<Option<LifeCycle>>>,
196
197 // /// - Only informational.
198 // /// - *Fetched from* `PracticalPlants` and Permapeople (merged with `growth` of Permapeople).
199 // /// - *Fill ratio:* 30%
200 // pub growth_rate: Option<Vec<Option<GrowthRate>>>,
201 //
202 /// - Only informational, is in rw attribute
203 /// - *Fetched from* `PracticalPlants` as `mature_size_height` and merged with Permapeople.
204 /// - informs about the maximum height that the plant gains in cm
205 /// - *Fill ratio:* 80%
206 pub height: Option<i32>,
207
208 // /// - Determines how large the plant can grow in diameter.
209 // /// - Other plants should get a warning if planted within this area.
210 // /// - *TODO:* replaced with spread, will keep this for now for information
211 // /// - *Fetched from* `PracticalPlants` as `mature_size_width` and merged with Permapeople.
212 // /// - *Fill ratio:* 22%
213 //pub width: Option<String>,
214
215 // /// - Only informational.
216 // /// - *Fetched from* `PracticalPlants`
217 // /// - *Fill ratio:* 18%
218 // pub fertility: Option<Vec<Option<Fertility>>>,
219
220 // /// - Only informational.
221 // /// - *Fetched from* PracticalPlants
222 // /// - *Fill ratio:* 0.5%
223 //pub flower_colour: Option<String>,
224
225 // /// - Only informational.
226 // /// - *Fetched from* PracticalPlants
227 // /// - a plant can contain flowers of two different sexes, male or female (monoecious), a plant can contain only flowers of one specific sex and therefore needs at least another plant of the other sex to reproduce (dioecious) or can contain flowers that have both the sexes within the same flower (hermaphrodite).
228 // /// - *Fill ratio:* 62%
229 // pub flower_type: Option<FlowerType>,
230 /// - Is readonly in attribute
231 /// - The creation date of the entry (actual time).
232 /// - Only for administration.
233 /// - *Fill ratio:* 100%
234 pub created_at: NaiveDateTime,
235
236 /// - Is readonly in attribute
237 /// - The last update date of the entry (actual time).
238 /// - Only for administration.
239 /// - *Fill ratio:* 100%
240 pub updated_at: NaiveDateTime,
241
242 /// - *Used* so that an icon can be shown in the search results. Also displayed in the plant attributes.
243 /// - Will be used in watering layer.
244 /// - Fetched from `PracticalPlants` and merged with `has_drought_tolerance` of Permapeople.
245 /// - *Fill ratio:* 57%
246 pub has_drought_tolerance: Option<bool>,
247
248 // /// - *Fetched from* `PracticalPlants`.
249 // /// - *Fill ratio:* 10%
250 // pub tolerates_wind: Option<bool>,
251
252 // /// - The list of the references of the plant.
253 // /// - `references` items link to these items.
254 // /// - Only informational.
255 // /// - *Fill ratio:* 58%
256 // pub plant_references: Option<Vec<Option<String>>>,
257
258 // /// - Boolean value indicating whether the plant is a tree.
259 // /// - Plants with `is_tree == true` can be used in the tree layer.
260 // /// - In plants layer all plants can be used.
261 // /// - *Initial value* is to `True` if herbaceous_or_woody (woody) and life_cycle (perennial)
262 // /// - *Fill ratio:* 0.1%
263 // pub is_tree: Option<bool>,
264
265 // /// - Only informational.
266 // /// - *Initial value* is to `light feeder` if "Nutritionally poor soil" in `environmental_tolerances` is present.
267 // /// - *Fill ratio:* 0.04%
268 // pub nutrition_demand: Option<NutritionDemand>,
269
270 // /// - Not used.
271 // /// - Number value between -1..6 (-1 should be printed as 00)
272 // /// - *Fill ratio:* 0%
273 // pub preferable_permaculture_zone: Option<i16>,
274
275 // /// - When article was modified last time.
276 // /// - Only for administration.
277 // /// - Date value fetched from `PracticalPlants` page showing the last modification date of the plant.
278 // /// - *Fill ratio:* 63%
279 // pub article_last_modified_at: Option<NaiveDateTime>,
280 //
281 /// - *Used* To diplay an icon in the search results.
282 /// - USDA Hardiness Zone (without subranges).
283 /// - Important information.
284 /// - Fetched from `PracticalPlants` and Permapeople (merged with `usda_hardiness_zone` of Permapeople).
285 /// - *Fill ratio:* 63%
286 pub hardiness_zone: Option<String>,
287
288 /// - Shade tolerance of the plant, to be used together with shade.
289 /// - *Used* in shade layer.
290 /// - *For example* a plant that has "Full sun", should get a warning if placed in a shade.
291 /// - **Fetched from*** `PracticalPlants` and Permapeople (merged with `sun` of `PracticalPlants`)
292 /// - Full sun: full sun exposure
293 /// - Partial sun/shade: about 3-6 hours of direct sunlight or moderately shaded throughout the day
294 /// - Full shade: less than 3 hours of direct sunlight or almost no sunlight/no direct sunlight
295 /// - *Fill ratio:* 88%
296 pub light_requirement: Option<Vec<Option<LightRequirement>>>,
297
298 /// - *Used* in hydrology layer.
299 /// - *Fetched from* `PracticalPlants` and Permapeople (merged with `water` of `PracticalPlants`).
300 /// - water = completely aquatic;
301 /// - wet = drowned, (often) flooded or in general very moist, e.g. swamp;
302 /// - moist = humid, regular water supply, e.g. flat bed with humus;
303 /// - well drained = dry, little water input.
304 /// - *Fill ratio:* 88%
305 pub water_requirement: Option<Vec<Option<WaterRequirementEnum>>>,
306
307 // /// - Only informational.
308 // /// - *Fetched from* Permapeople (renamed from `propagation`)
309 // /// - How to reproduce a plant: cuttings = cut pieces of wood; layering = let low branches reach the soil to root; Seed - direct sow = sow directly the seeds; division = split the rhizomes (roots) into pieces; Spores = plant reproduces via spores (e.g. ferns, funghi); seed - transplant = raise indoors from seed and transplant to outdoors later
310 // /// - *Fill ratio:* 0.9%
311 // pub propagation_method: Option<Vec<Option<PropagationMethod>>>,
312
313 // /// - Only informational.
314 // /// - May be used in search functionality (low priority).
315 // /// - *Fetched from* Permapeople.
316 // /// - *Fill ratio:* 35%
317 // pub alternate_name: Option<String>,
318
319 // /// - Only informational.
320 // /// - *Fetched from* Permapeople.
321 // /// - *Fill ratio:* 0.02%
322 //pub diseases: Option<String>,
323 //
324 /// - *Used* so that an icon can be shown in the search results. Also displayed in the plant attributes.
325 /// - Important information.
326 /// - *Fetched from* Permapeople.
327 /// - *Fill ratio:* 62%
328 pub edible: Option<bool>,
329
330 /// - Only informational.
331 /// - *Used* Displayed in the plant attributes.
332 /// - *Fetched from* Permapeople.
333 /// - which organ of the plant can be eaten, e.g. root, leaves.
334 /// - *Fill ratio:* 61%
335 pub edible_parts: Option<Vec<Option<String>>>,
336
337 // /// - Only informational.
338 // /// - *Fetched from* Permapeople.
339 // /// - Reinsaat: `Keimtemperatur` should be copied to `germination_temperature`
340 // /// - Germination means that all conditions are right for a seed to start growing. Temperature is one essential factor.
341 // /// - *Fill ratio:* 2%
342 //pub germination_temperature: Option<String>,
343
344 // /// - Not used.
345 // /// - *Fetched from* Permapeople.
346 // /// - *Fill ratio:* 36%
347 //pub introduced_into: Option<String>,
348
349 // /// - Only informational.
350 // /// - *Fetched from* Permapeople as \`layer\` and renamed.
351 // /// - Habitus describes the shape of a plant.
352 // /// - *Fill ratio:* 48%
353 //pub habitus: Option<String>,
354
355 // /// - Not used.
356 // /// - *Fetched from* Permapeople.
357 // /// - *Fill ratio:* 0.1%
358 //pub medicinal_parts: Option<String>,
359
360 // /// - Only informational.
361 // /// - *Fetched from* Permapeople.
362 // /// - *Fill ratio:* 80%
363 //pub native_to: Option<String>,
364
365 // /// - Not used.
366 // /// - *Fetched from* Permapeople.
367 // /// - *Fill ratio:* 86%
368 //pub plants_for_a_future: Option<String>,
369
370 // /// - Not used.
371 // /// - *Fetched from* Permapeople.
372 // /// - *Fill ratio:* 86%
373 //pub plants_of_the_world_online_link: Option<String>,
374
375 // /// - Not used.
376 // /// - *Fetched from* Permapeople.
377 // /// - *Fill ratio:* 15%
378 //pub plants_of_the_world_online_link_synonym: Option<String>,
379
380 // /// - Only informational.
381 // /// - *Fetched from* PracticalPlants as `pollinators` and merged with `pollination` of Permapeople.
382 // /// - Pollination is the process that the pollen (male part) gets united with the pistil (female part), e.g. via bees, wind.
383 // /// - *Fill ratio:* 48%
384 //pub pollination: Option<String>,
385
386 // /// - Only informational.
387 // /// - *Fetched from* Permapeople.
388 // /// - *Fill ratio:* 0.1%
389 //pub propagation_transplanting_en: Option<String>,
390
391 // /// - Not used.
392 // /// - Nearly empty.
393 // /// - *Fetched from* Permapeople.
394 // /// - *Fill ratio:* 0.01%
395 //pub resistance: Option<String>,
396
397 // /// - Only informational.
398 // /// - *Fetched from* Permapeople.
399 // /// - Root type describes the shape of the roots.
400 // /// - *Fill ratio:* 0.24%
401 //pub root_type: Option<String>,
402
403 // /// - Only informational.
404 // /// - *Fetched from* Permapeople as `seed_planting_depth` and renamed.
405 // /// - Reinsaat: `Sowing depth` should be copied to `seed_planting_depth_en`
406 // /// - When sowing each plant has a specific value how deep the seeds should be covered with soil.
407 // /// - *Fill ratio:* 0.07%
408 //pub seed_planting_depth_en: Option<String>,
409
410 // /// - Only informational.
411 // /// - *Fetched from* Permapeople.
412 // /// - expected average life span (in years) of a seed of a certain specie.
413 // /// - *Fill ratio:* 0.6%
414 //pub seed_viability: Option<String>,
415
416 // /// - Not used.
417 // /// - The final part of the URL of the plant on the Permapeople website.
418 // /// - This field can be potentially used to construct the `external_url` field traversing through all the parents given by `parent_id`.
419 // /// - *Fetched from* Permapeople.
420 // /// - *Fill ratio:* 90%
421 //pub slug: Option<String>,
422 //
423 /// - **Used**
424 /// - How far a plant spreads (The 'width' of a plant) in cm
425 /// - *Fetched from* Permapeople.
426 /// - *Fill ratio:* 0.1%
427 pub spread: Option<i32>,
428
429 // /// - Not used.
430 // /// - *Fetched from* Permapeople.
431 // /// - *Fill ratio:* 2%
432 //pub utility: Option<String>,
433 //
434 /// - *Used* so that an icon can be shown in the search results. Also displayed in the plant attributes.
435 /// - Important information.
436 /// - *Fetched from* Permapeople.
437 /// - specific warnings for eather human, animal or environmental well-being, e.g. toxic, invasive.
438 /// - *Fill ratio:* 8%
439 pub warning: Option<String>,
440
441 // /// - Not used.
442 // /// - *Fetched from* Permapeople.
443 // /// - *Fill ratio:* 0.06%
444 //pub when_to_plant_cuttings_en: Option<String>,
445
446 // /// - Not used.
447 // /// - *Fetched from* Permapeople.
448 // /// - *Fill ratio:* 0.07%
449 //pub when_to_plant_division_en: Option<String>,
450
451 // /// - Not used.
452 // /// - *Fetched from* Permapeople.
453 // /// - *Fill ratio:* 0.2%
454 //pub when_to_plant_transplant_en: Option<String>,
455
456 // /// - Only informational.
457 // /// - *Fetched from* Permapeople.
458 // /// - *Fill ratio:* 0.23%
459 //pub when_to_sow_indoors_en: Option<String>,
460
461 // /// - Only informational.
462 // /// - *Fetched from* Permapeople as `when_to_sow_outdoors` and renamed.
463 // /// - Reinsaat: `Sowing` or `Direct Sowing` or `Sowing outdoors` or `Sowing Direct Outdoors` should be copied to `sowing_outdoors_en`
464 // /// - *Fill ratio:* 0.36%
465 //pub sowing_outdoors_en: Option<String>,
466
467 // /// - Only informational.
468 // /// - *Fetched from* Permapeople.
469 // /// - *Fill ratio:* 0.56%
470 //pub when_to_start_indoors_weeks: Option<String>,
471
472 // /// - Only informational.
473 // /// - *Fetched from* Permapeople.
474 // /// - *Fill ratio:* 0.12%
475 //pub when_to_start_outdoors_weeks: Option<String>,
476
477 // /// - Only informational.
478 // /// - *Fetched from* Permapeople.
479 // /// - Stratification is the process that a seed must go through to get triggered for germination, e.g. by a certain threshold of minus degrees.
480 // /// - *Fill ratio:* 0.03%
481 //pub cold_stratification_temperature: Option<String>,
482
483 // /// - Only informational.
484 // /// - *Fetched from* Permapeople.
485 // /// - Suggested change
486 // /// - *Fetched from* Permapeople.
487 // /// - Stratification is the process that a seed must go through to get triggered for germination, e.g. by a certain amount of time under cold temperatures.
488 // /// - *Fill ratio:* 0.05%
489 //pub cold_stratification_time: Option<String>,
490
491 // /// - Only informational.
492 // /// - *Fetched from* Permapeople.
493 // /// - Reinsaat: `1st harvest` should be copied to `days_to_harvest`
494 // /// - *Fill ratio:* 0.1%
495 //pub days_to_harvest: Option<String>,
496
497 // /// - Needed for occupied space and in attributes
498 // /// - *TODO:* should be number and then be used for calender
499 //pub life_cycle_days: Option<int>,
500
501 // /// - Not used.
502 // /// - *Fetched from* Permapeople.
503 // /// - *Fill ratio:* 0.2%
504 //pub habitat: Option<String>,
505
506 // /// - One number means it is spacing between plants and rows. Two numbers means first is spacing between plants, second between rows.
507 // /// - Only informational.
508 // /// - *Fetched from* Permapeople as `spacing` and from Reinsaat as `Distances` and renamed.
509 // /// - Reinsaat: `Distances` or `Spacing` should be copied to `spacing_en`
510 // /// - *Fill ratio:* 0.7%
511 //pub spacing_en: Option<String>,
512
513 // /// - Not used.
514 // /// - *Fetched from* Permapeople as `wikipedia` and renamed.
515 // /// - *Fill ratio:* 47%
516 //pub wikipedia_url: Option<String>,
517
518 // /// - Only informational.
519 // /// - *Fetched from* Permapeople.
520 // /// - *Fill ratio:* 0.3%
521 //pub days_to_maturity: Option<String>,
522
523 // /// - Not used.
524 // /// - Nearly empty.
525 // /// - *Fetched from* Permapeople.
526 // /// - *Fill ratio:* 0.03%
527 //pub pests: Option<String>,
528 //
529 /// - Only for administration.
530 /// - The version of the entry.
531 /// - To be incremented after every relevant change.
532 /// - *Fetched from* Permapeople.
533 /// - *Fill ratio:* 90%
534 pub version: Option<i16>,
535
536 // /// - Only informational.
537 // /// - *Fetched from* Permapeople.
538 // /// - Germination time describes the time (days, weeks, months) that a seed needs to germinate given the right conditions.
539 // /// - *Fill ratio:* 0.5%
540 //pub germination_time: Option<String>,
541
542 // /// - Not used.
543 // /// - The description of the entry.
544 // /// - *Fetched from* Permapeople.
545 // /// - *Fill ratio:* 5%
546 //pub description: Option<String>,
547
548 // /// - TODO: (not yet in database) add to attributes
549 // /// - Short important information to shown.
550 //pub info: Option<String>,
551
552 // /// - Not used.
553 // /// - *Fetched from* permapeople id of the parent entry pointing to the `external_id` column.
554 // /// - *Fill ratio:* 2%
555 //pub parent_id: Option<String>,
556
557 // /// - Not used.
558 // /// - Enum value indicating the source of the entry.
559 // /// - *Fill ratio:* 100%
560 // pub external_source: Option<ExternalSource>,
561
562 // /// - Not used.
563 // /// - The external id of the entry used in combination with the `external_source` column.
564 // /// - *Fill ratio:* 90%
565 //pub external_id: Option<String>,
566
567 // /// - Not used.
568 // /// - The external URL provided by the origin source.
569 // /// - *Fill ratio:* 9%
570 //pub external_url: Option<String>,
571
572 // /// - Only informational.
573 // /// - *Fetched from* PracticalPlants as `root_zone_tendency` and merged with root_depth of Permapeople.
574 // /// - Root depth can be considered when planning polycultures, e.g. combining shallow roots with deep roots.
575 // /// - *Fill ratio:* 0.2%
576 //pub root_depth: Option<String>,
577
578 // /// - Not used.
579 // /// - The article number `Artikelnummer` of the plant in the Reinsaat database.
580 // /// - *Fill ratio:* 7%
581 //pub external_article_number: Option<String>,
582
583 // /// - Not used.
584 // /// - `Portionsinhalt` should be called `external_portion_content`
585 // /// - *Fetched from* Reinsaat.
586 // /// - *Fill ratio:* 7%
587 //pub external_portion_content: Option<String>,
588
589 // /// - Only informational.
590 // /// - *Fetched from* Reinsaat as \`Direktsaat\` and renamed.
591 // /// - `Direktsaat` or `Aussaat` should be called `sowing_outdoors_de`
592 // /// - *Fill ratio:* 3%
593 //pub sowing_outdoors_de: Option<String>,
594 //
595 /// - *Used* Displayed in the plant attributes.
596 /// - String array of numbers representing a time period.
597 /// - The year is divided into 24 periods of half a month each.
598 /// - *For example* "\[8,9,10\]" means from the 2nd half of April to the 2nd half of May incl.
599 /// - *Fetched from* Reinsaat
600 /// - `Aussaat/ Pflanzung Freiland` should be called `sowing_outdoors`
601 /// - *Fill ratio:* 5%
602 pub sowing_outdoors: Option<Vec<Option<i16>>>,
603
604 /// - *Used* Displayed in the plant attributes.
605 /// - String array of numbers representing a time period.
606 /// - The year is divided into 24 periods of half a month each.
607 /// - *For example* "\[8,9,10\]" means from the 2nd half of April to the 2nd half of May incl.
608 /// - `Ernte` should be called `harvest_time`
609 /// - *Fetched from* Reinsaat
610 /// - *Fill ratio:* 6%
611 pub harvest_time: Option<Vec<Option<i16>>>,
612 /*
613 /// - Only informational.
614 /// - *Fetched from* Reinsaat.
615 /// - `Abstände` should be called `spacing_de`
616 /// - *Fill ratio:* 4%
617 //pub spacing_de: Option<String>,
618
619 /// - Only informational.
620 /// - *Fetched from* Reinsaat.
621 /// - *Fill ratio:* 4%
622 /// - `Saatgutbedarf` should be called `required_quantity_of_seeds_de`
623 //pub required_quantity_of_seeds_de: Option<String>,
624
625 /// - Only informational.
626 /// - *Fetched from* Reinsaat.
627 /// - `Required quantity of seeds` should be called `required_quantity_of_seeds_en`
628 /// - *Fill ratio:* 3%
629 //pub required_quantity_of_seeds_en: Option<String>,
630
631 /// - Only informational.
632 /// - *Fetched from* Reinsaat.
633 /// - `Saattiefe` should be called `seed_planting_depth_de`
634 /// - When sowing, each plant has a specific value how deep the seeds should be covered with soil.
635 /// - *Fill ratio:* 5%
636 //pub seed_planting_depth_de: Option<String>,
637
638 /// - German version of thousand grain weight (German: Tausendkornmasse)
639 /// - Only informational.
640 /// - *Fetched from* Reinsaat.
641 /// - Called `Tausendkornmasse` in Reinsaat
642 /// - *Fill ratio:* 4%
643 //pub seed_weight_1000_de: Option<String>,
644
645 /// - English version of thousand grain weight (German: Tausendkornmasse)
646 /// - Only informational.
647 /// - *Fetched from* Reinsaat.
648 /// - Called `Thousand seeds mass` in Reinsaat
649 /// - *Fill ratio:* 3%
650 //pub seed_weight_1000_en: Option<String>,
651
652 /// - Number for thousand grain weight (German: Tausendkornmasse)
653 /// - *Used* in `doc/usecases/buy_seeds.md` to calculate seed weight based on number of plants.
654 /// - *Fetched from* Permapeople as `1000_seed_weight_g` and renamed.
655 /// - *TODO:* merge with data from reinsaat: `Tausendkorngewicht (TKG)` should be copied to `seed_weight` (remove ` g`)
656 /// - *Fill ratio:* 4%
657 // pub seed_weight_1000: Option<f64>,
658
659 /// - Only informational.
660 /// - *Fetched from* Reinsaat.
661 /// - `Suitable for professional cultivation` should be called `machine_cultivation_possible`
662 /// - *Fill ratio:* 9%
663 //pub machine_cultivation_possible: Option<bool>,
664
665 /// - *Fetched from* Reinsaat.
666 /// - *Used* for plant search and informational.
667 /// - `subcategory` from Reinsaat should be copied to `edible_uses_de` and `edible_uses_en` respectively (DE and EN version)
668 /// - *Fill ratio:* 6%
669 //pub edible_uses_de: Option<String>,
670 */
671 /// - Hierarchy fields
672 /// - Either *Fetched from* `PracticalPlants` and Permapeople
673 /// - Or determined from the unique name
674 /// - Or set by scraper overrides
675 pub rank: Option<TaxonomicRank>,
676 pub family: Option<i32>,
677 pub genus: Option<i32>,
678 pub species: Option<i32>,
679 pub variety: Option<i32>,
680
681 /// - The path to the icon of the plant.
682 pub icon_path: Option<String>,
683}
684/// The `Seed` entity.
685#[derive(Identifiable, Queryable)]
686#[diesel(table_name = seeds)]
687pub struct Seed {
688 /// The record id of the seed.
689 pub id: i32,
690 /// An additional name for the seed.
691 pub name: String,
692 /// When the seeds were harvested.
693 pub harvest_year: i16,
694 /// When the seeds should be used by.
695 pub use_by: Option<NaiveDate>,
696 /// Where the seeds came from.
697 pub origin: Option<String>,
698 /// What the seeds taste like.
699 pub taste: Option<String>,
700 /// The yield of the seeds.
701 pub yield_: Option<String>,
702 /// How many seeds there are.
703 pub quantity: Quantity,
704 /// The quality of the seeds.
705 pub quality: Option<Quality>,
706 /// How much the seeds cost.
707 pub price: Option<i16>,
708 /// How many generations the seeds have been grown.
709 pub generation: Option<i16>,
710 /// Notes about the seeds.
711 pub notes: Option<String>,
712 /// The id of the plant this seed belongs to.
713 pub plant_id: Option<i32>,
714 /// The id of the creator of the seed.
715 pub created_by: Uuid,
716 /// Timestamp indicating when the seed was archived.
717 /// Empty if the seed was not archived.
718 pub archived_at: Option<NaiveDateTime>,
719}
720
721/// The `NewSeed` entity.
722#[allow(clippy::missing_docs_in_private_items)] // TODO: See #97.
723#[derive(Insertable)]
724#[diesel(table_name = seeds)]
725pub struct NewSeed {
726 pub name: String,
727 pub plant_id: Option<i32>,
728 pub harvest_year: i16,
729 pub use_by: Option<NaiveDate>,
730 pub origin: Option<String>,
731 pub taste: Option<String>,
732 pub yield_: Option<String>,
733 pub quantity: Quantity,
734 pub quality: Option<Quality>,
735 pub price: Option<i16>,
736 pub generation: Option<i16>,
737 pub notes: Option<String>,
738 pub created_by: Uuid,
739}
740
741/// The `Map` entity.
742#[derive(Identifiable, Queryable)]
743#[diesel(table_name = maps)]
744pub struct Map {
745 /// The id of the map.
746 pub id: i32,
747 /// The name of the map.
748 pub name: String,
749 /// The date the map is supposed to be deleted.
750 pub deletion_date: Option<NaiveDate>,
751 /// The date the last time the map view was opened by any user.
752 pub last_visit: Option<NaiveDate>,
753 /// A flag indicating if this map is marked for deletion.
754 pub is_inactive: bool,
755 /// The zoom factor of the map.
756 pub zoom_factor: i16,
757 /// The amount of honors the map received.
758 pub honors: i16,
759 /// The amount of visits the map had.
760 pub visits: i16,
761 /// The amount of plants harvested on the map.
762 pub harvested: i16,
763 /// An enum indicating if this map is private or not.
764 pub privacy: PrivacyOption,
765 /// The description of the map.
766 pub description: Option<String>,
767 /// The location of the map as a latitude/longitude point.
768 pub location: Option<Point>,
769 /// The id of the creator of the map.
770 pub created_by: Uuid,
771 /// The geometry of the map.
772 pub geometry: Polygon<Point>,
773 /// When the map was created.
774 pub created_at: NaiveDateTime,
775 /// When a map was last modified, e.g., by modifying plantings.
776 pub modified_at: NaiveDateTime,
777 /// By whom the map was last modified.
778 pub modified_by: Uuid,
779}
780
781/// The `NewMap` entity.
782#[derive(Insertable)]
783#[diesel(table_name = maps)]
784pub struct NewMap {
785 /// The name of the map.
786 pub name: String,
787 /// For a new map the same as `created_by`.
788 pub deletion_date: Option<NaiveDate>,
789 /// The date the last time the map view was opened by any user.
790 pub last_visit: Option<NaiveDate>,
791 /// A flag indicating if this map is marked for deletion.
792 pub is_inactive: bool,
793 /// The zoom factor of the map.
794 pub zoom_factor: i16,
795 /// The amount of honors the map received.
796 pub honors: i16,
797 /// The amount of visits the map had.
798 pub visits: i16,
799 /// The amount of plants harvested on the map.
800 pub harvested: i16,
801 /// An enum indicating if this map is private or not.
802 pub privacy: PrivacyOption,
803 /// The description of the map.
804 pub description: Option<String>,
805 /// The location of the map as a latitude/longitude point.
806 pub location: Option<Point>,
807 /// The id of the creator of the map.
808 pub created_by: Uuid,
809 /// The geometry of the map.
810 pub geometry: Polygon<Point>,
811 /// The user who last modified the planting.
812 pub modified_by: Uuid,
813}
814
815/// The `UpdateMap` entity.
816#[derive(AsChangeset)]
817#[diesel(table_name = maps)]
818pub struct UpdateMap {
819 /// The name of the map.
820 pub name: Option<String>,
821 /// An enum indicating if this map is private or not.
822 pub privacy: Option<PrivacyOption>,
823 /// The description of the map.
824 pub description: Option<String>,
825 /// The location of the map as a latitude/longitude point.
826 pub location: Option<Point>,
827}
828
829/// The `UpdateMapGeometry` entity.
830#[derive(AsChangeset)]
831#[diesel(table_name = maps)]
832pub struct UpdateMapGeometry {
833 /// New Map Bounds
834 pub geometry: Polygon<Point>,
835}
836
837/// The `Users` entity.
838#[derive(Insertable, Identifiable, Queryable)]
839#[diesel(table_name = users)]
840pub struct Users {
841 /// The id of the user from Keycloak.
842 pub id: Uuid,
843 /// The preferred salutation of the user.
844 pub salutation: Salutation,
845 /// The title(s) of the user.
846 pub title: Option<String>,
847 /// The current country of the user.
848 pub country: String,
849 /// The phone number of the user.
850 pub phone: Option<String>,
851 /// The website of the user.
852 pub website: Option<String>,
853 /// The organization the user belongs to.
854 pub organization: Option<String>,
855 /// The experience level in permaculture of the user.
856 pub experience: Option<Experience>,
857 /// The membership type of the user.
858 pub membership: Option<Membership>,
859 /// A collection of years in which the user was a member.
860 pub member_years: Option<Vec<Option<i32>>>,
861 /// The date since when the user is a member.
862 pub member_since: Option<NaiveDate>,
863 /// The amount of permacoins the user earned in each year as a member.
864 pub permacoins: Option<Vec<Option<i32>>>,
865}
866
867/// The `GuidedTours` entity.
868#[derive(Insertable, Identifiable, Queryable)]
869#[diesel(primary_key(user_id), table_name = guided_tours)]
870pub struct GuidedTours {
871 /// The id of the user from Keycloak.
872 pub user_id: Uuid,
873 /// A flag indicating if the Map Editor Guided Tour was completed.
874 pub editor_tour_completed: bool,
875}
876
877/// The `UpdateGuidedTours` entity.
878#[derive(AsChangeset)]
879#[diesel(table_name = guided_tours)]
880pub struct UpdateGuidedTours {
881 /// A flag indicating if the Map Editor Guided Tour was completed.
882 pub editor_tour_completed: Option<bool>,
883}
884
885/// The `Blossom` entity.
886#[derive(Identifiable, Queryable)]
887#[diesel(primary_key(title), table_name = blossoms)]
888pub struct Blossom {
889 /// The title of the Blossom.
890 pub title: String,
891 /// The description of the Blossom.
892 pub description: Option<String>,
893 /// The track the Blossom is part of.
894 pub track: Track,
895 /// The path to the icon of the Blossom in Nextcloud.
896 pub icon: String,
897 /// A flag indicating if this Blossom is repeatable every season.
898 pub is_seasonal: bool,
899}
900
901/// The `GainedBlossoms` entity.
902#[derive(Insertable, Identifiable, Queryable)]
903#[diesel(primary_key(user_id, blossom), table_name = gained_blossoms)]
904pub struct GainedBlossoms {
905 /// The id of the user from Keycloak.
906 pub user_id: Uuid,
907 /// The title of the Blossom.
908 pub blossom: String,
909 /// The number of times this Blossom was gained by this user.
910 pub times_gained: i32,
911 /// The date on which the user gained this Blossom.
912 pub gained_date: NaiveDate,
913}
914
915/// The `ApplicationSetting` entity.
916#[derive(Identifiable, Queryable)]
917#[diesel(primary_key(id), table_name = application_settings)]
918pub struct ApplicationSetting {
919 /// The id of the setting
920 pub id: i32,
921 /// The unique key of the setting
922 pub key: String,
923 /// The value of the setting
924 pub value: String,
925}
926
927/// The [`MapCollaborator`] entity.
928#[derive(Insertable, Identifiable, Queryable)]
929#[diesel(primary_key(map_id, user_id), table_name = map_collaborators)]
930pub struct MapCollaborator {
931 pub map_id: i32,
932 pub user_id: Uuid,
933 pub created_at: NaiveDateTime,
934}