Skip to content

Commit

Permalink
Merge pull request #26764 from code-dot-org/revert-26702-auto-project…
Browse files Browse the repository at this point in the history
…-counter

Revert "Auto project counter"
  • Loading branch information
dmcavoy committed Jan 26, 2019
2 parents fd243d7 + 941faa7 commit 96d7542
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 114 deletions.
2 changes: 1 addition & 1 deletion apps/i18n/common/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@
"projectsViewAll": "View all projects",
"projectsViewProjectGallery": "View projects",
"projects": "Projects",
"projectsSubHeading": "Over {project_count} million projects created",
"projectsSubHeading": "Over 35 million projects created",
"print": "Print",
"privacyPolicy": "Privacy Policy",
"projectWarning": "Note: You are on a level that is part of a longer project. Changes made on this level will also appear in other levels in the project.",
Expand Down
1 change: 0 additions & 1 deletion apps/src/sites/studio/pages/projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ $(document).ready(() => {
<Provider store={store}>
<ProjectHeader
canViewAdvancedTools={projectsData.canViewAdvancedTools}
projectCount={projectsData.projectCount}
/>
</Provider>,
document.getElementById('projects-header')
Expand Down
15 changes: 11 additions & 4 deletions apps/src/sites/studio/pages/projects/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import $ from 'jquery';
import React from 'react';
import ReactDOM from 'react-dom';
import PublicGallery from '@cdo/apps/templates/projects/PublicGallery';
import HeaderBanner from '@cdo/apps/templates/HeaderBanner';
import i18n from "@cdo/locale";
import { Provider } from 'react-redux';
import { getStore, registerReducers } from '@cdo/apps/redux';
import projects, { setProjectLists } from '@cdo/apps/templates/projects/projectsRedux';
import { MAX_PROJECTS_PER_CATEGORY } from '@cdo/apps/templates/projects/projectConstants';
import ProjectHeader from "@cdo/apps/templates/projects/ProjectHeader";
import StartNewProject from '@cdo/apps/templates/projects/StartNewProject';

$(document).ready(() => {
const script = document.querySelector('script[data-projects]');
Expand All @@ -24,9 +26,14 @@ $(document).ready(() => {
ReactDOM.render(
<Provider store={getStore()}>
<div>
<ProjectHeader
canViewAdvancedTools={projectsData.canViewAdvancedTools}
projectCount={projectsData.projectCount}
<HeaderBanner
headingText={i18n.projects()}
subHeadingText={i18n.projectsSubHeading()}
short
/>
<StartNewProject
canViewFullList
canViewAdvancedTools
/>
<PublicGallery
limitedGallery={projectsData.limitedGallery}
Expand Down
3 changes: 1 addition & 2 deletions apps/src/templates/projects/ProjectHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import HeaderBanner from '@cdo/apps/templates/HeaderBanner';
export default class ProjectHeader extends React.Component {
static propTypes = {
canViewAdvancedTools: PropTypes.bool,
projectCount: PropTypes.number,
};

render() {
Expand All @@ -16,7 +15,7 @@ export default class ProjectHeader extends React.Component {
<HeaderBanner
short={true}
headingText={i18n.projects()}
subHeadingText={i18n.projectsSubHeading({project_count: this.props.projectCount})}
subHeadingText={i18n.projectsSubHeading()}
/>
<StartNewProject
canViewFullList
Expand Down
26 changes: 0 additions & 26 deletions apps/test/unit/templates/projects/ProjectHeaderTest.js

This file was deleted.

2 changes: 0 additions & 2 deletions bin/cron/analyze_hoc_activity
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,11 @@ def main
petition_signatures = PEGASUS_REPORTING_DB_READONLY[:forms].where(kind: 'Petition').group_by(:hashed_email).count

time = DateTime.now
# Pull current project_count to keep that current value.
Properties.set :metrics, {
created_at: time,
created_on: time.to_date,
petition_signatures: petition_signatures,
lines_of_code: lines_of_code,
project_count: Properties.get(:metrics)['project_count'],
}

total_females = DASHBOARD_REPORTING_DB_READONLY[:users].where(gender: 'f').exclude(last_sign_in_at: nil).count
Expand Down
56 changes: 0 additions & 56 deletions bin/cron/update_project_count

This file was deleted.

1 change: 0 additions & 1 deletion cookbooks/cdo-apps/templates/default/crontab.erb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
cronjob at:'*/1 * * * *', do:deploy_dir('bin', 'cron', 'user_geos')
cronjob at:'0 9 * * 5', do:deploy_dir('bin', 'cron', 'create_rollup_tables')
cronjob at:"0 8 * * *", do:deploy_dir('bin', 'cron', 'purge_expired_deleted_accounts')
cronjob at:'0 4 * * 0', do:deploy_dir('bin', 'cron', 'update_project_count')
end
end

Expand Down
3 changes: 0 additions & 3 deletions dashboard/app/views/projects/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
:ruby
- @page_title = t('project.project_gallery')
- is_public = local_assigns[:is_public]
- limited_gallery = local_assigns[:limited_gallery]
- projects_data = {}
- projects_data[:limitedGallery] = limited_gallery
- projects_data[:projectCount] = fetch_project_count['rounded_down_millions']

- if current_user
- projects_data[:canViewAdvancedTools] = !(current_user.under_13? && current_user.terms_version.nil?)
- projects_data[:canShare] = !current_user.sharing_disabled?
Expand Down
4 changes: 0 additions & 4 deletions dashboard/app/views/projects/public.html.haml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
- limited_gallery = local_assigns[:limited_gallery]
- projects_data = {}
- projects_data[:limitedGallery] = limited_gallery
- projects_data[:projectCount] = fetch_project_count['rounded_down_millions']

- if current_user
- projects_data[:canViewAdvancedTools] = !(current_user.under_13? && current_user.terms_version.nil?)

%script{src: asset_path("js/#{js_locale}/common_locale.js"), data: {projects: projects_data.to_json}}
%script{src: minifiable_asset_path('js/projects/public.js')}
Expand Down
13 changes: 2 additions & 11 deletions lib/cdo/properties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,13 @@ def self.get_user_metrics
end

def fetch_metrics
# Include stale default values as of 2017-06-21 (project count from 2019-1-20) so we never show 0. These
# Include stale default values as of 2017-06-21 so we never show 0. These
# would be used, for example, if the DB is unavailable.
Properties.get(:metrics) || {
'created_at' => '2017-06-21T14:46:25+00:00',
'created_on' => 'created_on"=>"2017-06-21',
'petition_signatures' => 1_774_817,
'lines_of_code' => 21_238_497_830,
'project_count' => 35_000_000
}
end

def fetch_project_count
current_project_count = fetch_metrics['project_count']
{
'total_projects' => current_project_count,
'rounded_down_millions' => (current_project_count / 1_000_000).floor
'lines_of_code' => 21_238_497_830
}
end

Expand Down
2 changes: 1 addition & 1 deletion pegasus/sites.v3/code.org/views/homepage_gallery.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#gallerycolumn.same-height-column
%a.nounderscorehover.linktag#projects-images{href: CDO.studio_url("projects/public")}
.headingbox{style: "background-color: rgb(#{bgc_body})"}
= I18n.t('homepage_gallery_header', project_count: fetch_project_count['rounded_down_millions'])
= I18n.t(:homepage_header_codestudio)
.thelinks
%img.col-50.lazyload{'data-src':"/shared/images/gallery/fit-750/gallery_thumbnails_2019a.jpg", width: 750, height: 120}
%img.col-50.lazyload{'data-src':"/shared/images/gallery/fit-750/gallery_thumbnails_2019b.jpg", width: 750, height: 120}
3 changes: 1 addition & 2 deletions pegasus/sites.v3/code.org/views/stats_homepage.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
:ruby
student_accounts_percent = "30%"
female_students = "15M"
project_count = fetch_project_count['rounded_down_millions']
project_count = project_count.to_s + "M"
project_count = "35M"
teacher_users = "1M"
states_policy_change = "48"

Expand Down

0 comments on commit 96d7542

Please sign in to comment.