diff --git a/models/cm_tamai_naracrime.model.lkml b/models/cm_tamai_naracrime.model.lkml new file mode 100644 index 0000000..94d0403 --- /dev/null +++ b/models/cm_tamai_naracrime.model.lkml @@ -0,0 +1,41 @@ +connection: "cm_snowflake" + +include: "/views/*.view" + +datagroup: cm_tamai_naracrime_default_datagroup { + max_cache_age: "1 hour" +} + +persist_with: cm_tamai_naracrime_default_datagroup + +explore: basic_info { + label: "奈良県犯罪情報(基本)" +} + +explore: hit_bicycle { + label: "自転車盗" +} + +explore: hit_car { + label: "自動車盗" +} + +explore: hit_bike { + label: "オートバイ盗" +} + +explore: aim_automat { + label: "自動販売機ねらい" +} + +explore: aim_parts { + label: "部品ねらい" +} + +explore: car_break_in { + label: "車上ねらい" +} + +explore: grab { + label: "ひったくり" +} diff --git a/views/aim_automat.view.lkml b/views/aim_automat.view.lkml new file mode 100644 index 0000000..dfd795b --- /dev/null +++ b/views/aim_automat.view.lkml @@ -0,0 +1,13 @@ +include: "/views/extend_base.view" + +view: aim_automat { + extends: [extend_base] + sql_table_name: "NARA_CRIME"."aim_automat" ;; + + dimension: damage_cash { + label: "現金被害の有無" + type: yesno + sql: ${TABLE}."damage_cash" = 'あり' ;; + } + +} diff --git a/views/aim_parts.view.lkml b/views/aim_parts.view.lkml new file mode 100644 index 0000000..5f91c42 --- /dev/null +++ b/views/aim_parts.view.lkml @@ -0,0 +1,13 @@ +include: "/views/extend_base.view" + +view: aim_parts { + extends: [extend_base] + sql_table_name: "NARA_CRIME"."aim_parts" ;; + + dimension: damage { + label: "現金以外の主な被害品" + type: string + sql: ${TABLE}."damage" ;; + } + +} diff --git a/views/basic_info.view.lkml b/views/basic_info.view.lkml new file mode 100644 index 0000000..e332125 --- /dev/null +++ b/views/basic_info.view.lkml @@ -0,0 +1,66 @@ +include: "/views/extend_base.view" + +view: basic_info { + extends: [extend_base] + + derived_table: { + sql: SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude" + FROM "NARA_CRIME"."aim_parts" + UNION + SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude" + FROM "NARA_CRIME"."grab" + union + SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude" + FROM "NARA_CRIME"."aim_automat" + union + SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude" + FROM "NARA_CRIME"."hit_bike" + union + SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude" + FROM "NARA_CRIME"."hit_bicycle" + union + SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude" + FROM "NARA_CRIME"."hit_car" + union + SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude" + FROM "NARA_CRIME"."car_break_in" + ;; + } + + dimension: deception { + label: "手口" + type: string + sql: ${TABLE}."deception" ;; + link: { + label: "詳細ダッシュボードへ" + url: " + {% if value == '自転車盗' %} + /dashboards/79?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }} + {% elsif value == 'ひったくり' %} + /dashboards/73?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }} + {% elsif value == 'オートバイ盗' %} + /dashboards/78?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }} + {% elsif value == '自動販売機ねらい' %} + /dashboards/78?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }} + {% elsif value == '車上ねらい' %} + /dashboards/76?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }} + {% elsif value == '自動車盗' %} + /dashboards/77?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }} + {% elsif value == '部品ねらい' %} + /dashboards/75?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }} + {% endif %} + " + } + } + +# dimension: deception { +# label: "手口" +# type: string +# sql: ${TABLE}."deception" ;; +# link: { +# label: "詳細ダッシュボードへ" +# url: "/dashboards/79?発生場所={{ basic_info.location._value }}" +# } +# } + +} diff --git a/views/car_break_in.view.lkml b/views/car_break_in.view.lkml new file mode 100644 index 0000000..3a91928 --- /dev/null +++ b/views/car_break_in.view.lkml @@ -0,0 +1,19 @@ +include: "/views/extend_base.view" + +view: car_break_in { + extends: [extend_base] + sql_table_name: "NARA_CRIME"."car_break_in" ;; + + dimension: damage_cash { + label: "現金被害の有無" + type: yesno + sql: ${TABLE}."damage_cash" = 'あり' ;; + } + + dimension: lockup { + label: "施錠関係" + type: yesno + sql: ${TABLE}."lockup" = '施錠した' ;; + } + +} diff --git a/views/extend_base.view.lkml b/views/extend_base.view.lkml new file mode 100644 index 0000000..b140087 --- /dev/null +++ b/views/extend_base.view.lkml @@ -0,0 +1,89 @@ +view: extend_base { + extension: required + + dimension: record_id { + primary_key: yes + hidden: yes + type: number + sql: ${TABLE}."RecordID" ;; + } + + dimension: deception { + label: "手口" + type: string + sql: ${TABLE}."deception" ;; + } + + dimension: precinct { + label: "管轄警察署(発生地)" + type: string + sql: ${TABLE}."precinct" ;; + } + + dimension: police_booth { + label: "管轄交番・駐在所(発生地)" + type: string + sql: ${TABLE}."police_booth" ;; + } + + dimension: municipality { + label: "市区町村(発生地)" + type: string + sql: ${TABLE}."municipality" ;; + } + + dimension: town { + label: "町丁目(発生地)" + type: string + sql: ${TABLE}."town" ;; + } + + dimension_group: datetime_occurrence { + label: "発生年月日時(始期)" + type: time + sql: ${TABLE}."datetime_occurrence" ;; + } + + dimension: attribute_occurrence { + label: "発生場所の属性" + type: string + sql: ${TABLE}."attribute_occurrence" ;; + } + + dimension: latitude { + hidden: yes + type: number + sql: ${TABLE}."Latitude" ;; + } + + dimension: longitude { + hidden: yes + type: number + sql: ${TABLE}."Longitude" ;; + } + + dimension: location { + label: "発生場所" + type: location + sql_latitude: ${latitude} ;; + sql_longitude: ${longitude} ;; + } + + measure: count { + label: "件数" + type: count + drill_fields: [detail*] + } + + set: detail { + fields: [ + datetime_occurrence, + deception, + municipality, + town, + attribute_occurrence, + location + ] + } + +} diff --git a/views/grab.view.lkml b/views/grab.view.lkml new file mode 100644 index 0000000..7d8eb17 --- /dev/null +++ b/views/grab.view.lkml @@ -0,0 +1,25 @@ +include: "/views/extend_base.view" + +view: grab { + extends: [extend_base] + sql_table_name: "NARA_CRIME"."grab" ;; + + dimension: damage_cash { + label: "現金被害の有無" + type: yesno + sql: ${TABLE}."damage_cash" = 'あり' ;; + } + + dimension: age_aggrieved { + label: "被害者の年齢" + type: string + sql: ${TABLE}."age_aggrieved" ;; + } + + dimension: sex_aggrieved { + label: "被害者の性別" + type: string + sql: ${TABLE}."sex_aggrieved" ;; + } + +} diff --git a/views/hit_bicycle.view.lkml b/views/hit_bicycle.view.lkml new file mode 100644 index 0000000..f228ca0 --- /dev/null +++ b/views/hit_bicycle.view.lkml @@ -0,0 +1,25 @@ +include: "/views/extend_base.view" + +view: hit_bicycle { + extends: [extend_base] + sql_table_name: "NARA_CRIME"."hit_bicycle" ;; + + dimension: age_aggrieved { + label: "被害者の年齢" + type: string + sql: ${TABLE}."age_aggrieved" ;; + } + + dimension: job_aggrieved { + label: "被害者の職業" + type: string + sql: ${TABLE}."job_aggrieved" ;; + } + + dimension: lockup { + label: "施錠関係" + type: yesno + sql: ${TABLE}."lockup" = '施錠した' ;; + } + +} diff --git a/views/hit_bike.view.lkml b/views/hit_bike.view.lkml new file mode 100644 index 0000000..52c869d --- /dev/null +++ b/views/hit_bike.view.lkml @@ -0,0 +1,25 @@ +include: "/views/extend_base.view" + +view: hit_bike { + extends: [extend_base] + sql_table_name: "NARA_CRIME"."hit_bike" ;; + + dimension: damage { + label: "現金以外の主な被害品" + type: string + sql: ${TABLE}."damage" ;; + } + + dimension: lockup { + label: "施錠関係" + type: yesno + sql: ${TABLE}."lockup" = 'キーあり' ;; + } + + dimension: antitheft_device { + label: "盗難防止装置の有無" + type: yesno + sql: ${TABLE}."antitheft_device" = 'あり' ;; + } + +} diff --git a/views/hit_car.view.lkml b/views/hit_car.view.lkml new file mode 100644 index 0000000..b6e147a --- /dev/null +++ b/views/hit_car.view.lkml @@ -0,0 +1,6 @@ +include: "/views/hit_bike.view" + +view: hit_car { + extends: [hit_bike] + sql_table_name: "NARA_CRIME"."hit_car" ;; +}